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>

#!/usr/bin/python3

"""
    get_allimages_by_name.py
    MediaWiki Action API Code Samples
    List all images in the namespace, starting from files that
    begin with 'Graffiti_000'. 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": "Graffiti_000",
    "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: <translate> Introduced <tvar|1>aiprop=canonicaltitle, aiprop=commonmetadata, aiprop=extmetadata</></translate>
  • v1.20: <translate> Introduced <tvar|1>aisort, aistart, aiend, aiuser, aifilterbots, aidir=newer, aidir=older</></translate>
  • v1.18: <translate> Introduced <tvar|1>aimime, aiprop=mediatype</></translate>
  • v1.17: <translate> Introduced <tvar|1>aiprop=userid, aiprop=parsedcomment</></translate>
  • v1.14: <translate> Introduced <tvar|1>bitdepth</></translate>

<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]

MediaWiki version: 1.11

<translate> GET request to list links that point to a given {{<tvar|1>ll|Manual:Namespace</>|namespace}}, ordered by title.

This module can be used as a generator.

API documentation[edit]

</translate>




(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]

<translate>

Example[edit]

By default, this module will return duplicates if a page contains multiple links pointing to the same namespace.</translate> <translate> This example uses <tvar|1>alunique=1</> to remove any duplicate titles in the response.

GET request[edit]

</translate> <translate> List distinct links (i.e. no duplicates) which point to the main namespace.</translate>

<translate>

Response[edit]

</translate>

{
    "batchcomplete": "",
    "continue": {
        "alcontinue": "!!!!Hashtagging",
        "continue": "-||"
    },
    "query": {
        "alllinks": [
            {
                "ns": 0,
                "title": "!"
            },
            {
                "ns": 0,
                "title": "!!"
            },
            {
                "ns": 0,
                "title": "!!!"
            },
            ...
}

<translate>

Sample code[edit]

</translate> get_alllinks.py

#!/usr/bin/python3

"""
    get_alllinkinks.py

    MediaWiki Action API Code Samples
    Demo of `Alllinks` module: List links 
    pointing to a given namespace.
    MIT license
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action":"query",
    "format":"json",
    "list":"alllinks",
    "alunique":"1"
}

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

print(DATA)

<translate>

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
badcontinue Invalid continue param. You should pass the original value returned by the previous query.
invalidparammix The alprop=ids parameter cannot be used with alunique.
2>alunique</> together</translate>

<translate>

Additional notes[edit]

  • As with other link modules within the {{<tvar|1>ll|API:Main_page</>|Action API}}, this module returns the titles of the pages that link to the namespace, not the exact URIs to those pages.</translate>

<translate>

  • This module can be used as a generator.</translate>

<translate>

  • Previous versions would return an error if the user tried to run this module as a generator, and <tvar|1>alunique</> was set to true.</translate> <translate>

This was altered in v1.24, to allow using the module as a generator even if <tvar|1>alunique</> is true.

See also[edit]

</translate>

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>

  • Chris G's botclasses/AllPagesBot.php - <translate> a bot that retrieves all files on a wiki, utilizing this API</translate>
  • API:Categorymembers - <translate> lists all pages within a category</translate>
  • API:Categories - <translate> lists all categories associated with a certain page, which can aid in finding similar pages</translate>
  • API:Allcategories - <translate> lists all categories fitting a certain criteria</translate>
  • API:Allimages - <translate> lists all images whose file names fit a certain criteria</translate>
  • API:Allusers - <translate> lists all users in alphabetical order</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, uploader, checkuser, translationadmin, flow-bot, confirmed
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, uploader, checkuser, translationadmin, flow-bot, confirmed
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, urlshortener-manage-url, 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, oathauth-view-log, 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: <translate> Introduced <tvar|1>auprop=registration</></translate>

<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]

GET Request to list recent blocked users, in the same manner as Special:BlockList lists them.

MediaWiki version: 1.12

API documentation[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.

Example[edit]

Lists the 3 most recent blocks

GET Request[edit]

Response[edit]

{
    "batchcomplete": "",
    "continue": {
        "bkcontinue": "20190226192632|8865878",
        "continue": "-||"
    },
    "query": {
        "blocks": [
            {
                "id": 8865881,
                "user": "168.11.166.47",
                "by": "Gilliam",
                "timestamp": "2019-02-26T19:28:56Z",
                "expiry": "2020-02-26T19:28:56Z",
                "reason": "{{school block}}",
                "rangestart": "168.11.166.47",
                "rangeend": "168.11.166.47",
                "anononly": "",
                "nocreate": "",
                "allowusertalk": ""
            },
            {
                "id": 8865880,
                "user": "64.125.67.43",
                "by": "Gilliam",
                "timestamp": "2019-02-26T19:27:44Z",
                "expiry": "2019-03-01T19:27:44Z",
                "reason": "part of mass attack",
                "rangestart": "64.125.67.43",
                "rangeend": "64.125.67.43",
                "anononly": "",
                "nocreate": "",
                "allowusertalk": ""
            }
            ...
        ]
    }
}

Sample code[edit]

get_blocked_users.py

#!/usr/bin/python3

"""
    get_blocked_users.py

    MediaWiki Action API Code Samples
    Demo of `Blocks` module: GET request to list recent blocked users

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "query",
    "bklimit": "3",
    "list": "blocks",
    "bkprop": "id|user|by|timestamp|expiry|reason|range|flags",
    "format": "json"
}

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

print(DATA['query']['blocks'])

Additional notes[edit]

Parameter history[edit]

  • v1.19: Introduced bkshow
  • v1.18: Introduced userid

See also[edit]

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: <translate> Deprecated <tvar|1>cmstartsortkey, cmendsortkey</></translate>
  • v1.18: <translate> Introduced <tvar|1>cmstartsortkeyprefix, cmendsortkeyprefix</></translate>
  • v1.17: <translate> Introduced <tvar|1>sortkeyprefix, type</></translate>
  • v1.14: <translate> Introduced <tvar|1>cmstartsortkey, cmendsortkey</></translate>
  • v1.12: <translate> Introduced <tvar|1>cmtype,cmstart, cmend, cmdir</></translate>

<translate>

See also[edit]

</translate>

  • API:Allpages - <translate> lists all pages fitting certain criteria</translate>
  • API:Categories - <translate> lists categories associated with a page</translate>
  • API:Allcategories - <translate> lists all categories on a wiki</translate>

deletedrevs[edit]

MediaWiki version: 1.25
alldeletedrevisions>alldeletedrevisions </> api</translate>

<translate> GET request to list deleted revisions.

API documentation[edit]

</translate>




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]

<translate>

Example[edit]

GET request[edit]

</translate> <translate> List the 6 most recent deleted revisions from user <tvar

<translate>

Response[edit]

</translate>

<?xml version="1.0" encoding="utf-8"?>
<api>
  <query-continue>
    <deletedrevs drstart="20070904142729" />
  </query-continue>
  <query>
    <deletedrevs>
      <page title="Main Page" ns="0" token="e4c475f13be7824135b4edbebf4140ff+\">
        <revisions>
          <rev timestamp="20070904200804" revid="31" user="Catrope" minor="" len="" />
          <rev timestamp="20070904200753" revid="30" user="Catrope" minor="" len="" />
          <rev timestamp="20070904193501" revid="29" user="Catrope" minor="" len="568" />
          <rev timestamp="20070904193213" revid="28" user="Catrope" minor="" len="470" />
        </revisions>
      </page>
      <page title="User:Catrope" ns="2" token="e4c475f13be7824135b4edbebf4140ff+\">
        <revisions>
          <rev timestamp="20070904143938" revid="24" user="Catrope" len="52" />
          <rev timestamp="20070904142758" revid="23" user="Catrope" len="37" />
        </revisions>
      </page>
    </deletedrevs>
  </query>
</api>

<translate>

Sample code[edit]

</translate> get_deleted_revisions.py

#!/usr/bin/python3

"""
    get_deleted_revisions.py

    MediaWiki Action API Code Samples
    Demo of `Deletedrevs` module: List the six most recent deleted revisions
    from User:Catrope

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "drend": "20070904000000",
    "format": "json",
    "druser": "Catrope",
    "list": "deletedrevs",
    "drstart": "20070904235959",
    "drlimit": "6",
    "drprop": "revid|user|minor|len|token",
    "action": "query"
}

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

print(DATA)

<translate>

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
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.

<translate>

Parameter history[edit]

</translate>

  • v1.24: <translate> Deprecated <tvar|1>drprop: token</></translate>
  • v1.23: <translate> Introduced <tvar|1>drtag, drprop: tags</></translate>
  • v1.19: <translate> Introduced <tvar|1>drprop: sha1</></translate>
  • v1.18: <translate> Introduced <tvar|1>drto, drprefix, drprop: parentid</></translate>
  • v1.17: <translate> Introduced <tvar|1>drprop: userid</></translate>
  • v1.16: <translate> Introduced <tvar|1>drprop: parsedcomment </></translate>
  • v1.15: <translate> Introduced <tvar|1>druser,drexcludeuser,drnamespace, drunique,drfrom</></translate>

<translate>

Additional notes[edit]

  • This module cannot be used as a {{<tvar|1>ll|API:Query#generators</>|generator}}.</translate>

<translate>

  • You need the <tvar|1>deletedhistory</> right to use this module.</translate> <translate> This module can be used in one of three modes:</translate>

<translate>

    • List deleted revisions for the given titles (through <tvar|1>titles</> or a generator), sorted by timestamp</translate>

<translate>

    • List deleted contributions for a certain user, sorted by timestamp (<tvar|1>druser</> set, no titles given)</translate>

<translate>

    • List all deleted revisions in a certain namespace (<tvar|1>druser</> not set, no titles given)</translate>

<translate>

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

See also[edit]

</translate>

Embeddedin[edit]

MediaWiki version: 1.11

<translate> GET request to find all page(s) that embed a given page.

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

API documentation[edit]

</translate>




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

<translate>

Example[edit]

GET request[edit]

</translate> <translate> Find all pages that embed the English Wikipedia's <tvar

<translate>

Response[edit]

</translate>

{
    "batchcomplete": "",
    "query": {
        "embeddedin": [
            {
                "pageid": 14388072,
                "ns": 100,
                "title": "Portal:Computing"
            },
            {
                "pageid": 45719527,
                "ns": 2,
                "title": "User:SoSivr/sandbox"
            }
        ]
    }
}

<translate>

Sample code[edit]

</translate> get_embedded_pages.py

#!/usr/bin/python3

"""
    get_embedded_pages.py

    MediaWiki Action API Code Samples
    Demo of `Embeddedin` module: Get all page(s) that 
    embed the given title.

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "query",
    "format": "json",
    "list": "embeddedin",
    "eititle": "Computer",
    "eilimit": "20"
}

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

print(DATA)

<translate>

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
missingparam One of the parameters eititle, eipageid is required.
eibadcontinue Invalid continue param. You should pass the original value returned by the previous query.

<translate>

See also[edit]

</translate>

  • API:Transcludedin - <translate> Find all pages that transclude the given pages.</translate>
  • API:Templates - <translate> Returns all pages transcluded on the given pages.</translate>
  • API:Alltransclusions - <translate> Part of <tvar|1>API:Alllinks </> module.</translate> <translate> This API gets a list all transclusions (pages embedded using <tvar|1>{{x}}</>), including non-existing.</translate>
  • API:Parsing_wikitext - <translate> Parse content of a page and obtain the output.</translate>

Exturlusage[edit]

MediaWiki version: 1.11

<translate> GET request to list pages that link to a certain URL, like <tvar|1>Special:Linksearch</>.

API documentation[edit]

</translate>




list=exturlusage (eu)

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

Enumerate pages that contain a given URL.

Parameters:
euprop

Which pieces of information to include:

ids
Adds the ID of page.
title
Adds the title and namespace ID of the page.
url
Adds the URL used in the page.
Values (separate with | or alternative): ids, title, url
Default: ids|title|url
eucontinue

When more results are available, use this to continue.

euprotocol

Protocol of the URL. If empty and euquery is set, the protocol is http. Leave both this and euquery empty to list all external links.

One of the following values: Can be empty, or bitcoin, ftp, ftps, geo, git, gopher, http, https, irc, ircs, magnet, mailto, mms, news, nntp, redis, sftp, sip, sips, sms, ssh, svn, tel, telnet, urn, worldwind, xmpp
Default: (empty)
euquery

Search string without protocol. See Special:LinkSearch. Leave empty to list all external links.

eunamespace

The page namespaces to enumerate.

Note: Due to miser mode, using this may result in fewer than eulimit 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 *.
eulimit

How many pages to return.

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

Expand protocol-relative URLs with the canonical protocol.

Type: boolean (details)

<translate>

Example[edit]

GET request[edit]

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

<translate>

Response[edit]

</translate>

{
    "batchcomplete": "",
    "continue": {
        "eucontinue": "http://org.slashdot./|169423",
        "continue": "-||"
    },
    "query": {
        "exturlusage": [
            {
                "pageid": 533948,
                "ns": 2,
                "title": "User:Peter Ellis",
                "url": "http://slashdot.org"
            },
            {
                "pageid": 3274,
                "ns": 2,
                "title": "User:Alexdb",
                "url": "http://slashdot.org/"
            },
            {
                "pageid": 36471,
                "ns": 2,
                "title": "User:Joao",
                "url": "http://slashdot.org/"
            }
            ...
        ]
    }
}

<translate>

Sample code[edit]

</translate> get_exturlusage.py

#!/usr/bin/python3

"""
    get_exturlusage.py

    MediaWiki Action API Code Samples
    Demo of `Exturlusage` module: Enumerate pages that contain a given URL.

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "query",
    "format": "json",
    "list": "exturlusage",
    "euquery": "slashdot.org"
}

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

print(DATA)

<translate>

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
unknown_euprotocol Wrong property for protocol parameter (use value from the list of supported protocols)
badcontinue Invalid continue param. You should pass the original value returned by the previous query.

<translate>

Parameter history[edit]

</translate>

  • v1.21: <translate> Introduced <tvar|1>euexpandurl</></translate>

<translate>

See also[edit]

</translate>

  • API:Backlinks - <translate> lists links to a given page.</translate>
  • API:Links - <translate> retrieves links on a given page or pages.</translate>
  • API:Iwlinks - <translate> Find interwiki links on a given page (i.e, meta pages, special pages).</translate>
  • API:Extlinks - <translate> Find all external links on a given page.</translate>
  • API:Langlinks - <translate> Get a list of language links from the given page.</translate> <translate> Language links represent translations.</translate>
  • API:Langbacklinks - <translate> Get a list of pages that contains a given language link.</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, oath, 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, oath/*, 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]

MediaWiki version: 1.18

<translate> GET request to get a list provided by a QueryPage-based special page.

API documentation[edit]

</translate>




list=querypage (qp)

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

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

Parameters:
qppage

The name of the special page. Note, this is case sensitive.

This parameter is required.
One of the following values: Ancientpages, BrokenRedirects, Deadendpages, DoubleRedirects, ListDuplicatedFiles, Listredirects, Lonelypages, Longpages, MediaStatistics, Mostcategories, Mostimages, Mostinterwikis, Mostlinkedcategories, Mostlinkedtemplates, Mostlinked, Mostrevisions, Fewestrevisions, Shortpages, Uncategorizedcategories, Uncategorizedpages, Uncategorizedimages, Uncategorizedtemplates, Unusedcategories, Unusedimages, Wantedcategories, Wantedfiles, Wantedpages, Wantedtemplates, Unwatchedpages, Unusedtemplates, Withoutinterwiki, UnconnectedPages, GadgetUsage, MostGloballyLinkedFiles, GloballyWantedFiles, DisambiguationPages, DisambiguationPageLinks
qpoffset

When more results are available, use this to continue.

Type: integer
Default: 0
qplimit

Number of results to return.

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

<translate>

Example[edit]

GET request[edit]

</translate> <translate> In the below query, we call the API to get a list of the first ten pages which are uncategorized</translate>

<translate>

Response[edit]

</translate>

{
  "batchcomplete": "", 
  "continue": {
    "continue": "-||", 
    "qpoffset": 10
  }, 
  "query": {
    "querypage": {
      "cached": "", 
      "cachedtimestamp": "2019-02-22T11:46:48Z", 
      "maxresults": 5000, 
      "name": "Uncategorizedpages", 
      "results": [
        {
          "ns": 0, 
          "title": "Abelardo Delgado", 
          "value": "0"
        }, 
        {
          "ns": 0, 
          "title": "Agriculture in Tonga", 
          "value": "0"
        }, 
        {
          "ns": 0, 
          "title": "Andriandramaka", 
          "value": "0"
        }
        ...
      ]
    }
  }
}

<translate>

Sample code[edit]

</translate> get_querypage_list

#!/usr/bin/python3

"""
    get_querypage_list.py

    MediaWiki Action API Code Samples
    Demo of `Querypage` module: List first 10 pages which are 
    uncategorized

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "qplimit": "10",
    "action": "query",
    "qppage": "Uncategorizedpages",
    "list": "querypage",
    "format": "json"
}

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

print(DATA)

<translate>

Special page values[edit]

</translate> (MediaWiki 1.32.0)

Ancientpages Listredirects Mostlinked Unusedtemplates
BrokenRedirects Lonelypages Mostrevisions Unwatchedpages
Deadendpages Longpages Shortpages Wantedcategories
DisambiguationPageLinks MediaStatistics Uncategorizedcategories Wantedfiles
DisambiguationPages Mostcategories Uncategorizedpages Wantedpages
DoubleRedirects MostGloballyLinkedFiles Uncategorizedimages Wantedtemplates
EntityUsage Mostimages Uncategorizedtemplates Withoutinterwiki
Fewestrevisions Mostinterwikis UnconnectedPages
GloballyWantedFiles Mostlinkedcategories Unusedcategories
ListDuplicatedFiles Mostlinkedtemplates Unusedimages

<translate>

Possible errors[edit]

</translate>

<translate> Code</translate> <translate> Info</translate>
unknown_qppage Unrecognized value for parameter qppage: value.
noqppage The qppage parameter must be set.

<translate>

Additional notes[edit]

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

<translate>

  • Namespace filtering is unavailable on these pages.</translate> <translate>

The possible way is to manually filter "ns" from collected results.

See also[edit]

</translate>

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: <translate> Previous limit of <tvar|1>10/20</> on <tvar|2>rnlimit</> was increased to standard <tvar|3>500/5000</> limits.</translate>
  • v1.26: <translate> Deprecated <tvar|1>rnredirect</></translate>
  • v1.26: <translate> Introduced <tvar|1>rnfilterredir</></translate>
  • v1.14: <translate> Introduced <tvar|1>rnredirect</></translate>

<translate>

Additional notes[edit]

</translate>

  • <translate> Unlike most modules in the {{<tvar|1>ll|API:Main page</>|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>

  • Manual:Random page - <translate> describes how to configure the API on the backend.</translate>

Recentchanges[edit]

MediaWiki version: 1.9

GET Request to list all the recent changes to the wiki, in the same manner as Special:RecentChanges lists them.

API documentation[edit]




list=recentchanges (rc)

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

Enumerate recent changes.

Parameters:
rcstart

The timestamp to start enumerating from.

Type: timestamp (allowed formats)
rcend

The timestamp to end enumerating.

Type: timestamp (allowed formats)
rcdir

In which direction to enumerate:

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

Filter changes to only these namespaces.

Values (separate with | or alternative): -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
To specify all values, use *.
rcuser

Only list changes by this user.

Type: user name
rcexcludeuser

Don't list changes by this user.

Type: user name
rctag

Only list changes tagged with this tag.

rcprop

Include additional pieces of information:

user
Adds the user responsible for the edit and tags if they are an IP.
userid
Adds the user ID responsible for the edit.
comment
Adds the comment for the edit.
parsedcomment
Adds the parsed comment for the edit.
flags
Adds flags for the edit.
timestamp
Adds timestamp of the edit.
title
Adds the page title of the edit.
ids
Adds the page ID, recent changes ID and the new and old revision ID.
sizes
Adds the new and old page length in bytes.
redirect
Tags edit if page is a redirect.
patrolled
Tags patrollable edits as being patrolled or unpatrolled.
loginfo
Adds log information (log ID, log type, etc) to log entries.
tags
Lists tags for the entry.
sha1
Adds the content checksum for entries associated with a revision.
Values (separate with | or alternative): user, userid, comment, parsedcomment, flags, timestamp, title, ids, sizes, redirect, patrolled, loginfo, tags, sha1
Default: title|timestamp|ids
rctoken
Deprecated.

Use action=query&meta=tokens instead.

Values (separate with | or alternative): patrol
rcshow

Show only items that meet these criteria. For example, to see only minor edits done by logged-in users, set rcshow=minor|!anon.

Values (separate with | or alternative): minor, !minor, bot, !bot, anon, !anon, redirect, !redirect, patrolled, !patrolled, unpatrolled, autopatrolled, !autopatrolled
rclimit

How many total changes to return.

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

Which types of changes to show.

Values (separate with | or alternative): edit, new, log, external, categorize
Default: edit|new|log|categorize
rctoponly

Only list changes which are the latest revision.

Type: boolean (details)
rctitle

Filter entries to those related to a page.

rccontinue

When more results are available, use this to continue.

rcgeneraterevisions

When being used as a generator, generate revision IDs rather than titles. Recent change entries without associated revision IDs (e.g. most log entries) will generate nothing.

Type: boolean (details)

Example[edit]

GET Request[edit]

Get the 3 most recent changes with sizes and flags

Response[edit]

{
    "batchcomplete": "",
    "continue": {
        "rccontinue": "20180330090522|1041353210",
        "continue": "-||"
    },
    "query": {
        "recentchanges": [
            {
                "type": "edit",
                "ns": 0,
                "title": "Histology",
                "pageid": 13570,
                "revid": 833218500,
                "old_revid": 833218201,
                "rcid": 1041353213,
                "user": "Iztwoz",
                "oldlen": 25718,
                "newlen": 25749
            }
            ...
        ]
    }
}

Sample code[edit]

get_recent_changes.py

#!/usr/bin/python3

"""
    get_recent_changes.py

    MediaWiki Action API Code Samples
    Demo of `RecentChanges` module: Get the three most recent changes 
    with sizes and flags

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "format": "json",
    "rcprop": "title|ids|sizes|flags|user",
    "list": "recentchanges",
    "action": "query",
    "rclimit": "3"
}

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

print(DATA)

Possible errors[edit]

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

Parameter history[edit]

  • v1.24: Deprecated rctoken
  • v1.15: Removed rctitles
  • v1.14: Introduced rctitles
  • v1.13: Introduced loginfo

Additional notes[edit]

See also[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, create_timestamp_asc, create_timestamp_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>

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: <translate> Deprecated <tvar|1>score,hasrelated</></translate>
  • v1.23:
    • <translate> Removed <tvar|1>srredirects</>.</translate> <translate> Redirects are always included.</translate>]
    • <translate> Introduced <tvar|1>srinterwiki</></translate>
  • v1.22: <translate> Introduced <tvar|1>srbackend</></translate>
  • v1.17: <translate> Introduced <tvar|1>nearmatch, score, titlesnippet, redirecttitle, redirectsnippet, sectiontitle, sectionsnippet, hasrelated</></translate>
  • v1.16: <translate> Introduced <tvar|1>srinfo, srprop</></translate>

<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