Jump to content

API:Contributors

From mediawiki.org
MediaWiki version:
1.23

GET request to view the list of logged-in contributors and the count of anonymous contributors to a page.

API documentation

[edit]

prop=contributors (pc)

(main | query | contributors)

Get the list of logged-in contributors and the count of logged-out contributors to a page.

Specific parameters:
Other general parameters are available.
pcgroup

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
pcexcludegroup

Exclude 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
pcrights

Only include users having 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, bigdelete, block, blockemail, bot, browsearchive, centralauth-createlocal, centralauth-lock, centralauth-merge, centralauth-rename, centralauth-suppress, centralauth-unmerge, changetags, checkuser, checkuser-log, checkuser-temporary-account, checkuser-temporary-account-log, checkuser-temporary-account-no-preference, collectionsaveascommunitypage, collectionsaveasuserpage, 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, interwiki, ipblock-exempt, ipinfo, ipinfo-view-basic, ipinfo-view-full, ipinfo-view-log, lqt-merge, lqt-react, lqt-split, 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-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, read, renameuser, 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, suppressionlog, suppressredirect, suppressrevision, tboverride, tboverride-account, templateeditor, titleblacklistlog, torunblocked, transcode-reset, transcode-status, translate, translate-groupreview, translate-import, translate-manage, translate-messagereview, unblockself, undelete, unfuzzy, unreviewedpages, unwatchedpages, upload, upload_by_url, 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).
pcexcluderights

Exclude users having 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, bigdelete, block, blockemail, bot, browsearchive, centralauth-createlocal, centralauth-lock, centralauth-merge, centralauth-rename, centralauth-suppress, centralauth-unmerge, changetags, checkuser, checkuser-log, checkuser-temporary-account, checkuser-temporary-account-log, checkuser-temporary-account-no-preference, collectionsaveascommunitypage, collectionsaveasuserpage, 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, interwiki, ipblock-exempt, ipinfo, ipinfo-view-basic, ipinfo-view-full, ipinfo-view-log, lqt-merge, lqt-react, lqt-split, 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-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, read, renameuser, 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, suppressionlog, suppressredirect, suppressrevision, tboverride, tboverride-account, templateeditor, titleblacklistlog, torunblocked, transcode-reset, transcode-status, translate, translate-groupreview, translate-import, translate-manage, translate-messagereview, unblockself, undelete, unfuzzy, unreviewedpages, unwatchedpages, upload, upload_by_url, 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).
pclimit

How many contributors to return.

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

When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.


Example

[edit]

GET request

[edit]
GET request to view the logged-in and anonymous contributors to a page.

Response

[edit]
{
    "continue": {
        "pccontinue": "323710|1591",
        "continue": "||"
    },
    "query": {
        "pages": {
            "323710": {
                "pageid": 323710,
                "ns": 0,
                "title": "MediaWiki",
                "anoncontributors": 603,
                "contributors": [
                    {
                        "userid": 1,
                        "name": "Damian Yerrick"
                    },
                    {
                        "userid": 11,
                        "name": "Kpjas"
                    },
                    {
                        "userid": 43,
                        "name": "Lee Daniel Crocker"
                    },
                    ...
                ]
            }
        }
    }
}

Sample code

[edit]

Python

[edit]
#!/usr/bin/python3

"""
    get_contributors.py

    MediaWiki API Demos
    Demo of `Contributors` module: List all the logged-in contributors and count of anonymous 
    contributors to a page.

    MIT License
"""

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

PARAMS = {
    "action": "query",
    "titles": "MediaWiki",
    "prop": "contributors",
    "format": "json"
}

R = S.get(url=URL, params=PARAMS)
DATA = R.json()

print(DATA)

PHP

[edit]
<?php
/*
    get_contributors.php

    MediaWiki API Demos
    Demo of `Contributors` module: List all the logged-in contributors and count of anonymous 
    contributors to a page.

    MIT License
*/

$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
    "action" => "query",
    "titles" => "MediaWiki",
    "prop" => "contributors",
    "format" => "json"
];

$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 );
var_dump( $result );

Javascript

[edit]
/*
    get_contributors.js

    MediaWiki API Demos
    Demo of `Contributors` module: Get request to list all logged-in contributors and count of anonymous contributors to a page.

    MIT License
*/

const fetch = require('node-fetch');
var url = "https://en.wikipedia.org/w/api.php"; 

var params = {
    action: "query",
    titles: "MediaWiki",
    prop: "contributors",
    format: "json"
};

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 pages = response.query.pages;
        for (var page in pages) {
            console.log(pages[page].anoncontributors);
            console.log(pages[page].contributors);
        }    
    })
    .catch(function(error){console.log(error);});

MediaWiki JS

[edit]
/*
	get_contributors.js

	MediaWiki API Demos
	Demo of `Contributors` module: List all the logged-in contributors and count of anonymous 
        contributors to a page.
	MIT License
*/

var params = {
		action: 'query',
		titles: 'MediaWiki',
		prop: 'contributors',
		format: 'json'
	},
	api = new mw.Api();

api.get( params ).done( function ( data ) {
	console.log( data );
} );

Additional notes

[edit]

See also

[edit]
  • API:Users - to view information about a list of users.