API:Allusers: Difference between revisions
translation tweaks |
updated as per the 'improving the top 50 action APIs' project |
||
Line 1: | Line 1: | ||
{{API}} |
{{API}} |
||
{{MW 1.11|and after}} |
|||
{{API-head |
|||
'''Get request''' to list all registered users, as ordered by username. |
|||
|version=1.11 |
|||
|prefix=au |
|||
|rrights=None |
|||
|postonly=No |
|||
|description=<nowiki>Enumerate all registered users, ordered by username</nowiki> |
|||
|generator=no |
|||
|query=yes |
|||
}} |
|||
== |
== API documentation == |
||
{| style="color: black; background-color: #f8f8f8; border-spacing: 20px; border: 1px solid darkgray;" |
|||
*{{ApiParam|aufrom |The user name to start enumerating from}} |
|||
| {{Api help|query+allusers}} |
|||
*{{ApiParam|auto |The user name to stop enumerating at}} |
|||
|} |
|||
*{{ApiParam|auprefix |Search for all users that begin with this value}} |
|||
*{{ApiParam|audir |Direction to sort in. One value: ascending, descending. Default: ascending}} |
|||
*{{ApiParam|augroup |Limit users to given group name(s).|values=bot, sysop, bureaucrat (+ any other group that is defined on the wiki). This is different for every wiki; see the API help or {{ll|API:Parameter information|action{{=}}paraminfo}} for a list of possible values}} |
|||
*{{ApiParam|auexcludegroup |Exclude users in given group name(s). Can not be used together with 'group'.}} |
|||
*{{ApiParam|aurights |Limit users to given right(s)}} |
|||
*{{ApiParam|auprop |What pieces of information to include.}} |
|||
**{{ApiParam|blockinfo |Adds the information about a current block on the user}} |
|||
**{{ApiParam|groups |Lists groups that the user is in. This uses more server resources and may return fewer results than the limit}} |
|||
**{{ApiParam|implicitgroups|Lists all the groups the user is automatically in}} |
|||
**{{ApiParam|rights |Lists rights that the user has}} |
|||
**{{ApiParam|editcount |Adds the edit count of the user}} |
|||
**{{ApiParam|registration |Adds the timestamp of when the user registered if available (may be blank)|version=1.12}} |
|||
*{{ApiParam|aulimit |How many total user names to return.|maxallowed=500|default=10}} |
|||
*{{ApiParam|auwitheditsonly|Only list users who have made edits}} |
|||
*{{ApiParam|auactiveusers |Only list users active in the last 30 days(s)}} |
|||
== Example == |
== Example == |
||
=== GET Request === |
|||
{{ApiEx |
{{ApiEx |
||
| |
|desc=GET request to list all users, starting from those whose name begins with the string, "Drov" |
||
| |
|p1=action=query |
||
| |
|p2=format=json |
||
| |
|p3=list=allusers |
||
|p4=auprefix=Drov |
|||
| result=<source lang="json">{ |
|||
}} |
|||
"batchcomplete": "", |
|||
"continue": { |
|||
"aufrom": "Y 20", |
|||
"continue": "-||" |
|||
}, |
|||
"query": { |
|||
"allusers": [ |
|||
{ |
|||
"userid": 3634417, |
|||
"name": "Y" |
|||
}, |
|||
{ |
|||
"userid": 53928, |
|||
"name": "Y (usurped)" |
|||
}, |
|||
{ |
|||
"userid": 17490379, |
|||
"name": "Y . SOUNA" |
|||
}, |
|||
{ |
|||
"userid": 24519575, |
|||
"name": "Y 10bushehrii" |
|||
}, |
|||
{ |
|||
"userid": 32323885, |
|||
"name": "Y 11" |
|||
}, |
|||
{ |
|||
"userid": 7341556, |
|||
"name": "Y 12345 ut" |
|||
}, |
|||
{ |
|||
"userid": 31689152, |
|||
"name": "Y 1526" |
|||
}, |
|||
{ |
|||
"userid": 10969800, |
|||
"name": "Y 19" |
|||
}, |
|||
{ |
|||
"userid": 21703794, |
|||
"name": "Y 1977k" |
|||
}, |
|||
{ |
|||
"userid": 9302968, |
|||
"name": "Y 1praneeth" |
|||
} |
|||
] |
|||
} |
|||
}</source>}} |
|||
=== Response === |
|||
{{ApiEx |
|||
<div style="width:60%;"> |
|||
| desc=Show a list of first 5 sysops |
|||
<syntaxhighlight lang="json"> |
|||
| p1= action=query |
|||
{ |
|||
| p2= list=allusers |
|||
| p3= augroup=sysop |
|||
| p4= aulimit=5 |
|||
| result=<source lang="json">{ |
|||
"batchcomplete": "", |
"batchcomplete": "", |
||
"continue": { |
"continue": { |
||
"aufrom": " |
"aufrom": "Drovark", |
||
"continue": "-||" |
"continue": "-||" |
||
}, |
}, |
||
Line 103: | Line 31: | ||
"allusers": [ |
"allusers": [ |
||
{ |
{ |
||
"userid": |
"userid": 13239275, |
||
"name": " |
"name": "Drov" |
||
}, |
}, |
||
{ |
{ |
||
"userid": |
"userid": 7080866, |
||
"name": " |
"name": "Drova" |
||
}, |
}, |
||
{ |
{ |
||
"userid": |
"userid": 16013473, |
||
"name": " |
"name": "Drova 82" |
||
}, |
}, |
||
... |
|||
"userid": 8638440, |
|||
"name": "78.26" |
|||
}, |
|||
{ |
|||
"userid": 195987, |
|||
"name": "A Train" |
|||
} |
|||
] |
] |
||
} |
} |
||
} |
|||
}</source>}} |
|||
</syntaxhighlight> |
|||
</div> |
|||
=== Sample code === |
|||
'''''get_allusers.py''''' |
|||
<div style="width:60%;"> |
|||
<syntaxhighlight lang="python3"> |
|||
#!/usr/bin/python3 |
|||
""" |
|||
== Error Codes == |
|||
get_allusers.py |
|||
{| class="wikitable sortable" |
|||
! Code !! Info |
|||
MediaWiki Action API Code Samples |
|||
Demo of `Allusers` module: GET request to list all users, |
|||
starting from those whose name begins with the string, "Drov" |
|||
MIT license |
|||
""" |
|||
import requests |
|||
S = requests.Session() |
|||
URL = "https://en.wikipedia.org/w/api.php" |
|||
PARAMS = { |
|||
"action":"query", |
|||
"format":"json", |
|||
"list":"allusers", |
|||
"auprefix":"Drov" |
|||
} |
|||
R = S.get(url=URL, params=PARAMS) |
|||
DATA = R.json() |
|||
print(DATA) |
|||
</syntaxhighlight> |
|||
</div> |
|||
== Possible errors == |
|||
{| class="wikitable" |
|||
|+ |
|||
!Code!!Info |
|||
|- |
|- |
||
| |
|augroup-excludegroup || group and excludegroup cannot be used together |
||
|} |
|} |
||
== |
== Parameter history == |
||
* v1.12: Introduced <code>auprop=registration</code> |
|||
This api call is case sensitive, so aufrom=YA doesn't have the same results as aufrom=Ya. |
|||
[[Category:MediaWiki API query lists]] |
|||
== Additional notes == |
|||
* This API call is case sensitive, so <code>aufrom=DROV</code> doesn't return the same results as <code>aufrom=Drov</code>. |
|||
* All registered usernames are saved and retrieved in capitalized form. If you are using <code>aufrom</code> or <code>auprefix</code> in your query, make sure you are passing them values that start with an uppercase character. |
|||
* Although the default behavior is to list any user in the database, we can also limit our response to only those users who belong to a certain group, such as sysops, or bots. User groups are how MediaWiki grants users certain rights and privileges; see [[Help:User rights and groups]] for more details on how this system works. |
|||
== See also == |
|||
* [[API:Users]] - finds information about a list of users. |
Revision as of 01:55, 4 January 2019
This page is part of the MediaWiki Action API documentation. |
MediaWiki version: | ≥ 1.11 |
Get request to list all registered users, as ordered by username.
API documentation
list=allusers (au)
Enumerate all registered users. Specific parameters: Other general parameters are available.
Example:
|
Example
GET Request
Response
{
"batchcomplete": "",
"continue": {
"aufrom": "Drovark",
"continue": "-||"
},
"query": {
"allusers": [
{
"userid": 13239275,
"name": "Drov"
},
{
"userid": 7080866,
"name": "Drova"
},
{
"userid": 16013473,
"name": "Drova 82"
},
...
]
}
}
Sample code
get_allusers.py
#!/usr/bin/python3
"""
get_allusers.py
MediaWiki Action API Code Samples
Demo of `Allusers` module: GET request to list all users,
starting from those whose name begins with the string, "Drov"
MIT license
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action":"query",
"format":"json",
"list":"allusers",
"auprefix":"Drov"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)
Possible errors
Code | Info |
---|---|
augroup-excludegroup | group and excludegroup cannot be used together |
Parameter history
- v1.12: Introduced
auprop=registration
Additional notes
- This API call is case sensitive, so
aufrom=DROV
doesn't return the same results asaufrom=Drov
. - All registered usernames are saved and retrieved in capitalized form. If you are using
aufrom
orauprefix
in your query, make sure you are passing them values that start with an uppercase character. - Although the default behavior is to list any user in the database, we can also limit our response to only those users who belong to a certain group, such as sysops, or bots. User groups are how MediaWiki grants users certain rights and privileges; see Help:User rights and groups for more details on how this system works.
See also
- API:Users - finds information about a list of users.