User:Martyav/Sandbox/API:Users
Appearance
MediaWiki version: | ≥ 1.12 |
GET Request to view information about a list of users.
API documentation
[edit]
list=users (us)
Get information about a list of users. Specific parameters: Other general parameters are available.
Example:
|
Example
[edit]GET Request
[edit]Get a list of the specified users -- each item in the list contains information specified by the
usprop
parameterapi.php? action=query& list=users& ususers=1.2.3.4|Catrope|Vandal01|Bob& usprop=blockinfo|groups|editcount|registration|emailable|gender [try in ApiSandbox]
Response
[edit]{
"batchcomplete": "",
"query": {
"users": [
{
"name": "1.2.3.4",
"invalid": ""
},
{
"userid": 4587601,
"name": "Catrope",
"editcount": 359,
"registration": "2007-06-07T16:36:03Z",
"groups": [
"*",
"user",
"autoconfirmed"
],
"emailable": "",
"gender": "male"
},
{
"name": "Vandal01",
"missing": ""
},
{
"userid": 2793024,
"name": "Bob",
"editcount": 4542,
"registration": "2006-11-18T21:55:03Z",
"groups": [
"extendedconfirmed",
"reviewer",
"*",
"user",
"autoconfirmed"
],
"emailable": "",
"gender": "male"
}
]
}
}
Sample code
[edit]get_users.py
#!/usr/bin/python3
"""
get_users.py
MediaWiki Action API Code Samples
Demo of `Users` module: Get information about several users:
[[1.2.3.4]], [[Catrope]], [[Vandal01]], and [[Bob]]
MIT license
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"format": "json",
"list": "users",
"ususers": "1.2.3.4|Catrope|Vandal01|Bob",
"usprop": "blockinfo|groups|editcount|registration|emailable|gender"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)
Parameter history
[edit]- v1.29: Introduced
ususerids
,userrights
- v1.24: Deprecated
ustoken
- v1.18: Introduced
implicitgroups
- v1.17: Introduced
rights
- v1.16: Introduced
ususerids
,gender
- v1.14: Introduced
emailable
- v1.13: Introduced
registration
See also
[edit]- Help:User rights and groups: More information on user rights, and how they relate to groups
- API:User group membership: Adding and removing users from groups