Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

API:Userinfo

From mediawiki.org
Translate this page
Languages:
This page is part of theMediaWiki Action API documentation.
MediaWiki Action API
Basics
Authentication
Accounts and Users
Page Operations
Search
Developer Utilities
Tutorials
v·d·e
MediaWiki version:
1.11

GET request to return information about the currently logged-in user.

API documentation

[edit]
The following documentation is the output ofSpecial:ApiHelp/query+userinfo, automatically generated by the pre-release version of MediaWiki that is running on this site (MediaWiki.org).

meta=userinfo (ui)

(main |query |userinfo)

Get information about the current user.

Specific parameters:
Other general parameters are available.
uiprop

Which pieces of information to include:

blockinfo
Tags if the current user is blocked, by whom, and for what reason.
hasmsg
Adds a tagmessages if the current user has pending messages.
groups
Lists all the groups the current user belongs to.
groupmemberships
Lists groups that the current user has been explicitly assigned to, including the expiry date of each group membership.
implicitgroups
Lists all the groups the current user is automatically a member of.
rights
Lists all the rights the current user has.
changeablegroups
Lists the groups the current user can add to and remove from.
options
Lists all preferences the current user has set.
editcount
Adds the current user's edit count.
ratelimits
Lists all rate limits applying to the current user.
theoreticalratelimits
Lists all rate limits that would apply to the current user if they were not exempt from all ratelimits based on user rights or ip.
email
Adds the user's email address and email authentication date.
realname
Adds the user's real name.
acceptlang
Echoes theAccept-Language header sent by the client in a structured format.
registrationdate
Adds the user's registration date.
unreadcount
Adds the count of unread pages on the user's watchlist (maximum 999; returns1000+ if more).
centralids
Adds the central IDs and attachment status for the user.
latestcontrib
Adds the date of user's latest contribution.
cancreateaccount
Indicates whether the user is allowed to create accounts. To check whether some specific account can be created, useaction=query&list=users&usprop=cancreate.
Values (separate with| oralternative): acceptlang, blockinfo, cancreateaccount, centralids, changeablegroups, editcount, email, groupmemberships, groups, hasmsg, implicitgroups, latestcontrib, options, ratelimits, realname, registrationdate, rights, theoreticalratelimits, unreadcount
To specify all values, use*.
uiattachedwiki

Withuiprop=centralids, indicate whether the user is attached with the wiki identified by this ID.

Examples:
Get information about the current user.
api.php?action=query&meta=userinfo[open in sandbox]
Get additional information about the current user.
api.php?action=query&meta=userinfo&uiprop=blockinfo|groups|rights|hasmsg[open in sandbox]

Example

[edit]

GET request

[edit]
Get general user info and user rights.
api.php?action=query&meta=userinfo&uiprop=rights&format=json [try in ApiSandbox]

Response

[edit]
{"batchcomplete":"","query":{"userinfo":{"id":37494596,"name":"Zaycodes","groups":["*","user"],"rights":["createaccount","read","edit","createtalk","writeapi","viewmywatchlist","editmywatchlist","viewmyprivateinfo","editmyprivateinfo",...]}}

Sample code

[edit]

Python

[edit]
#!/usr/bin/python3"""    userinfo.py    MediaWiki API Demos    Demo of `Userinfo` module: Get general user info and user rights    MIT License"""importrequestsS=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

[edit]
<?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

[edit]
/*    userinfo.js    MediaWiki API Demos    Demo of `Userinfo` module: Get general user info and user rights    MIT License*/varurl="https://en.wikipedia.org/w/api.php";varparams={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){returnresponse.json();}).then(function(response){console.log(response);}).catch(function(error){console.log(error);});

MediaWiki JS

[edit]
/*userinfo.jsMediaWiki API DemosDemo of `Userinfo` module: Get general user info and user rightsMIT License*/varparams={action:'query',meta:'userinfo',uiprop:'rights',format:'json'};varapi=newmw.Api();api.get(params).then(function(data){console.log(data);});

Parameter history

[edit]
  • v1.33: Introducedlatestcontrib
  • v1.24: Introducedunreadcount
  • v1.18: Introducedimplicitgroups,registrationdate,realname
  • v1.17: Introducedacceptlang
  • v1.16: Introducedchangeablegroups
  • v1.15: Introducedemail
  • v1.14: Introducedpreferencestoken
  • v1.12: Introducedratelimits,editcount

Additional notes

[edit]
  • The code for theuserinfo function is located atApiQueryUserInfo.php.
  • If you need access to user information not listed here for a user on a Wikimedia project, please email privacy@wikimedia.org for further assistance.

See also

[edit]
Retrieved from "https://www.mediawiki.org/w/index.php?title=API:Userinfo&oldid=7531234"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp