GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing www.mediawiki.org — API:Userinfo - MediaWiki
GET request to return information about the currently logged-in user. API documentation
meta=userinfo (ui)
Get information about the current user. Specific parameters: Other general parameters are available.
Examples:
ExampleGET requestGet general user info and user rights.
Response{ "batchcomplete": "", "query": { "userinfo": { "id": 37494596, "name": "Zaycodes", "groups": [ "*", "user" ], "rights": [ "createaccount", "read", "edit", "createtalk", "writeapi", "viewmywatchlist", "editmywatchlist", "viewmyprivateinfo", "editmyprivateinfo", ... ] } } Sample codePython#!/usr/bin/python3 """ userinfo.py MediaWiki API Demos Demo of `Userinfo` module: Get general user info and user rights MIT License """ import requests S = requests.Session() URL = "https://en.wikipedia.org/w/api.php" PARAMS = { "action": "query", "meta": "userinfo", "uiprop": "rights", "format": "json" } R = S.get(url=URL, params=PARAMS) DATA = R.json() print(DATA) PHP<?php /* userinfo.php MediaWiki API Demos Demo of `Userinfo` module: Get general user info and user rights MIT License */ $endPoint = "https://en.wikipedia.org/w/api.php"; $params = [ "action" => "query", "meta" => "userinfo", "uiprop" => "rights", "format" => "json" ]; $url = $endPoint . "?" . http_build_query( $params ); $ch = curl_init( $url ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $output = curl_exec( $ch ); curl_close( $ch ); $result = json_decode( $output, true ); var_dump( $result ); JavaScript/* userinfo.js MediaWiki API Demos Demo of `Userinfo` module: Get general user info and user rights MIT License */ var url = "https://en.wikipedia.org/w/api.php"; var params = { action: "query", meta: "userinfo", uiprop: "rights", format: "json" }; url = url + "?origin=*"; Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];}); fetch(url) .then(function(response){return response.json();}) .then(function(response) {console.log(response);}) .catch(function(error){console.log(error);}); MediaWiki JS/* userinfo.js MediaWiki API Demos Demo of `Userinfo` module: Get general user info and user rights MIT License */ var params = { action: 'query', meta: 'userinfo', uiprop: 'rights', format: 'json' }; var api = new mw.Api(); api.get( params ).then( function ( data ) { console.log( data ); } ); Parameter history
Additional notes
See also
| ||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |