Jump to content

API:Všichni uživatelé

From mediawiki.org
This page is a translated version of the page API:Allusers and the translation is 100% complete.
Verze MediaWiki:
1.11

GET požadavek pro zobrazení seznamu všech registrovaných uživatelů seřazených podle uživatelského jména.

Dokumentace API

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, community-wishlist-manager, confirmed, event-organizer, flow-bot, import, interface-admin, ipblock-exempt, no-ipinfo, steward, suppress, sysop, temporary-account-viewer, translationadmin, transwiki, uploader
auexcludegroup

Exclude users in the given groups.

Values (separate with | or alternative): accountcreator, autopatrolled, bot, bureaucrat, checkuser, community-wishlist-manager, confirmed, event-organizer, flow-bot, import, interface-admin, ipblock-exempt, no-ipinfo, steward, suppress, sysop, temporary-account-viewer, 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-blocked-external-domains-log, 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, badoath-long, bigdelete, block, blockemail, bot, browsearchive, campaignevents-delete-registration, campaignevents-email-participants, campaignevents-enable-registration, campaignevents-generate-invitation-lists, campaignevents-organize-events, campaignevents-view-private-participants, centralauth-createlocal, centralauth-lock, centralauth-merge, centralauth-rename, centralauth-suppress, centralauth-unmerge, changeemail, changetags, checkuser, checkuser-log, checkuser-suggested-investigations, checkuser-temporary-account, checkuser-temporary-account-auto-reveal, checkuser-temporary-account-log, checkuser-temporary-account-no-preference, checkuser-userinfo, collectionsaveascommunitypage, collectionsaveasuserpage, confirmemail, createaccount, createpage, createpreviouslyrenamedaccount, createtalk, createwithcontentmodel, delete, delete-redirect, deletechangetags, deletedhistory, deletedtext, deletelogentry, deleterevision, disableoath, echo-create, echo-read-notifications, edit, editalluserpages, editautopatrolprotected, editautoreviewprotected, editcontentmodel, editeditorprotected, editextendedsemiprotected, editinterface, editmyoptions, editmyprivateinfo, editmyusercss, editmyuserjs, editmyuserjson, editmyuserjsredirect, editmywatchlist, editpatrolprotected, 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-local-status, globalgroupmembership, globalgrouppermissions, hideuser, ignore-restricted-groups, import, importupload, interwiki, ipblock-exempt, ipinfo, ipinfo-ip-lookup, ipinfo-view-arbitrary-ip, ipinfo-view-basic, ipinfo-view-full, ipinfo-view-log, linkpurge, logentryimport, logout, lqt-merge, lqt-react, lqt-split, mailpassword, manage-all-push-subscriptions, manage-wishlist, managechangetags, managementors, manually-edit-wishlist, 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-disable-for-user, oathauth-enable, oathauth-recover-for-user, oathauth-verify-user, oathauth-view-log, override-antispoof, override-export-depth, pagelang, pagetranslation, patrol, patrolmarks, post-hcaptcha-token, protect, purge, read, recover-2fa, renameuser, renameuser-global, renderfile, renderfile-nonstandard, reupload, reupload-own, reupload-shared, review, rollback, sboverride, securepoll-create-poll, securepoll-edit-poll, securepoll-view-voter-pii, sendemail, setmentor, siteadmin, skipcaptcha, spamblacklistlog, stablesettings, stashbasehtml, stashedit, suppressionlog, suppressredirect, suppressrevision, tboverride, tboverride-account, templateeditor, thanks-notification, titleblacklistlog, torunblocked, transcode-reset, transcode-status, translate, translate-empty-category, 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, verify-2fa, viewdeletedfile, viewmyprivateinfo, viewmywatchlist, viewsuppressed, wikilambda-abstract-optin, wikimediaevents-hcaptcha-diff-logging
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.
tempexpired
Indicates whether the temporary account has expired or not. If account isn't temporary, null is returned.
Values (separate with | or alternative): blockinfo, centralids, editcount, groups, implicitgroups, registration, rights, tempexpired
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)

Příklad

Dotazování přes GET

Požadavek GET pro výpis všech uživatelů, počínaje těmi, jejichž jména začínají řetězcem "Drov"

Odpověď

{
    "batchcomplete": "",
    "continue": {
        "aufrom": "Drovark",
        "continue": "-||"
    },
    "query": {
        "allusers": [
            {
                "userid": 13239275,
                "name": "Drov"
            },
            {
                "userid": 7080866,
                "name": "Drova"
            },
            {
                "userid": 16013473,
                "name": "Drova 82"
            },
            ...
        ]
    }
}

Ukázkový kód

Python

#!/usr/bin/python3

"""
    get_allusers.py

    MediaWiki API Demos
    Demo of `Allusers` module: Get 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()

USERS = DATA["query"]["allusers"]

for user in USERS:
    print(user["name"])

PHP

<?php
/*
    get_allusers.php

    MediaWiki API Demos
    Demo of `Allusers` module: Get all users, starting from those whose name begins with the string, 'Drov'.

    MIT License
*/

$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
    "action" => "query",
    "format" => "json",
    "list" => "allusers",
    "auprefix" => "Drov"
];

$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 );

foreach( $result["query"]["allusers"] as $k => $v ) {
    echo( $v["name"] . "\n" );
}

JavaScript

/*
    get_allusers.js

    MediaWiki API Demos
    Demo of `Allusers` module: Get all users, starting from those whose name begins with the string, 'Drov'.

    MIT License
*/

var url = "https://en.wikipedia.org/w/api.php"; 

var params = {
    action: "query",
    format: "json",
    list: "allusers",
    auprefix: "Drov"
};

url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});

fetch(url)
    .then(function(response){return response.json();})
    .then(function(response) {
        var users = response.query.allusers;
        for (var u in users) {
            console.log(users[u].name);
        }
    })
    .catch(function(error){console.log(error);});

MediaWiki JS

/*
	get_allusers.js

	MediaWiki API Demos
	Demo of `Allusers` module: Get all users, starting from those
	whose name begins with the string, 'Drov'.

	MIT License
*/

var params = {
		action: 'query',
		format: 'json',
		list: 'allusers',
		auprefix: 'Drov'
	},
	api = new mw.Api();

api.get( params ).done( function ( data ) {
	var users = data.query.allusers,
		u;
	for ( u in users ) {
		console.log( users[ u ].name );
	}
} );

Možné chyby

Kód Popis
augroup-excludegroup group a excludegroup nelze použít společně

Historie parametrů

  • v1.12: Představeno auprop=registration

Další poznámky

  • Toto volání API rozlišuje velká a malá písmena, takže aufrom=DROV nevrací stejné výsledky jako aufrom=Drov.
  • Všechna registrovaná uživatelská jména jsou uložena a načtena s velkými písmeny. Pokud v dotazu používáte aufrom nebo auprefix, ujistěte se, že jim předáváte hodnoty začínající velkým písmenem.
  • Ačkoli je výchozím chováním vypsání libovolného uživatele v databázi, můžeme také omezit naši odpověď pouze na ty uživatele, kteří patří do určité skupiny, jako jsou sysopové nebo roboti. Uživatelské skupiny jsou způsob, jakým MediaWiki uděluje uživatelům určitá práva a privilegia. Více informací o fungování tohoto systému naleznete v části Nápověda:Uživatelská práva a skupiny .

Související odkazy