API:Lists/All

From MediaWiki.org
Jump to navigation Jump to search

Ugly but useful view of all lists pages combined.

Contents

Allcategories[edit]

MediaWiki version: 1.12

<translate> GET request to list all {{<tvar|1>ll|Help:Categories</>|categories}} that fit certain criteria relating to their titles.

This module can be used as a {{<tvar|1>ll|API:Query#Generators</>|generator}}.

API documentation[edit]

</translate>




list=allcategories (ac)

(main | query | allcategories)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Enumerate all categories.

Parameters:
acfrom

The category to start enumerating from.

accontinue

When more results are available, use this to continue.

acto

The category to stop enumerating at.

acprefix

Search for all category titles that begin with this value.

acdir

Direction to sort in.

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

Only return categories with at least this many members.

Type: integer
acmax

Only return categories with at most this many members.

Type: integer
aclimit

How many categories to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
acprop

Which properties to get:

size
Adds number of pages in the category.
hidden
Tags categories that are hidden with __HIDDENCAT__.
Values (separate with | or alternative): size, hidden
Default: (empty)
Examples:
List categories with information on the number of pages in each.
api.php?action=query&list=allcategories&acprop=size [open in sandbox]
Retrieve info about the category page itself for categories beginning List.
api.php?action=query&generator=allcategories&gacprefix=List&prop=info [open in sandbox]

<translate>

Example[edit]

GET Request[edit]

</translate> <translate> Get a list of all categories, starting from "<tvar

<translate>

Response[edit]

</translate>

{
    {
    "batchcomplete": "",
    "continue": {
        "accontinue": "15th-century_churches_in_Denmark",
        "continue": "-||"
    },
    "query": {
        "allcategories": [
            {
                "*": "15th-century caliphs"
            },
            {
                "*": "15th-century calligraphers"
            },
            {
                "*": "15th-century card games"
            },
            ...
        ]
    }
}

<translate>

Sample code[edit]

</translate> get_allcategories.py

#!/usr/bin/python3

"""
    get_allcategories.py

    MediaWiki Action API Code Samples
    Demo of `Allcategories` module: GET request to list all categories 
    on the English Wikipedia, starting from "15th-century caliphs".
    MIT license
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action":"query",
    "format":"json",
    "list":"allcategories"
    "acfrom": "15th-century caliphs"
}

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

print(DATA)

<translate>

Additional notes[edit]

  • This module differs from <tvar|1>list=allpages&alnamespace=14 </> in that categories without descriptions will be listed, while redirects and pages where the category was never used will not.</translate>

<translate>

  • The response may include categories that were previously used but have since been deleted.</translate>

<translate>

  • Because the response may include categories that are deleted or otherwise empty, it is recommended to filter the list using <tvar|1>acmin=1</>, so as to only return categories containing one or more members.

See also[edit]

</translate>

  • API:Categorymembers - <translate> list pages which are members of a certain category.</translate>
  • API:Categories - <translate> a <tvar|1>prop </> module that gets all the categories associated with a particular page.</translate>
  • API:Allpages - <translate> another module that can access the category {{<tvar|1>ll|Manual:Namespace</>|namespace}}.</translate>

Allimages[edit]

MediaWiki version: 1.13

<translate> GET request to list all image files, ordered by either title or timestamp.

This module can be used as a {{<tvar|1>ll|API:Query#Generators</>|generator}}.

API documentation[edit]

</translate>




list=allimages (ai)

(main | query | allimages)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Enumerate all images sequentially.

Parameters:
aisort

Property to sort by.

One of the following values: name, timestamp
Default: name
aidir

The direction in which to list.

One of the following values: ascending, descending, newer, older
Default: ascending
aifrom

The image title to start enumerating from. Can only be used with aisort=name.

aito

The image title to stop enumerating at. Can only be used with aisort=name.

aicontinue

When more results are available, use this to continue.

aistart

The timestamp to start enumerating from. Can only be used with aisort=timestamp.

Type: timestamp (allowed formats)
aiend

The timestamp to end enumerating. Can only be used with aisort=timestamp.

Type: timestamp (allowed formats)
aiprop

Which file information to get:

timestamp
Adds timestamp for the uploaded version.
user
Adds the user who uploaded each file version.
userid
Add the ID of the user that uploaded each file version.
comment
Comment on the version.
parsedcomment
Parse the comment on the version.
canonicaltitle
Adds the canonical title of the file.
url
Gives URL to the file and the description page.
size
Adds the size of the file in bytes and the height, width and page count (if applicable).
dimensions
Alias for size.
sha1
Adds SHA-1 hash for the file.
mime
Adds MIME type of the file.
mediatype
Adds the media type of the file.
metadata
Lists Exif metadata for the version of the file.
commonmetadata
Lists file format generic metadata for the version of the file.
extmetadata
Lists formatted metadata combined from multiple sources. Results are HTML formatted.
bitdepth
Adds the bit depth of the version.
badfile
Adds whether the file is on the MediaWiki:Bad image list
Values (separate with | or alternative): timestamp, user, userid, comment, parsedcomment, canonicaltitle, url, size, dimensions, sha1, mime, mediatype, metadata, commonmetadata, extmetadata, bitdepth, badfile
Default: timestamp|url
aiprefix

Search for all image titles that begin with this value. Can only be used with aisort=name.

aiminsize

Limit to images with at least this many bytes.

Type: integer
aimaxsize

Limit to images with at most this many bytes.

Type: integer
aisha1

SHA1 hash of image. Overrides aisha1base36.

aisha1base36

SHA1 hash of image in base 36 (used in MediaWiki).

aiuser

Only return files uploaded by this user. Can only be used with aisort=timestamp. Cannot be used together with aifilterbots.

Type: user name
aifilterbots

How to filter files uploaded by bots. Can only be used with aisort=timestamp. Cannot be used together with aiuser.

One of the following values: all, bots, nobots
Default: all
aimime

Disabled due to miser mode.

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

How many images in total to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10

<translate>

Example[edit]

Example 1: Get images by name[edit]

GET Request[edit]

</translate> <translate> List all images in the namespace, starting from files that begin with "<tvar

<translate>

Response[edit]

</translate>

{
    "batchcomplete": "",
    "continue": {
        "aicontinue": "Graffiti_BTER_0001.JPG",
        "continue": "-||"
    },
    "query": {
        "allimages": [
            {
                "name": "Graffiti_0001.JPG",
                "timestamp": "2006-10-26T01:48:05Z",
                "url": "https://upload.wikimedia.org/wikipedia/en/9/98/Graffiti_0001.JPG",
                "descriptionurl": "https://en.wikipedia.org/wiki/File:Graffiti_0001.JPG",
                "descriptionshorturl": "https://en.wikipedia.org/w/index.php?curid=7624737",
                "ns": 6,
                "title": "File:Graffiti 0001.JPG"
            },
            {
                "name": "Graffiti_0002.JPG",
                "timestamp": "2006-10-26T02:03:40Z",
                "url": "https://upload.wikimedia.org/wikipedia/en/6/66/Graffiti_0002.JPG",
                "descriptionurl": "https://en.wikipedia.org/wiki/File:Graffiti_0002.JPG",
                "descriptionshorturl": "https://en.wikipedia.org/w/index.php?curid=7624935",
                "ns": 6,
                "title": "File:Graffiti 0002.JPG"
            },
            {
                "name": "Graffiti_0003.JPG",
                "timestamp": "2006-10-26T08:05:08Z",
                "url": "https://upload.wikimedia.org/wikipedia/en/2/2b/Graffiti_0003.JPG",
                "descriptionurl": "https://en.wikipedia.org/wiki/File:Graffiti_0003.JPG",
                "descriptionshorturl": "https://en.wikipedia.org/w/index.php?curid=7628426",
                "ns": 6,
                "title": "File:Graffiti 0003.JPG"
            }
        ]
    }
}

<translate>

Sample code[edit]

</translate> get_allimages_by_name.py

#!/usr/bin/python3

"""
    get_allimages_by_name.py

    MediaWiki Action API Code Samples
    Demo of `Allimages` module: List all images in the namespace, 
    starting from files that begin with "I". Limit the initial
    response to just the first three images. 
    MIT license
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action":"query",
    "format":"json",
    "list": "allimages",
    "aifrom": "I",
    "ailimit": "3"
}

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

print(DATA)

<translate>

Example 2: Get images by date[edit]

GET Request[edit]

</translate> <translate> List all images in the namespace, starting from 2010-01-01 18:05:46 (UTC).</translate>

<translate>

Response[edit]

</translate>

{
    "batchcomplete": "",
    "continue": {
        "aicontinue": "20100101190633|Ryan_Baker_12-30-2009.JPG",
        "continue": "-||"
    },
    "query": {
        "allimages": [
            {
                "name": "DramaQueenThatGirl.jpg",
                "timestamp": "2010-01-01T18:21:57Z",
                "url": "https://upload.wikimedia.org/wikipedia/en/1/17/DramaQueenThatGirl.jpg",
                "descriptionurl": "https://en.wikipedia.org/wiki/File:DramaQueenThatGirl.jpg",
                "descriptionshorturl": "https://en.wikipedia.org/w/index.php?curid=25646192",
                "ns": 6,
                "title": "File:DramaQueenThatGirl.jpg"
            },
            {
                "name": "VS_in_viena_austria.JPG",
                "timestamp": "2010-01-01T18:42:49Z",
                "url": "https://upload.wikimedia.org/wikipedia/en/b/bd/VS_in_viena_austria.JPG",
                "descriptionurl": "https://en.wikipedia.org/wiki/File:VS_in_viena_austria.JPG",
                "descriptionshorturl": "https://en.wikipedia.org/w/index.php?curid=25646382",
                "ns": 6,
                "title": "File:VS in viena austria.JPG"
            },
            {
                "name": "Vasanthamtv_channel.jpg",
                "timestamp": "2010-01-01T19:03:08Z",
                "url": "https://upload.wikimedia.org/wikipedia/en/1/18/Vasanthamtv_channel.jpg",
                "descriptionurl": "https://en.wikipedia.org/wiki/File:Vasanthamtv_channel.jpg",
                "descriptionshorturl": "https://en.wikipedia.org/w/index.php?curid=25626466",
                "ns": 6,
                "title": "File:Vasanthamtv channel.jpg"
            }
            ...
        ]
    }
}

<translate>

Sample code[edit]

</translate> get_allimages_by_timestamp.py

#!/usr/bin/python3

"""
    get_allimages_by_timestamp.py

    MediaWiki Action API Code Samples
    Demo of `Allimages` module: Get a list of all images
    in the namespace, starting from 2010-01-01T18:05:46. 
    MIT license
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action":"query",
    "format":"json",
    "list": "allimages",
    "aisort": "timestamp",
    "aistart": "2010-01-01T18:05:46Z"
}

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

print(DATA)

<translate>

Parameter history[edit]

</translate>

  • v1.23: Introduced aiprop=canonicaltitle, aiprop=commonmetadata, aiprop=extmetadata
  • v1.20: Introduced aisort, aistart, aiend, aiuser, aifilterbots, aidir=newer, aidir=older
  • v1.18: Introduced aimime, aiprop=mediatype
  • v1.17: Introduced aiprop=userid, aiprop=parsedcomment
  • v1.14: Introduced bitdepth

<translate>

Additional notes[edit]

  • Only the most recent version of each file is returned.</translate>

<translate>

  • See {{<tvar|1>ll|API:Data formats#Timestamps</>|Data formats}} for more information on how to properly format dates for <tvar|2>aisort=timestamps</>

See also[edit]

</translate>

  • API:Images - <translate> a very similar module, but it is a <tvar|1>prop</>, not a <tvar|2>list</>; see <tvar|3>API:Properties </> and <tvar|4>API:Lists </> for more details on how these two kinds of modules differ from one another.</translate>
  • API:Imageinfo - <translate> retrieves detailed information about image files.</translate>
  • API:Stashimageinfo - <translate> retrieves information about {{<tvar|1>ll|Manual:UploadStash</>|stashed}} images</translate>
  • API:Fileusage - <translate> find all pages that use the given image or images</translate>
  • API:Duplicatefiles - <translate> find any duplicates of the given file or files</translate>

Alllinks[edit]

Returns a list of (unique) links to pages in a given namespace starting ordered by link title.

Parameters[edit]

  • alcontinue: When more results are available, use this to continue.
  • alfrom: The title of the link to start enumerating from.
  • alto: The title of the link to stop enumerating at.
  • alprefix: Search for all linked titles that begin with this value.
  • alunique: Only show distinct linked titles. Cannot be used with alprop=ids. When used as a generator, yields target pages instead of source pages. Before MW 1.21 (gerrit:40559) it couldn't be used in generator mode.
  • alprop: Which pieces of information to include: (Default: title)
    • ids: Page IDs of the linking pages. Cannot be used together with alunique.
    • title: Link titles
  • alnamespace: The namespace to enumerate. You can only enumerate one namespace at a time. (Default: 0)
  • allimit: How many total items to return. No more than 500 (5000 for bots) allowed. (Default: 10)
  • aldir: The direction in which to list. Possible values: ascending, descending (Default: ascending)

Example[edit]

List all links to talk pages whose name starts with Talk:API

Error Codes[edit]

Code Info
alparams alllinks cannot be used as a generator in unique links mode
alparams alllinks cannot return corresponding page ids in unique links mode
Note: This happens when you use alunique and alprop=ids together
alparams alcontinue and alfrom cannot be used together




(main | query | alllinks)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Enumerate all links that point to a given namespace.

Parameters:
alcontinue

When more results are available, use this to continue.

alfrom

The title of the link to start enumerating from.

alto

The title of the link to stop enumerating at.

alprefix

Search for all linked titles that begin with this value.

alunique

Only show distinct linked titles. Cannot be used with alprop=ids.

When used as a generator, yields target pages instead of source pages.

Type: boolean (details)
alprop

Which pieces of information to include:

ids
Adds the page ID of the linking page (cannot be used with alunique).
title
Adds the title of the link.
Values (separate with | or alternative): ids, title
Default: title
alnamespace

The namespace to enumerate.

One of the following values: -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
Default: 0
allimit

How many total items to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
aldir

The direction in which to list.

One of the following values: ascending, descending
Default: ascending
Examples:
List linked titles, including missing ones, with page IDs they are from, starting at B.
api.php?action=query&list=alllinks&alfrom=B&alprop=ids|title [open in sandbox]
List unique linked titles.
api.php?action=query&list=alllinks&alunique=&alfrom=B [open in sandbox]
Gets all linked titles, marking the missing ones.
api.php?action=query&generator=alllinks&galunique=&galfrom=B [open in sandbox]
Gets pages containing the links.
api.php?action=query&generator=alllinks&galfrom=B [open in sandbox]

Allpages[edit]

MediaWiki version: 1.18

<translate> GET Request to list all pages fitting certain criteria, within a given <tvar|1>Namespace </>.

This module can be used as a {{<tvar|1>ll|API:Query#Generators</>|generator}}.

API documentation[edit]

</translate>




list=allpages (ap)

(main | query | allpages)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Enumerate all pages sequentially in a given namespace.

Parameters:
apfrom

The page title to start enumerating from.

apcontinue

When more results are available, use this to continue.

apto

The page title to stop enumerating at.

apprefix

Search for all page titles that begin with this value.

apnamespace

The namespace to enumerate.

One of the following values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
Default: 0
apfilterredir

Which pages to list.

Note: Due to miser mode, using this may result in fewer than aplimit results returned before continuing; in extreme cases, zero results may be returned.

One of the following values: all, redirects, nonredirects
Default: all
apminsize

Limit to pages with at least this many bytes.

Type: integer
apmaxsize

Limit to pages with at most this many bytes.

Type: integer
apprtype

Limit to protected pages only.

Values (separate with | or alternative): edit, move, upload
apprlevel

Filter protections based on protection level (must be used with apprtype= parameter).

Values (separate with | or alternative): Can be empty, or autoconfirmed, sysop
apprfiltercascade

Filter protections based on cascadingness (ignored when apprtype isn't set).

One of the following values: cascading, noncascading, all
Default: all
aplimit

How many total pages to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
apdir

The direction in which to list.

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

Filter based on whether a page has langlinks. Note that this may not consider langlinks added by extensions.

One of the following values: withlanglinks, withoutlanglinks, all
Default: all
apprexpiry

Which protection expiry to filter the page on:

indefinite
Get only pages with indefinite protection expiry.
definite
Get only pages with a definite (specific) protection expiry.
all
Get pages with any protections expiry.
One of the following values: indefinite, definite, all
Default: all

<translate>

Example[edit]

GET Request[edit]

Get all pages whose title contains the text "Jungle," in whole or part. </translate>

<translate>

Response[edit]

</translate>

<translate> Items in the results are listed in alphabetical order, by page title.</translate>
{
    "batchcomplete": "",
    "continue": {
        "apcontinue": "Jungle_(Bakufu_Slump_album)",
        "continue": "-||"
    },
    "query": {
        "allpages": [
            {
                "pageid": 341265,
                "ns": 0,
                "title": "Jungle"
            },
            {
                "pageid": 56461312,
                "ns": 0,
                "title": "Jungle-runner"
            },
            {
                "pageid": 18698572,
                "ns": 0,
                "title": "Jungle/Drum n bass"
            },
            {
                "pageid": 1487899,
                "ns": 0,
                "title": "Jungle2jungle"
            },
            {
                "pageid": 30391179,
                "ns": 0,
                "title": "JunglePup"
            }
            ...
        ]
    }
}

<translate>

Sample code[edit]

</translate> get_allpages.py

#!/usr/bin/python3

"""
    get_allpages.py

    MediaWiki Action API Code Samples
    Demo of `Allpages` module: Get all pages whose title contains
    the text "Jungle," in whole or part.

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "query",
    "format": "json",
    "list": "allpages",
    "apfrom": "jungle"
}

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

print(DATA)

<translate>

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
invalidparammix The prlevel parameter may only be used with prtype.

<translate>

See also[edit]

</translate>

Alltransclusions[edit]

List all transclusions (pages embedded using {{x}}), including non-existing.

This module is part of API:Alllinks.

Added in gerrit:40559.

Parameters[edit]

  • atcontinue: When more results are available, use this to continue.
  • atfrom: The title of the transclusion to start enumerating from.
  • atto: The title of the transclusion to stop enumerating at.
  • atprefix: Search for all transclusion titles that begin with this value.
  • atunique: Only show distinct transclusion titles. Cannot be used with atprop=ids. When used as a generator, yields target pages instead of source pages.
  • atprop: What pieces of information to include. (Default: title)
    • title: Adds the title of the transclusion
    • ids: Adds the pageid of the transcluding page. (Cannot be used with atunique).
  • atnamespace: The namespace number to enumerate. (Default: 10 (the Template: namespace))
  • atlimit: How many total items to return. (Default: 10)
  • atdir: The direction in which to list (Default: ascending)
    • ascending: List from A to Z.
    • descending: List from Z to A.

Example[edit]

To count the number of pages which transclude a template, to decide to protect it above a certain number.

List all links to talk pages whose name starts with Talk:API

Allusers[edit]

MediaWiki version: 1.11

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

API documentation[edit]

</translate>




list=allusers (au)

(main | query | allusers)

Enumerate all registered users.

Parameters:
aufrom

The user name to start enumerating from.

auto

The user name 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.

Values (separate with | or alternative): bot, sysop, interface-admin, bureaucrat, steward, accountcreator, import, transwiki, ipblock-exempt, oversight, autopatrolled, checkuser, translationadmin, confirmed, flow-bot
auexcludegroup

Exclude users in the given groups.

Values (separate with | or alternative): bot, sysop, interface-admin, bureaucrat, steward, accountcreator, import, transwiki, ipblock-exempt, oversight, autopatrolled, checkuser, translationadmin, confirmed, flow-bot
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): apihighlimits, applychangetags, autoconfirmed, autocreateaccount, autopatrol, bigdelete, block, blockemail, bot, browsearchive, changetags, createaccount, createpage, createtalk, delete, deletechangetags, deletedhistory, deletedtext, deletelogentry, deleterevision, edit, editcontentmodel, editinterface, editprotected, editmyoptions, editmyprivateinfo, editmyusercss, editmyuserjson, editmyuserjs, editmyuserjsredirect, editmywatchlist, editsemiprotected, editsitecss, editsitejson, editsitejs, editusercss, edituserjson, edituserjs, hideuser, import, importupload, ipblock-exempt, managechangetags, markbotedits, mergehistory, minoredit, move, movefile, move-categorypages, move-rootuserpages, move-subpages, nominornewtalk, noratelimit, override-export-depth, pagelang, patrol, patrolmarks, protect, purge, read, reupload, reupload-own, reupload-shared, rollback, sendemail, siteadmin, suppressionlog, suppressredirect, suppressrevision, unblockself, undelete, unwatchedpages, upload, upload_by_url, userrights, userrights-interwiki, viewmyprivateinfo, viewmywatchlist, viewsuppressed, writeapi, spamblacklistlog, tboverride, tboverride-account, titleblacklistlog, gadgets-edit, gadgets-definition-edit, transcode-reset, transcode-status, globalblock, globalblock-whitelist, globalblock-exempt, securepoll-create-poll, renameuser, nuke, torunblocked, skipcaptcha, override-antispoof, centralauth-merge, centralauth-unmerge, centralauth-lock, centralauth-oversight, globalgrouppermissions, globalgroupmembership, centralauth-rename, centralauth-usermerge, repoadmin, codereview-use, codereview-add-tag, codereview-remove-tag, codereview-post-comment, codereview-set-status, codereview-signoff, codereview-associate, codereview-link-user, codereview-review-own, abusefilter-modify, abusefilter-log-detail, abusefilter-view, abusefilter-log, abusefilter-private, abusefilter-private-log, abusefilter-modify-restricted, abusefilter-revert, abusefilter-view-private, abusefilter-log-private, abusefilter-hidden-log, abusefilter-hide-log, abusefilter-modify-global, lqt-split, lqt-merge, lqt-react, massmessage, translate, translate-import, translate-manage, translate-messagereview, translate-groupreview, vipsscaler-test, flow-hide, flow-lock, flow-delete, flow-suppress, flow-edit-post, flow-create-board, usermerge, mwoauthproposeconsumer, mwoauthupdateownconsumer, mwoauthmanageconsumer, mwoauthsuppress, mwoauthviewsuppressed, mwoauthviewprivate, mwoauthmanagemygrants, oathauth-enable, oathauth-api-all, oathauth-disable-for-user, newsletter-create, newsletter-delete, newsletter-manage, newsletter-restore, checkuser, checkuser-log, autoreviewrestore, stablesettings, review, unreviewedpages, movestable, validate, templateeditor, editeditorprotected, editextendedsemiprotected, extendedconfirmed, viewdeletedfile, collectionsaveasuserpage, collectionsaveascommunitypage, pagetranslation
Maximum number of values is 50 (500 for bots).
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, groups, implicitgroups, rights, editcount, registration, centralids
aulimit

How many total user names to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
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.

<translate>

Example[edit]

GET Request[edit]

</translate> <translate> GET request to list all users, starting from those whose name begins with the string, "<tvar

<translate>

Response[edit]

</translate>

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

<translate>

Sample code[edit]

</translate> 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)

<translate>

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
augroup-excludegroup <translate> group and excludegroup cannot be used together</translate>

<translate>

Parameter history[edit]

</translate>

  • v1.12: Introduced auprop=registration

<translate>

Additional notes[edit]

  • This API call is case sensitive, so <tvar|1>aufrom=DROV</> doesn't return the same results as <tvar|2>aufrom=Drov</>.</translate>

<translate>

  • All registered usernames are saved and retrieved in capitalized form.</translate> <translate> If you are using <tvar|1>aufrom</> or <tvar|2>auprefix</> in your query, make sure you are passing them values that start with an uppercase character.</translate>

<translate>

  • 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.</translate> <translate>

User groups are how MediaWiki grants users certain rights and privileges; see <tvar|1>Help:User rights and groups </> for more details on how this system works.

See also[edit]

</translate>

  • API:Users - <translate> finds information about a list of users.</translate>

Backlinks[edit]

MediaWiki version: 1.9

<translate> Get request to list pages which link to a certain page.

API documentation[edit]

</translate>




(main | query | backlinks)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Find all pages that link to the given page.

Parameters:
bltitle

Title to search. Cannot be used together with blpageid.

blpageid

Page ID to search. Cannot be used together with bltitle.

Type: integer
blcontinue

When more results are available, use this to continue.

blnamespace

The namespace to enumerate.

Values (separate with | or alternative): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
To specify all values, use *.
bldir

The direction in which to list.

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

How to filter for redirects. If set to nonredirects when blredirect is enabled, this is only applied to the second level.

One of the following values: all, redirects, nonredirects
Default: all
bllimit

How many total pages to return. If blredirect is enabled, the limit applies to each level separately (which means up to 2 * bllimit results may be returned).

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
blredirect

If linking page is a redirect, find all pages that link to that redirect as well. Maximum limit is halved.

Type: boolean (details)

<translate>

Example[edit]

GET Request[edit]

</translate> <translate> List backlinks to the philosophy page.</translate>

<translate>

Response[edit]

</translate>

{
    "batchcomplete": "",
    "continue": {
        "blcontinue": "1|987",
        "continue": "-||"
    },
    "query": {
        "backlinks": [
            {
                "pageid": 12,
                "ns": 0,
                "title": "Anarchism"
            },
            {
                "pageid": 128,
                "ns": 1,
                "title": "Talk:Atlas Shrugged"
            },
            {
                "pageid": 336,
                "ns": 0,
                "title": "Altruism"
            },
            ...
        ]
    }
}

<translate>

Sample code[edit]

</translate> get_backlinks.py

#!/usr/bin/python3

"""
    get_backlinks.py

    MediaWiki Action API Code Samples
    Demo of `API:Backlinks` module: Get request to list pages which
    link to a certain page.
    MIT license
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action":"query",
    "format":"json",
    "list":"backlinks",
    "bltitle":"philosophy"
}

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

print(DATA)

<translate>

Redirects[edit]

In the example above, only direct links to the philosophy page are returned.</translate> <translate> When <tvar|1>blredirect</> is set, the response will include any pages which backlink to redirects for the value in <tvar|2>bltitle</>.

These redirected backlinks are treated as separate groups within the response hierarchy, one level down from the redirect itself.

The limit set in <tvar|1>bllimit</> applies separately to each level of the response, so <tvar|2>bllimit=25</> would return up to 25 direct backlinks, and up to 25 backlinks within each individual redirect.

In addition, using <tvar|1>blcontinue</> when a redirect was in the response will return more second-level backlinks, before finally moving on to more direct backlinks, once all the backlinks for a redirect have been returned in full.

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
blbadcontinue Invalid continue param. You should pass the original value returned by the previous query.

<translate>

See also[edit]

</translate>

  • API:Linkshere - <translate> finds all pages that link to a given page.</translate> <translate> Note that, unlike <tvar|1>API:Backlinks</>, which is a <tvar|2>list </> module, <tvar|3>API:Linkshere</> is a <tvar|4>prop </> module.</translate> <translate> See the respective pages on <tvar|1>API:Properties </> and <tvar|2>API:Lists </> for how these two kinds of modules differ.</translate>
  • API:Transcludedin - <translate> a <tvar|1>prop</> module that finds all pages that transclude (i.e. embed information from) the given pages.</translate>
  • API:Embeddedin - <translate> a <tvar|1>list</> module which lists backlinks via transclusion, similar to <tvar|2>Special:Whatlinkshere</>.</translate>
  • API:Imageusage - <translate> lists pages that use the given image(s).</translate>
  • API:Fileusage - <translate> lists pages that use the given file(s).</translate>

Blocks[edit]

List all blocks, à la Special:Ipblocklist. This module cannot be used as a generator.

Parameters[edit]

  • bkstart: The timestamp to start listing from
  • bkend: The timestamp to end listing at
  • bkdir: Direction to list in. (Default: older)
    • older: List newest blocks first. Note: bkstart has to be later than bkend.
    • newer: List oldest blocks first. Note: bkstart has to be before bkend.
  • bkids: Only list blocks with these IDs
  • bkusers: Only list blocks of these user names
  • bkip: List all blocks, including range blocks, that apply to this IP address. You can also specify a CIDR range here, in which case only blocks applying to the entire range will be listed. Cannot be used together with bkusers. CIDR ranges broader than /16 are not allowed, as range blocks cannot cross /16 boundaries
  • bklimit: Maximum number of blocks to list (Default: 10)
  • bkprop: A pipe-separated list of properties to get. They appear as keys of returned dictionary. (Default: id|user|by|timestamp|expiry|reason|flags)
    • id: The ID of the block
    • user: The IP address or username that was blocked (does not appear in output for autoblocks)
    • userid: The id of user who was blocked (does not appear in output for autoblocks) 1.18+
    • by: The user who applied the block
    • byid: The id of user who applied the block
    • timestamp: When the block was applied
    • expiry: When the block will expire
    • reason: The reason for the block
    • range: If an IP range was blocked, the first and last IP the block applies to
      Will appear as rangestart and rangeend in the answer, both 0.0.0.0 for registered users. Same as user for standalone IPs.
    • flags: Flags that apply to the block
      The appropriate flags will appear as keys of returned dictionary with an empty value. No key if the flag is not valid for the block.
      • automatic: Automatically blocked because of an autoblock (see also action=block)
      • anononly: Only anonymous edits are blocked
      • nocreate: Account creation is disabled
      • autoblock: Automatic blocking is enabled for this block
      • noemail: Sending e-mail through the wiki is disabled for the blocked user
      • allowusertalk: The user is allowed to edit his/her own talk page
      • hidden: This block is hidden from Special:Ipblocklist. Only users with oversight permissions can see these blocks.
  • bkshow: Show only items that meet these criteria. Conflicting options, like account|ip, are allowed, but won't return any results. 1.19+
    • account: Only show account blocks.
    • !account: Show everything except account blocks.
    • temp: Only show temporary blocks.
    • !temp: Show everything except temporary blocks.
    • ip: Only show single IP blocks.
    • !ip: Show everything except single IP blocks.
    • range: Only show range blocks.
    • !range: Show everything except range blocks.

Example[edit]

Listing the 3 most recent blocks

Error Codes[edit]

None.

See also[edit]




list=blocks (bk)

(main | query | blocks)

List all blocked users and IP addresses.

Parameters:
bkstart

The timestamp to start enumerating from.

Type: timestamp (allowed formats)
bkend

The timestamp to stop enumerating at.

Type: timestamp (allowed formats)
bkdir

In which direction to enumerate:

newer
List oldest first. Note: bkstart has to be before bkend.
older
List newest first (default). Note: bkstart has to be later than bkend.
One of the following values: newer, older
Default: older
bkids

List of block IDs to list (optional).

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

List of users to search for (optional).

Type: list of user names
Separate values with | or alternative. Maximum number of values is 50 (500 for bots).
bkip

Get all blocks applying to this IP address or CIDR range, including range blocks.

Cannot be used together with bkusers. CIDR ranges broader than IPv4/16 or IPv6/19 are not accepted.

bklimit

The maximum number of blocks to list.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
bkprop

Which properties to get:

id
Adds the ID of the block.
user
Adds the username of the blocked user.
userid
Adds the user ID of the blocked user.
by
Adds the username of the blocking user.
byid
Adds the user ID of the blocking user.
timestamp
Adds the timestamp of when the block was given.
expiry
Adds the timestamp of when the block expires.
reason
Adds the reason given for the block.
range
Adds the range of IP addresses affected by the block.
flags
Tags the ban with (autoblock, anononly, etc.).
restrictions
Adds the partial block restrictions if the block is not sitewide.
Values (separate with | or alternative): id, user, userid, by, byid, timestamp, expiry, reason, range, flags, restrictions
Default: id|user|by|timestamp|expiry|reason|flags
bkshow

Show only items that meet these criteria.

For example, to see only indefinite blocks on IP addresses, set bkshow=ip|!temp.

Values (separate with | or alternative): account, !account, temp, !temp, ip, !ip, range, !range
bkcontinue

When more results are available, use this to continue.

Categorymembers[edit]

MediaWiki version: 1.11

<translate> GET Request to list pages that belong to a given category.

API documentation[edit]

</translate>




list=categorymembers (cm)

(main | query | categorymembers)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

List all pages in a given category.

Parameters:
cmtitle

Which category to enumerate (required). Must include the Category: prefix. Cannot be used together with cmpageid.

cmpageid

Page ID of the category to enumerate. Cannot be used together with cmtitle.

Type: integer
cmprop

Which pieces of information to include:

ids
Adds the page ID.
title
Adds the title and namespace ID of the page.
sortkey
Adds the sortkey used for sorting in the category (hexadecimal string).
sortkeyprefix
Adds the sortkey prefix used for sorting in the category (human-readable part of the sortkey).
type
Adds the type that the page has been categorised as (page, subcat or file).
timestamp
Adds the timestamp of when the page was included.
Values (separate with | or alternative): ids, title, sortkey, sortkeyprefix, type, timestamp
Default: ids|title
cmnamespace

Only include pages in these namespaces. Note that cmtype=subcat or cmtype=file may be used instead of cmnamespace=14 or 6.

Note: Due to miser mode, using this may result in fewer than cmlimit results returned before continuing; in extreme cases, zero results may be returned.

Values (separate with | or alternative): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
To specify all values, use *.
cmtype

Which type of category members to include. Ignored when cmsort=timestamp is set.

Values (separate with | or alternative): page, subcat, file
Default: page|subcat|file
cmcontinue

When more results are available, use this to continue.

cmlimit

The maximum number of pages to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
cmsort

Property to sort by.

One of the following values: sortkey, timestamp
Default: sortkey
cmdir

In which direction to sort.

One of the following values: asc, desc, ascending, descending, newer, older
Default: ascending
cmstart

Timestamp to start listing from. Can only be used with cmsort=timestamp.

Type: timestamp (allowed formats)
cmend

Timestamp to end listing at. Can only be used with cmsort=timestamp.

Type: timestamp (allowed formats)
cmstarthexsortkey

Sortkey to start listing from, as returned by cmprop=sortkey. Can only be used with cmsort=sortkey.

cmendhexsortkey

Sortkey to end listing at, as returned by cmprop=sortkey. Can only be used with cmsort=sortkey.

cmstartsortkeyprefix

Sortkey prefix to start listing from. Can only be used with cmsort=sortkey. Overrides cmstarthexsortkey.

cmendsortkeyprefix

Sortkey prefix to end listing before (not at; if this value occurs it will not be included!). Can only be used with cmsort=sortkey. Overrides cmendhexsortkey.

cmstartsortkey
Deprecated.

Use cmstarthexsortkey instead.

cmendsortkey
Deprecated.

Use cmendhexsortkey instead.

<translate>

Examples[edit]

Example 1: List twenty pages in a category[edit]

GET request[edit]

</translate>

<translate>

Response[edit]

</translate>

{
	"api": {
		"query-continue": {
			"categorymembers": {
				"_cmcontinue": "subcat|44594e414d494353|10998823"
			}
		},
		"query": {
			"categorymembers": {
				"cm": [
					{
						"_pageid": "22688097",
						"_ns": "0",
						"_title": "Branches of physics"
					},
					{
						"_pageid": "3445246",
						"_ns": "0",
						"_title": "Glossary of classical physics"
					},
					{
						"_pageid": "24489",
						"_ns": "0",
						"_title": "Outline of physics"
					},
					...
				]
			}
		}
	}
}

<translate>

Sample code[edit]

</translate> get_category_items.py

#!/usr/bin/python3

"""

	get_category_items.py
	

    MediaWiki Action API Code Samples
    Demo of `Categorymembers` module : List twenty items in a category.
    MIT license
"""

import requests

S = requests.Session()

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

PARAMS = {
    'action': "query",
    'list': "categorymembers",
    'cmtitle': "Category:Physics",
    'cmlimit': 20,
    'format': "json"
}

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

print(DATA)

<translate>

Example 2: Get the ten articles most recently added to a category[edit]

GET Request[edit]

</translate>

<translate>

Response[edit]

</translate>

<translate>

Sample code[edit]

</translate>

<translate>

Example 3: Get ten subcategories of a category[edit]

GET request[edit]

</translate>

<translate>

Response[edit]

</translate>

<translate> The next subcategories (if there're more than 10) can be continued using the <tvar|1>cmcontinue</> parameter from the response above.

Sample code[edit]

</translate>

<translate>

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
cmnotitle The parameter cmtitle is required.
cminvalidcategory The category name you entered is not valid.
cmbadcontinue Invalid continue param. You should pass the original value returned by the previous query.

<translate>

Parameter history[edit]

</translate>

  • v1.24: Deprecated cmstartsortkey,cmendsortkey
  • v1.18: Introduced cmstartsortkeyprefix,cmendsortkeyprefix
  • v1.17: Introduced sortkeyprefix,type
  • v1.14: Introduced cmstartsortkey,cmendsortkey
  • v1.12: Introduced cmtype,cmstart,cmend,cmdir

deletedrevs[edit]

NOTE: This module's behavior was changed significantly in MediaWiki 1.15. Some of the features described here are not available in MediaWiki 1.14 and earlier.

List deleted revisions. You need the deletedhistory right to use this module. This module cannot be used as a generator. This module can be used in one of three modes:

  1. List deleted revisions for the given titles (through titles or a generator), sorted by timestamp
  2. List deleted contributions for a certain user, sorted by timestamp (druser set, no titles given)
  3. List all deleted revisions in a certain namespace (druser not set, no titles given)

Some parameters are restricted to certain modes only, and are marked accordingly.

Parameters[edit]

  • drlimit: Maximum number of revisions to list No more than 500 (5000 for bots) allowed. (Default: 10)
  • druser: Only list revisions by this user 1.15+
  • drexcludeuser: Don't list revisions by this user 1.15+
  • drstart: The timestamp to start listing from. If not specified, all revisions earlier than drend will be listed.[1]
  • drend: The timestamp to end listing at. If not specified, all revisions later than drstart will be listed.[1]
  • drdir: Direction to list in.[1] (Default: older)
    • older: List newest revisions first. Note: drstart has to be later than drend.
    • newer: List oldest revisions first. Note: drstart has to be earlier than drend.
  • drnamespace: List all deleted revisions in this namespace.[2] (Note that namespace was included in the original 1.12 as a pipe-separated list of values, but was removed in 1.13. In 1.15, it was reintroduced as a single-valued parameter.) 1.15+
  • drunique: List only one revision for each page[2] 1.15+
  • drfrom: Start listing at this title[2] 1.15+
  • drto: Stop listing at this title[2] 1.18+
  • drprefix: Search for all page titles that begin with this value[2] 1.18+
  • drcontinue: When more results are available, use this to continue. Note: prior to MW 1.23, drstart was used as a continue in mode 2 rather than drcontinue.
  • drprop: Which properties to get (Default: user|comment)
    • revid: Revision ID
    • parentid: Revision ID of the previous revision to the page 1.18+
    • user: User who made the revision
    • userid: User ID who made the revision 1.17+
    • comment: Edit comment
    • parsedcomment: Parsed comment of the revision 1.16+
    • minor: Whether the revision was minor
    • len: Revision size
    • content: Revision content. You need the undelete or deletedtext right to use this option
    • token: Undelete token (deprecated in 1.24)
    • sha1: SHA-1 (base 16) of the revision 1.19+
    • tags: Tags for the revision 1.23+
  • drtag: Only list revisions tagged with this tag 1.23+
  1. 1.0 1.1 1.2 Modes 1 and 2 only
  2. 2.0 2.1 2.2 2.3 2.4 Mode 3 only

Examples[edit]

Listing the 6 most recent deleted revisions from user Catrope dated September 4, 2007 (mode 2).

Error Codes[edit]

Code Info
drpermissiondenied You don't have permission to view deleted revision information. On most wikis, viewing deleted revisions is restricted to sysops, but other wikis may have different rules.
drpermissiondenied You don't have permission to view deleted revision content.




list=deletedrevs (dr)

(main | query | deletedrevs)
  • This module is deprecated.
  • This module requires read rights.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

List deleted revisions.

Operates in three modes:

  1. List deleted revisions for the given titles, sorted by timestamp.
  2. List deleted contributions for the given user, sorted by timestamp (no titles specified).
  3. List all deleted revisions in the given namespace, sorted by title and timestamp (no titles specified, druser not set).

Certain parameters only apply to some modes and are ignored in others.

Parameters:
drstart

The timestamp to start enumerating from.

Modes: 1, 2
Type: timestamp (allowed formats)
drend

The timestamp to stop enumerating at.

Modes: 1, 2
Type: timestamp (allowed formats)
drdir

In which direction to enumerate:

newer
List oldest first. Note: drstart has to be before drend.
older
List newest first (default). Note: drstart has to be later than drend.
Modes: 1, 3
One of the following values: newer, older
Default: older
drfrom

Start listing at this title.

Mode: 3
drto

Stop listing at this title.

Mode: 3
drprefix

Search for all page titles that begin with this value.

Mode: 3
drunique

List only one revision for each page.

Mode: 3
Type: boolean (details)
drnamespace

Only list pages in this namespace.

Mode: 3
One of the following values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
Default: 0
drtag

Only list revisions tagged with this tag.

druser

Only list revisions by this user.

Type: user name
drexcludeuser

Don't list revisions by this user.

Type: user name
drprop

Which properties to get:

revid
Adds the revision ID of the deleted revision.
parentid
Adds the revision ID of the previous revision to the page.
user
Adds the user who made the revision.
userid
Adds the ID of the user who made the revision.
comment
Adds the comment of the revision.
parsedcomment
Adds the parsed comment of the revision.
minor
Tags if the revision is minor.
len
Adds the length (bytes) of the revision.
sha1
Adds the SHA-1 (base 16) of the revision.
content
Adds the content of the revision.
token
Deprecated. Gives the edit token.
tags
Tags for the revision.
Values (separate with | or alternative): revid, parentid, user, userid, comment, parsedcomment, minor, len, sha1, content, token, tags
Default: user|comment
drlimit

The maximum amount of revisions to list.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
drcontinue

When more results are available, use this to continue.

Examples:
List the last deleted revisions of the pages Main Page and Talk:Main Page, with content (mode 1).
api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content [open in sandbox]
List the last 50 deleted contributions by Bob (mode 2).
api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50 [open in sandbox]
List the first 50 deleted revisions in the main namespace (mode 3).
api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50 [open in sandbox]
List the first 50 deleted pages in the Talk namespace (mode 3).
api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique= [open in sandbox]

Embeddedin[edit]

<translate> List pages that transclude a certain page.

Parameters[edit]

</translate>

  • eititle: <translate> List pages including this title.</translate> <translate> The title need not exist</translate>
  • einamespace: <translate> Only list pages in these namespaces</translate>
  • eifilterredir: <translate> How to filter redirects</translate> (Default: all)
    • all: <translate> List all pages regardless of their redirect flag</translate>
    • redirects: <translate> Only list redirects</translate>
    • nonredirects: <translate> Don't list redirects</translate>
  • eilimit: <translate> Maximum amount of pages to list.</translate> No more than 500 (5000 for bots) allowed. (Default: 10)
  • eicontinue: <translate> Used to continue a previous request</translate>

<translate>

Example[edit]

</translate> <translate> Find all pages that embed w:Template:Stub.</translate>

<translate>

Error Codes[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
eibadcontinue Invalid continue param. You should pass the original value returned by the previous query.





list=embeddedin (ei)

(main | query | embeddedin)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Find all pages that embed (transclude) the given title.

Parameters:
eititle

Title to search. Cannot be used together with eipageid.

eipageid

Page ID to search. Cannot be used together with eititle.

Type: integer
eicontinue

When more results are available, use this to continue.

einamespace

The namespace to enumerate.

Values (separate with | or alternative): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
To specify all values, use *.
eidir

The direction in which to list.

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

How to filter for redirects.

One of the following values: all, redirects, nonredirects
Default: all
eilimit

How many total pages to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10

Exturlusage[edit]

<translate> Get a list of pages that link to a certain URL, à la Special:Linksearch

Parameters[edit]

</translate>

  • euprop: <translate> Which properties to get.</translate> (Default: ids|title|url)
    • ids: <translate> Page ID of the linking page.</translate>
    • title: <translate> Title of the linking page.</translate>
    • url: <translate> URL being linked to.</translate>
  • eucontinue: <translate> Used for continuing a previous request.</translate>
  • euprotocol: 1>$wgUrlProtocols </>.</translate> Possible values: <translate> listed in <tvar (Default: <translate> <tvar)
  • euquery: 1>*</> can be used as a wildcard.</translate> <translate> If omitted, all external links will be listed, filtered by <tvar
  • eunamespace: <translate> Only list links from pages in these namespaces.</translate>
  • eulimit: <translate> Maximum amount of pages to list.</translate> No more than 500 (5000 for bots) allowed. (Default: 10)
  • euexpandurl: <translate> Expand protocol-relative URLs with the canonical protocol.</translate> 1.21+

<translate>

Example[edit]

</translate> <translate> Get a list of pages linking to slashdot.org</translate>

Filearchive[edit]

<translate> Enumerate all deleted files sequentially

Parameters[edit]

</translate>

  • fafrom: <translate> The image title to start enumerating from.</translate>
  • facontinue: <translate> When more results are available, use this to continue.</translate> 1.20+
  • fato: <translate> The image title to stop enumerating at.</translate> 1.18+
  • faprefix: <translate> Search for all image titles that begin with this value.</translate>
  • fadir: <translate> The direction in which to list.</translate> Possible values: ascending, descending (Default: ascending)
  • falimit: <translate> How many images to return in total.</translate> No more than 500 (5000 for bots) allowed. (Default: 10)
  • fasha1: 1>fasha1base36</>.</translate> 1.18+
  • fasha1base36: <translate> SHA1 hash of image in base 36.</translate> (<translate> used in MediaWiki</translate>) 1.18+
  • faprop: <translate> What image information to get.</translate> (Default: timestamp)
    • sha1: <translate> Adds SHA-1 hash for the image.</translate>
    • timestamp: <translate> Adds timestamp for the uploaded version.</translate>
    • user: <translate> Adds user who uploaded the image version.</translate>
    • size: <translate> Adds the size of the image in bytes and the height, width and page count (if applicable).</translate>
    • dimensions: 1>size</>.</translate>
    • description: <translate> Adds description the image version.</translate>
    • parseddescription: <translate> Parse the description on the version.</translate> 1.18+
    • mime: <translate> Adds MIME of the image.</translate>
    • mediatype: <translate> Adds the media type of the image.</translate> 1.20+
    • metadata: <translate> Lists Exif metadata for the version of the image.</translate>
    • bitdepth: <translate> Adds the bit depth of the version.</translate>
    • archivename: <translate> Adds the file name of the archive version for non-latest versions.</translate> 1.20+

<translate>

Error Codes[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
invalidsha1hash The SHA1 hash provided is not valid.
invalidsha1base36hash The SHA1Base36 hash provided is not valid.

Imageusage[edit]

<translate> Find all pages that use the given image title. </translate>

<translate> In MW 1.9 and 1.10, the module name was imagelinks.</translate>

<translate>

Parameters[edit]

</translate>

  • iutitle: <translate> List pages linking to this title.</translate> <translate> The title does not need to exist.</translate>
  • iunamespace: <translate> Only list pages in these namespaces.</translate>
  • iufilterredir: <translate> How to filter redirects.</translate> (Default: all)
    • all: <translate> List all pages regardless of their redirect flag.</translate>
    • redirects: <translate> Only list redirects.</translate>
    • nonredirects: <translate> Don't list redirects.</translate>
  • iulimit: 1>iuredirect</> is set.</translate> No more than 500 (5000 for bots) allowed. (Default: 10)
  • iuredirect: 1>iutitle</> through a redirect will also be listed.</translate>
  • iucontinue: <translate> Used to continue a previous request.</translate>

<translate>

Errors Codes[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
iubadcontinue Invalid continue param. You should pass the original value returned by the previous query.

Iwbacklinks[edit]

<translate> Find all pages that link to the given interwiki link. Can be used to find all links with a prefix, or all links to a title (with a given prefix). Using neither parameter is effectively "All IW Links".

Parameters[edit]

</translate>

  • iwblprefix: <translate> Prefix for the interwiki.</translate> Type: string
  • iwbltitle: 1>iwblprefix</>.</translate> Type: string
  • iwblcontinue: <translate> When more results are available, use this to continue.</translate> Type: string
  • iwbllimit: <translate> How many total pages to return.</translate> No more than 500 (5000 for bots) allowed. Type: limit (Default: 10)
  • iwblprop: <translate> Which properties to get.</translate> Possible values: iwprefix, iwtitle (Default: none)
    • iwprefix: <translate> Adds the prefix of the interwiki.</translate>
    • iwtitle: <translate> Adds the title of the interwiki.</translate>
  • iwbldir: <translate> The direction in which to list.</translate> Possible values: ascending, descending (Default: ascending) 1.20+

<translate>

Error Codes[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
missingparam The prefix parameter must be set.

Langbacklinks[edit]

Find all pages that link to the given language link. Can be used to find all links with a language code, or all links to a title (with a given language). Using neither parameter is effectively "All Language Links".

Parameters[edit]

  • lbllang: Language for the language link. Type: string
  • lbltitle: Language link to search for. Must be used with lbllang Type: string
  • lblcontinue: When more results are available, use this to continue. Type: string
  • lbllimit: How many total pages to return. No more than 500 (5000 for bots) allowed. Type: limit (Default: 10)
  • lblprop: Which properties to get. (Default: none)
    • lllang: Adds the language code of the language link.
    • lltitle: Adds the title of the language link.
  • dir: The direction in which to list. Type: string 1.20+

Errors Codes[edit]

Code Info
missingparam The lang parameter must be set.

Logevents[edit]

Get a list of all logged events, à la Special:Log. This module cannot be used as a generator.

Parameters[edit]

  • leprop: Which properties to get. (Default: ids|title|type|user|timestamp|comment|details)
    • ids: Page ID of the page in question and log ID
    • title: Title of the page in question
    • type: Type of log entry
    • user: User responsible for the log entry
    • userid: The user ID who was responsible for the log event. When specified for account creation events, the userid of the creating user is returned. When absent, the userid returned is that of the created account (see bugzilla:71020).
    • timestamp: Time and date the log entry was created
    • comment: Log comment
    • parsedcomment: The parsed comment of the event
    • details: Extra information (not present for all log types)
    • tags: List tags for the event
  • letype: Only list log entries of this type. Note that extensions may add other log types.
    • block
    • delete
    • import
    • merge
    • move
    • newusers
    • patrol
    • protect
    • stable
    • rights
    • upload
  • leaction: Filter log actions to only this type. Overrides letype even if the action isn't related to letype. 1.17+
    • block/block
    • block/reblock
    • block/unblock
    • delete/delete
    • delete/event
    • delete/restore
    • delete/revision
    • import/interwiki
    • import/upload
    • merge/merge
    • move/move_redir
    • move/move
    • newusers/autocreate
    • newusers/create2
    • newusers/create
    • newusers/newusers
    • patrol/patrol
    • protect/modify
    • protect/move_prot
    • protect/protect
    • protect/unprotect
    • rights/autopromote
    • rights/erevoke
    • rights/rights
    • upload/overwrite
    • upload/revert
    • upload/upload
  • leuser: Only list log entries made by this user
  • letitle: Only list log entries related to this title
  • lestart: The timestamp to start listing from
  • leend: The timestamp to end listing at
  • ledir: Direction to list in. (Default: older)
    • older: List newest log entries first. Note: lestart has to be later than leend.
    • newer: List oldest log entries first. Note: lestart has to be earlier than leend.
  • lelimit: Maximum number of log entries to list No more than 500 (5000 for bots) allowed. (Default: 10)
  • leprefix: Filter entries that start with this prefix. Disabled in Miser Mode
  • letag: Only list event entries tagged with this tag

Example[edit]

List the 3 most recent page moves

List the 3 most recent uploads

Error Codes[edit]

Code Info
leparam_user User name username not found
leparam_title Bad title value 'title'
This happens when you set letitle to an invalid title.




list=logevents (le)

(main | query | logevents)

Get events from logs.

Parameters:
leprop

Which properties to get:

ids
Adds the ID of the log event.
title
Adds the title of the page for the log event.
type
Adds the type of log event.
user
Adds the user responsible for the log event.
userid
Adds the user ID who was responsible for the log event.
timestamp
Adds the timestamp for the log event.
comment
Adds the comment of the log event.
parsedcomment
Adds the parsed comment of the log event.
details
Lists additional details about the log event.
tags
Lists tags for the log event.
Values (separate with | or alternative): ids, title, type, user, userid, timestamp, comment, parsedcomment, details, tags
Default: ids|title|type|user|timestamp|comment|details
letype

Filter log entries to only this type.

One of the following values: Can be empty, or spamblacklist, titleblacklist, timedmediahandler, gblblock, renameuser, globalauth, gblrights, gblrename, abusefilter, abusefilterprivatedetails, liquidthreads, massmessage, translationreview, notifytranslators, thanks, usermerge, newsletter, block, protect, rights, delete, upload, move, import, patrol, merge, suppress, tag, managetags, contentmodel, pagetranslation, newusers, create, pagelang
leaction

Filter log actions to only this action. Overrides letype. In the list of possible values, values with the asterisk wildcard such as action/* can have different strings after the slash (/).

One of the following values: abusefilter/create, abusefilter/hit, abusefilter/modify, abusefilterprivatedetails/access, block/block, block/reblock, block/unblock, contentmodel/change, contentmodel/new, create/create, delete/delete, delete/delete_redir, delete/event, delete/flow-delete-post, delete/flow-delete-topic, delete/flow-restore-post, delete/flow-restore-topic, delete/restore, delete/revision, gblblock/dwhitelist, gblblock/gblock, gblblock/gblock2, gblblock/gunblock, gblblock/modify, gblblock/whitelist, gblrename/merge, gblrename/promote, gblrename/rename, gblrights/deleteset, gblrights/groupperms, gblrights/groupprms2, gblrights/groupprms3, gblrights/grouprename, gblrights/newset, gblrights/setchange, gblrights/setnewtype, gblrights/setrename, gblrights/usergroups, globalauth/delete, globalauth/hide, globalauth/lock, globalauth/lockandhid, globalauth/setstatus, globalauth/unhide, globalauth/unlock, import/interwiki, import/lqt-to-flow-topic, import/upload, interwiki/*, liquidthreads/merge, liquidthreads/move, liquidthreads/resort, liquidthreads/signatureedit, liquidthreads/split, liquidthreads/subjectedit, lock/flow-lock-topic, lock/flow-restore-topic, managetags/activate, managetags/create, managetags/deactivate, managetags/delete, massmessage/*, massmessage/failure, massmessage/send, massmessage/skipbadns, massmessage/skipnouser, massmessage/skipoptout, merge/merge, move/move, move/move_redir, newsletter/*, newusers/autocreate, newusers/byemail, newusers/create, newusers/create2, newusers/newusers, notifytranslators/sent, pagelang/pagelang, pagetranslation/associate, pagetranslation/deletefnok, pagetranslation/deletefok, pagetranslation/deletelnok, pagetranslation/deletelok, pagetranslation/discourage, pagetranslation/dissociate, pagetranslation/encourage, pagetranslation/mark, pagetranslation/movenok, pagetranslation/moveok, pagetranslation/prioritylanguages, pagetranslation/unmark, patrol/autopatrol, patrol/patrol, protect/modify, protect/move_prot, protect/protect, protect/unprotect, renameuser/renameuser, rights/autopromote, rights/rights, spamblacklist/*, suppress/block, suppress/cadelete, suppress/delete, suppress/event, suppress/flow-restore-post, suppress/flow-restore-topic, suppress/flow-suppress-post, suppress/flow-suppress-topic, suppress/hide-afl, suppress/reblock, suppress/revision, suppress/setstatus, suppress/unhide-afl, tag/update, thanks/*, timedmediahandler/resettranscode, titleblacklist/*, translationreview/group, translationreview/message, upload/overwrite, upload/revert, upload/upload, usermerge/*
lestart

The timestamp to start enumerating from.

Type: timestamp (allowed formats)
leend

The timestamp to end enumerating.

Type: timestamp (allowed formats)
ledir

In which direction to enumerate:

newer
List oldest first. Note: lestart has to be before leend.
older
List newest first (default). Note: lestart has to be later than leend.
One of the following values: newer, older
Default: older
leuser

Filter entries to those made by the given user.

Type: user name
letitle

Filter entries to those related to a page.

lenamespace

Filter entries to those in the given namespace.

One of the following values: -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
leprefix

Disabled due to miser mode.

letag

Only list event entries tagged with this tag.

lelimit

How many total event entries to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
lecontinue

When more results are available, use this to continue.

Notes[edit]

For autoblock unblock entries, the page title is shown as "User:$blockid". This is indeed not a User page, just the way it is stored. As per task T19781

Results[edit]

It returns a list of items, each item being a log item.

Items can contain these properties, from the logging table:

  • logid: Content of the log_id field.
  • ns: Content of the log_namespace field.
  • title: Prefixed title from the log_namespace and log_title fields.
  • pageid: Page id corresponding to the current page defined by the combination of the log_namespace and log_title fields. It represents the current page id, not the page id at the time the log was stored.
  • logpage: Content of the log_page field. It represents the page id at the time the log was stored.
  • type: Content of the log_type field.
  • action: Content of the log_action field.
  • userid: Content of the log_user field.
  • user: Content of the log_user_text field.
  • timestamp: Content of the log_timestamp field formatted in ISO 8601 format.
  • comment: Content of the log_comment field.
  • actionhidden: Boolean indicating the title was hidden. ns and title will be absent if the user has no sufficient rights to view deleted log entries.
  • commenthidden: Boolean indicating the comment was hidden. comment will be absent if the user has no sufficient rights to view deleted log entries.
  • userhidden: Boolean indicating the user was hidden. user and userid will be absent if the user has no sufficient rights to view deleted log entries.
  • suppressed: Boolean indicating details were supressed. Only users with the suppressrevision can view them.
  • params: Prettified content of the log_params field in array format:
    • Legacy parameters will contain numeric keys, where each key is a line.
    • Other entries are formatted according to the LogFormatter class:
      • In general, parameter names in "4::paramname" format are output as "paramname", stripping the index and type and formatting the value accordingly.
      • If the parameter is a title, it's split in 2 parameters: paramname_ns (contains the namespace number) and paramname_title (contains the whole title, namespace included).
    • Before MediaWiki 1.25:
      • Parameters weren't in the params property, but in a property with the same name as the type value.
      • Some log types had different parameter names.
      • Legacy parameters were in numeric keys directly inside the log entry and not inside the params property.

Here are some examples of child elements that reveal log parameters:

Block

<block duration="3 days" expiry="2014-09-18T20:35:54Z"><flags><f>nocreate</f></flags></params>

Move

<move target_ns="0" target_title="Foo" suppressredirect="" />

Patrol

<params curid="12" previd="0" auto="1" />

Rights

<params><newgroups><g>sysop</g></newgroups><oldgroups /></params>

See also[edit]

Other languages: English

Protectedtitles[edit]

Get a list of titles protected from creation.

Parameters[edit]

  • ptnamespace: Only list titles in these namespaces Type: namespace (pipe-separated)
  • ptlevel: Only list titles with this protection level Type: string (pipe-separated)
  • ptlimit: Maximum number of titles to return No more than 500 (5000 for bots) allowed. (Default: 10)
  • ptdir: Direction to list in. (Default: older)
    • older: List most recently protected titles first. Note: ptstart must be later than ptend.
    • newer: List least recently protected titles first. Note: ptstart must be earlier than ptend.
  • ptstart: Start listing at this protection timestamp
  • ptend: End listing at this protection timestamp
  • ptprop: A pipe-separated list of properties to get. (Default: timestamp|level)
    • timestamp: Timestamp the title was protected
    • user: User who protected the title
    • userid: User id who protected the title 1.17+
    • comment: Protection log comment
    • parsedcomment: Parsed protection log comment 1.16+
    • expiry: Expiry timestamp
    • level: Protection level (i.e. the right needed to be able to create the page)
  • continue: When more results are available, use this to continue 1.23+

Example[edit]

Get the first 2 titles only sysops can create

Error Codes[edit]

None

Querypage[edit]

Get a list provided by a QueryPage-based special page.

Note: Namespace filtering is unavailable on these pages. The possible way is to manually filter "ns" from all collected results.

Parameters[edit]

  • qppage: The name of the special page. Note, this is case sensitive. Possible values: vary by wiki and version. Use action=help&modules=query+querypage (action=help&querymodules=querypage prior to 1.21) to discover possible values for a specific wiki
  • qpoffset: When more results are available, use this to continue.
  • qplimit: Number of results to return. No more than 500 (5000 for bots) allowed. (Default: 10)

Values in MediaWiki 1.32.0[edit]

  • Ancientpages
  • BrokenRedirects
  • Deadendpages
  • DisambiguationPageLinks
  • DisambiguationPages
  • DoubleRedirects
  • EntityUsage
  • Fewestrevisions
  • GadgetUsage
  • GloballyWantedFiles
  • ListDuplicatedFiles
  • Listredirects
  • Lonelypages
  • Longpages
  • MediaStatistics
  • Mostcategories
  • MostGloballyLinkedFiles
  • Mostimages
  • Mostinterwikis
  • Mostlinkedcategories
  • Mostlinkedtemplates
  • Mostlinked
  • Mostrevisions
  • Shortpages
  • Uncategorizedcategories
  • Uncategorizedpages
  • Uncategorizedimages
  • Uncategorizedtemplates
  • UnconnectedPages
  • Unusedcategories
  • Unusedimages (known on Special pages as UnusedFiles)
  • Unusedtemplates
  • Unwatchedpages
  • Wantedcategories
  • Wantedfiles
  • Wantedpages
  • Wantedtemplates
  • Withoutinterwiki

Example[edit]

Show a list of first 10 pages which are uncategorized.

Random[edit]

MediaWiki version: 1.12

<translate> GET request to view a list of random pages.

This module can be used as a {{<tvar|1>ll|API:Query#Generators</>|generator}}.

API documentation[edit]

</translate>




list=random (rn)

(main | query | random)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Get a set of random pages.

Pages are listed in a fixed sequence, only the starting point is random. This means that if, for example, Main Page is the first random page in the list, List of fictional monkeys will always be second, List of people on stamps of Vanuatu third, etc.

Parameters:
rnnamespace

Return pages in these namespaces only.

Values (separate with | or alternative): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
To specify all values, use *.
rnfilterredir

How to filter for redirects.

One of the following values: all, redirects, nonredirects
Default: nonredirects
rnredirect
Deprecated.

Use rnfilterredir=redirects instead.

Type: boolean (details)
rnlimit

Limit how many random pages will be returned.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 1
rncontinue

When more results are available, use this to continue.

Examples:
Return two random pages from the main namespace.
api.php?action=query&list=random&rnnamespace=0&rnlimit=2 [open in sandbox]
Return page info about two random pages from the main namespace.
api.php?action=query&generator=random&grnnamespace=0&grnlimit=2&prop=info [open in sandbox]

<translate>

Example[edit]

GET Request[edit]

</translate> <translate> List 5 random pages</translate>

<translate>

Response[edit]

</translate>

{

"batchcomplete": "",
    "continue": {
        "rncontinue": "0.559881820010|0.559881954661|47659388|0",
        "continue": "-||"
    },
    "query": {
        "random": [
            {
                "id": 32381675,
                "ns": 0,
                "title": "Mallabhum Institute of Technology"
            },
            {
                "id": 25126452,
                "ns": 3,
                "title": "User talk:96.232.132.176"
            },
            {
                "id": 1440028,
                "ns": 0,
                "title": "Hyundai Epsilon engine"
            },
            {
                "id": 35446805,
                "ns": 15,
                "title": "Category talk:Ukrainian card games"
            },
            {
                "id": 12613,
                "ns": 0,
                "title": "Grue"
            }
        ]
    }
}

<translate>

Sample code[edit]

</translate> get_random.py

#!/usr/bin/python3

"""
    get_random.py

    MediaWiki Action API Code Samples
    Demo of `Random` module: Get a list of 5 random pages
    MIT license
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action":"query",
    "format":"json",
    "list": "random",
    "rnlimit": "5"
}

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

print(DATA)

<translate>

Parameter history[edit]

</translate>

  • v1.26: Deprecated rnredirect
  • v1.26: Introduced rnfilterredir
  • v1.14: Introduced rnredirect

<translate>

Additional notes[edit]

</translate>

  • <translate> Unlike most modules in the action API, the default number of pages returned is 1, not 10.</translate>
  • <translate> Pages are returned in a fixed sequence; only the starting point is actually random.</translate>
  • <translate> The default behavior is to pick pages from across the entire wiki, including talk pages, user pages, and so on.</translate> <translate> If you are looking for similar functionality as <tvar|1>Special:Random</>, i.e. pick random articles, restrict <tvar|2>rnnamespace</> to <tvar|3>0</>.</translate>
  • <translate> If the number of pages is fewer than <tvar|1>rnlimit</>, the request will simply return all available pages.</translate> <translate> It will not repeat pages to pad out the response up to the limit.</translate>

<translate>

See also[edit]

</translate>

Recentchanges[edit]

Get all recent changes to the wiki, in the same manner as Special:RecentChanges lists them. This module can be used as a generator (but note that, like all other generators, it generates information about pages, not about revisions). This module is implemented by ApiQueryRecentChanges.php.

Note that, although many log actions can be viewed using this module, patrol actions are not among them (because they are not present in the recentchanges table).

Parameters[edit]

Please note that by default, the Recentchanges table is queried is in reverse-chronological order with the most recent changes at the start of the list. This means that any specified rcstart value must be later than any specified rcend value. This requirement is reversed if a rcdir=newer is specified.

  • rcdir: Direction to list in (Default: older)
    • older: List newest changes first. Note: rcstart has to be later than rcend.
    • newer: List oldest changes first. Note: rcstart has to be earlier than rcend.
  • rcstart: The timestamp to start listing from (May not be more than $wgRCMaxAge into the past, which on Wikimedia wikis is 30 days[1])
  • rcend: The timestamp to end listing at
  • rcnamespace: Only list changes in these namespaces
  • rcuser: Only list changes made by this user
  • rcexcludeuser: Do not list changes made by this user
  • rctag: Only list changes tagged with this tag
  • rctype: Only list certain types of changes
    • edit: Regular page edits
    • external: External edits
    • new: Page creations (Uploads are not listed as new but as log)
    • log: Log entries
    • categorize: Page categorizations
  • rcshow: Only list items that meet all of these criteria. Conflicting options (such as minor and !minor) cannot be used together
    • minor: Only list minor edits
    • !minor: Don't list minor edits
    • bot: Only list bot edits
    • !bot: Don't list bot edits
    • anon: Only list edits by anonymous users
    • !anon: Only list edits by registered users
    • redirect: Only list edits to pages that are currently redirects
    • !redirect: Only list edits to pages that currently aren't redirects
    • patrolled: Only list edits flagged as patrolled (including autopatrolled edits). Only available to users with the patrol right
    • !patrolled: Only list edits not flagged as patrolled (neither manual nor automatically). Only available to users with the patrol right
    • autopatrolled: Only list edits flagged as autopatrolled. Only available to users with the patrol right
    • !autopatrolled: Only list edits not flagged as autopatrolled. Only available to users with the patrol right
    • unpatrolled: Only list edits not flagged as patrolled (neither manual nor automatically). Equivalent to !patrolled. Only available to users with the patrol right
  • rcprop: Which properties to get (Default: timestamp|title|ids)
    • user: The user who made the change. Also returns anon="" if it was an anonymous edit.
    • userid: The user id who made the change.
    • comment: The edit/log comment
    • parsedcomment: The parsed comment for the edit/log comment
    • timestamp: The time and date of the change
    • title: The title the change was made to
    • ids: Gets the following IDs: pageid (rc_cur_id); revid (rc_this_oldid); old_revid (rc_last_oldid); and rcid (rc_id) (used for patrolling).
    • sha1: content checksum for entries associated with a revision
    • sizes: The page size before (oldlen) and after (newlen) the change
    • redirect: Whether the changed page is currently a redirect. When returned, the value is an empty string; not the redirect destination.
    • patrolled: Whether the change is patrolled. Only available to users with the patrol right. When returned, the value is an empty string.
    • loginfo: If the change was a log event, add the logid, logtype and logaction fields and the log parameters 1.13+
    • tags: List tags for the entry
    • flags
      • new: A new page was created
      • minor: The change was a minor edit
      • bot: The change was a bot edit
  • rctoken: Which tokens to obtain for each change (deprecated in 1.24)
  • rclimit: Maximum amount of changes to list (Default: 10)
  • rctoponly: Only list changes which are the latest revision
  • rccontinue: When more results are available, use this to continue
  • rctitles: Restrict results to these page titles 1.14-1.15 (removed in 1.15)

Example[edit]

Get the 3 most recent changes with sizes and flags

Possible warnings

  • Action 'action' is not allowed for the current user
    • Thrown when a token is requested that the current user isn't allowed to use

Error Codes[edit]

Code Info
rcshow Incorrect parameter - mutually exclusive values may not be supplied
rcpermissiondenied You need the patrol right to request the patrolled flag

Output[edit]

The "type" that is returned can be 'edit', 'new', 'move', 'categorize', 'log', 'external', or 'move over redirect'.

See also[edit]

References[edit]

Search[edit]

MediaWiki version: 1.11

<translate> GET Request to search for a title or text in a wiki. </translate>

<translate>

API documentation[edit]

</translate>




list=search (sr)

(main | query | search)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Perform a full text search.

Parameters:
srsearch

Search for page titles or content matching this value. You can use the search string to invoke special search features, depending on what the wiki's search backend implements.

This parameter is required.
srnamespace

Search only within these namespaces.

Values (separate with | or alternative): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
To specify all values, use *.
Default: 0
srlimit

How many total pages to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
sroffset

When more results are available, use this to continue.

Type: integer
Default: 0
srqiprofile

Query independent profile to use (affects ranking algorithm).

classic
Ranking based on the number of incoming links, some templates, page language and recency (templates/language/recency may not be activated on this wiki).
classic_noboostlinks
Ranking based on some templates, page language and recency when activated on this wiki.
empty
Ranking based solely on query dependent features (for debug only).
wsum_inclinks
Weighted sum based on incoming links
wsum_inclinks_pv
Weighted sum based on incoming links and weekly pageviews
popular_inclinks_pv
Ranking based primarily on page views
popular_inclinks
Ranking based primarily on incoming link counts
engine_autoselect
Let the search engine decide on the best profile to use.
One of the following values: classic, classic_noboostlinks, empty, wsum_inclinks, wsum_inclinks_pv, popular_inclinks_pv, popular_inclinks, engine_autoselect
Default: engine_autoselect
srwhat

Which type of search to perform.

One of the following values: title, text, nearmatch
srinfo

Which metadata to return.

Values (separate with | or alternative): totalhits, suggestion, rewrittenquery
Default: totalhits|suggestion|rewrittenquery
srprop

Which properties to return:

size
Adds the size of the page in bytes.
wordcount
Adds the word count of the page.
timestamp
Adds the timestamp of when the page was last edited.
snippet
Adds a parsed snippet of the page.
titlesnippet
Adds a parsed snippet of the page title.
redirecttitle
Adds the title of the matching redirect.
redirectsnippet
Adds a parsed snippet of the redirect title.
sectiontitle
Adds the title of the matching section.
sectionsnippet
Adds a parsed snippet of the matching section title.
isfilematch
Adds a boolean indicating if the search matched file content.
categorysnippet
Adds a parsed snippet of the matching category.
score
Deprecated. Ignored.
hasrelated
Deprecated. Ignored.
extensiondata
Adds extra data generated by extensions.
Values (separate with | or alternative): size, wordcount, timestamp, snippet, titlesnippet, redirecttitle, redirectsnippet, sectiontitle, sectionsnippet, isfilematch, categorysnippet, score, hasrelated, extensiondata
Default: size|wordcount|timestamp|snippet
srinterwiki

Include interwiki results in the search, if available.

Type: boolean (details)
srenablerewrites

Enable internal query rewriting. Some search backends can rewrite the query into another which is thought to provide better results, for instance by correcting spelling errors.

Type: boolean (details)
srsort

Set the sort order of returned results.

One of the following values: relevance, just_match, none, incoming_links_asc, incoming_links_desc, last_edit_asc, last_edit_desc
Default: relevance

<translate>

GET Request[edit]

</translate>

<translate> Default search results are without UTF8 encoding.</translate> <translate> Replace utf8 in the get request above to see the difference.</translate>

<translate>

Response[edit]

</translate>

{
    "batchcomplete": "",
    "continue": {
        "sroffset": 10,
        "continue": "-||"
    },
    "query": {
        "searchinfo": {
            "totalhits": 5060
        },
        "search": [
            {
                "ns": 0,
                "title": "Nelson Mandela",
                "pageid": 21492751,
                "size": 196026,
                "wordcount": 23664,
                "snippet": "<span class=\"searchmatch\">Nelson</span> Rolihlahla <span class=\"searchmatch\">Mandela</span> (/mænˈdɛlə/, Xhosa: [xoliɬaˈɬa <span class=\"searchmatch\">manˈdɛla</span>]; 18 July 1918 – 5 December 2013) was a South African anti-apartheid revolutionary,",
                "timestamp": "2018-07-23T07:59:43Z"
            },
            {
                "ns": 0,
                "title": "Death of Nelson Mandela",
                "pageid": 41284488,
                "size": 133513,
                "wordcount": 13512,
                "snippet": "On December 5, 2013, <span class=\"searchmatch\">Nelson</span> <span class=\"searchmatch\">Mandela</span>, the first President of South Africa to be elected in a fully representative democratic election, as well as the country's",
                "timestamp": "2018-07-19T17:30:59Z"
            }
            ...
        ]
    }
}

<translate>

Sample code[edit]

</translate> Search.py

#!/usr/bin/python3

"""
    search.py

    MediaWiki Action API Code Samples
    Demo of `Search` module: Search for a text or title
    MIT license
"""

import requests

S = requests.Session()

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

SEARCHPAGE = "Nelson Mandela"

PARAMS = {
    'action':"query",
    'list':"search",
    'srsearch': SEARCHPAGE,
    'format':"json"
}

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

if DATA['query']['search'][0]['title'] == SEARCHPAGE:
    print("Your search page '" + SEARCHPAGE + "' exists on English Wikipedia")

<translate>

Demo app(s)[edit]

</translate>

<translate> Article suggestion demo app</translate>

<translate>

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
nosrsearch The srsearch parameter must be set.
<translate> This was param-search before 1.17</translate>
search-text-disabled text search is disabled.
search-title-disabled title search is disabled.
search-error <translate> search error has occurred</translate>

<translate>

Parameter history[edit]

</translate>

  • v1.24: Deprecated score,hasrelated
  • v1.23: Removed srredirects. Redirects are always included. Introduced srinterwiki
  • v1.22: Introduced srbackend
  • v1.17: Introduced nearmatch, score, titlesnippet, redirecttitle, redirectsnippet, sectiontitle, sectionsnippet, hasrelated
  • v1.16: Introduced srinfo, srprop

<translate>

Additional notes[edit]

  • Depending on which search backend is in use, how srsearch is interpreted may vary.</translate> <translate>

On Wikimedia wikis which use CirrusSearch, see <tvar|1>Help:CirrusSearch </> for information about the search syntax.

See also[edit]

</translate>

Tags[edit]

List valid change tags.

Parameters[edit]

  • tgcontinue: When more results are available, use this to continue.
  • tglimit: The maximum number of tags to list. No more than 500 (5000 for bots) allowed. Type: limit (Default: 10)
  • tgprop: Which properties to get. (Default: name)
    • name: Adds name of tag. (Note: this is a dummy property—the name will always be added, even if not specified.)
    • displayname: Adds system message for the tag.
    • description: Adds description of the tag.
    • hitcount: Adds the amount of revisions that have this tag.

Example[edit]

List the hitcount for the first 5 change tags.

Usercontribs[edit]

API:Usercontribs

Users[edit]

API:Users

Watchlist[edit]

API:Watchlist

Watchlistraw[edit]

API:Watchlistraw