API:利用者

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page API:Users and the translation is 81% complete.

Other languages:
English • ‎dansk • ‎日本語
MediaWiki バージョン: 1.12

利用者の一覧についての情報を閲覧する GET リクエストです。

APIの説明文書




list=users (us)

(main | query | users)

Get information about a list of users.

Parameters:
usprop

Which pieces of information to include:

blockinfo
Tags if the user is blocked, by whom, and for what reason.
groups
Lists all the groups each user belongs to.
groupmemberships
Lists groups that each user has been explicitly assigned to, including the expiry date of each group membership.
implicitgroups
Lists all the groups a user is automatically a member of.
rights
Lists all the rights each user has.
editcount
Adds the user's edit count.
registration
Adds the user's registration timestamp.
emailable
Tags if the user can and wants to receive email through Special:Emailuser.
gender
Tags the gender of the user. Returns "male", "female", or "unknown".
centralids
Adds the central IDs and attachment status for the user.
cancreate
Indicates whether an account for valid but unregistered usernames can be created.
Values (separate with | or alternative): blockinfo, groups, groupmemberships, implicitgroups, rights, editcount, registration, emailable, gender, centralids, cancreate
usattachedwiki

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

ususers

A list of users to obtain information for.

Separate values with | or alternative. Maximum number of values is 50 (500 for bots).
ususerids

A list of user IDs to obtain information for.

Type: list of integers
Separate values with | or alternative. Maximum number of values is 50 (500 for bots).
ustoken
Deprecated.

Use action=query&meta=tokens instead.

Values (separate with | or alternative): userrights

GET リクエスト

Get a list of the specified users -- each item in the list contains information specified by the usprop parameter

レスポンス

{
    "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"
            }
        ]
    }
}

サンプル コード

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)

パラメーターの履歴

  • v1.29: ususerids, userrights を導入しました
  • v1.24: ustoken を廃止予定にしました
  • v1.18: implicitgroups を導入しました
  • v1.17: rights を導入しました
  • v1.16: ususerids, gender を導入しました
  • v1.14: emailable を導入しました
  • v1.13: registration を導入しました

関連項目