Jump to content

API:Allusers: Difference between revisions

From mediawiki.org
Content deleted Content added
translation tweaks
Martyav (talk | contribs)
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
}}


== Parameters ==
== 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=Show a list of usernames starting with Y (or whichever sorts first after that)
|desc=GET request to list all users, starting from those whose name begins with the string, "Drov"
| p1= action=query
|p1=action=query
| p2= list=allusers
|p2=format=json
| p3= aufrom=Y
|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": "AA",
"aufrom": "Drovark",
"continue": "-||"
"continue": "-||"
},
},
Line 103: Line 31:
"allusers": [
"allusers": [
{
{
"userid": 111640,
"userid": 13239275,
"name": "(aeropagitica)"
"name": "Drov"
},
},
{
{
"userid": 3030741,
"userid": 7080866,
"name": "28bytes"
"name": "Drova"
},
},
{
{
"userid": 7044616,
"userid": 16013473,
"name": "5 albert square"
"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
|augroup-excludegroup || group and excludegroup cannot be used together
|}
|}


== Note ==
== 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

MediaWiki version:
1.11

Get request to list all registered users, as ordered by username.

API documentation

list=allusers (au)

(main | query | allusers)

Enumerate all registered users.

Specific parameters:
Other general parameters are available.
aufrom

The username to start enumerating from.

auto

The username to stop enumerating at.

auprefix

Search for all users that begin with this value.

audir

Direction to sort in.

One of the following values: ascending, descending
Default: ascending
augroup

Only include users in the given groups. Does not include implicit or auto-promoted groups like *, user, or autoconfirmed.

Values (separate with | or alternative): accountcreator, autopatrolled, bot, bureaucrat, checkuser, checkuser-temporary-account-viewer, confirmed, flow-bot, import, interface-admin, ipblock-exempt, no-ipinfo, steward, suppress, sysop, translationadmin, transwiki, uploader
auexcludegroup

Exclude users in the given groups.

Values (separate with | or alternative): accountcreator, autopatrolled, bot, bureaucrat, checkuser, checkuser-temporary-account-viewer, confirmed, flow-bot, import, interface-admin, ipblock-exempt, no-ipinfo, steward, suppress, sysop, translationadmin, transwiki, uploader
aurights

Only include users with the given rights. Does not include rights granted by implicit or auto-promoted groups like *, user, or autoconfirmed.

Values (separate with | or alternative): abusefilter-access-protected-vars, abusefilter-bypass-blocked-external-domains, abusefilter-hidden-log, abusefilter-hide-log, abusefilter-log, abusefilter-log-detail, abusefilter-log-private, abusefilter-modify, abusefilter-modify-blocked-external-domains, abusefilter-modify-global, abusefilter-modify-restricted, abusefilter-privatedetails, abusefilter-privatedetails-log, abusefilter-protected-vars-log, abusefilter-revert, abusefilter-view, abusefilter-view-private, apihighlimits, applychangetags, autoconfirmed, autocreateaccount, autopatrol, autoreview, autoreviewrestore, badcaptcha, badoath, bigdelete, block, blockemail, bot, browsearchive, centralauth-createlocal, centralauth-lock, centralauth-merge, centralauth-rename, centralauth-suppress, centralauth-unmerge, changeemail, changetags, checkuser, checkuser-log, checkuser-temporary-account, checkuser-temporary-account-log, checkuser-temporary-account-no-preference, collectionsaveascommunitypage, collectionsaveasuserpage, confirmemail, createaccount, createpage, createtalk, delete, delete-redirect, deletechangetags, deletedhistory, deletedtext, deletelogentry, deleterevision, echo-create, edit, editautopatrolprotected, editautoreviewprotected, editcontentmodel, editeditorprotected, editextendedsemiprotected, editinterface, editmyoptions, editmyprivateinfo, editmyusercss, editmyuserjs, editmyuserjson, editmyuserjsredirect, editmywatchlist, editprotected, editsemiprotected, editsitecss, editsitejs, editsitejson, edittrustedprotected, editusercss, edituserjs, edituserjson, enrollasmentor, extendedconfirmed, flow-create-board, flow-delete, flow-edit-post, flow-edit-title, flow-hide, flow-lock, flow-suppress, globalblock, globalblock-exempt, globalblock-whitelist, globalgroupmembership, globalgrouppermissions, hideuser, import, importupload, ipblock-exempt, ipinfo, ipinfo-view-basic, ipinfo-view-full, ipinfo-view-log, linkpurge, lqt-merge, lqt-react, lqt-split, mailpassword, manage-all-push-subscriptions, managechangetags, managementors, markbotedits, massmessage, mergehistory, minoredit, move, move-categorypages, move-rootuserpages, move-subpages, movefile, movestable, mwoauthmanageconsumer, mwoauthmanagemygrants, mwoauthproposeconsumer, mwoauthsuppress, mwoauthupdateownconsumer, mwoauthviewprivate, mwoauthviewsuppressed, newsletter, newsletter-announce, newsletter-create, newsletter-delete, newsletter-manage, newsletter-restore, nominornewtalk, noratelimit, nuke, oathauth-api-all, oathauth-disable-for-user, oathauth-enable, oathauth-verify-user, oathauth-view-log, override-antispoof, override-export-depth, pagelang, pagetranslation, patrol, patrolmarks, protect, purge, read, renameuser, renderfile, renderfile-nonstandard, reupload, reupload-own, reupload-shared, review, rollback, sboverride, securepoll-create-poll, securepoll-edit-poll, securepoll-view-voter-pii, sendemail, setmentor, sfsblock-bypass, siteadmin, skipcaptcha, spamblacklistlog, stablesettings, stashbasehtml, stashedit, suppressionlog, suppressredirect, suppressrevision, tboverride, tboverride-account, templateeditor, thanks-notification, titleblacklistlog, torunblocked, transcode-reset, transcode-status, translate, translate-groupreview, translate-import, translate-manage, translate-messagereview, unblockself, undelete, unfuzzy, unreviewedpages, unwatchedpages, upload, upload_by_url, urlshortcode, urlshortener-create-url, urlshortener-manage-url, urlshortener-view-log, userrights, userrights-interwiki, validate, viewdeletedfile, viewmyprivateinfo, viewmywatchlist, viewsuppressed
Maximum number of values is 50 (500 for clients that are allowed higher limits).
auprop

Which pieces of information to include:

blockinfo
Adds the information about a current block on the user.
groups
Lists groups that the user is in. This uses more server resources and may return fewer results than the limit.
implicitgroups
Lists all the groups the user is automatically in.
rights
Lists rights that the user has.
editcount
Adds the edit count of the user.
registration
Adds the timestamp of when the user registered if available (may be blank).
centralids
Adds the central IDs and attachment status for the user.
Values (separate with | or alternative): blockinfo, centralids, editcount, groups, implicitgroups, registration, rights
aulimit

How many total usernames to return.

Type: integer or max
The value must be between 1 and 500.
Default: 10
auwitheditsonly

Only list users who have made edits.

Type: boolean (details)
auactiveusers

Only list users active in the last 30 days.

Type: boolean (details)
auattachedwiki

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

auexcludenamed

Exclude users of named accounts.

Type: boolean (details)
auexcludetemp

Exclude users of temporary accounts.

Type: boolean (details)


Example

GET Request

GET request to list all users, starting from those whose name begins with the string, "Drov"

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 as aufrom=Drov.
  • All registered usernames are saved and retrieved in capitalized form. If you are using aufrom or auprefix 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.