API:Lists/All

From MediaWiki.org
Jump to navigation Jump to search

Ugly but useful view of all lists pages combined.

Contents

Allcategories[edit]

Get a list of all categories. This differs from list=allpages&alnamespace=14 in that categories without descriptions will be listed, while redirects and pages where the category was never used will not. Note: the allcategories list includes categories that were previously used but have since been deleted. It is recommended that the list be filtered to those where the size is greater than zero or the category page exists.

Parameters[edit]

  • acfrom: The category to start enumerating from
  • acto: The category to stop enumerating at
  • acprefix: Search for all category titles that begin with this value
  • acdir: Direction to sort in (Default: ascending)
    • ascending: List from A to Z
    • descending: List from Z to A
  • acmin: Minimum number of category members
  • acmax: Maximum number of category members
  • aclimit: How many categories to return. No more than 500 (5000 for bots) allowed. (Default: 10)
  • acprop: Which properties to get (Default: none)
    • size: Adds number of pages in the category
    • hidden: Tags categories that are hidden with __HIDDENCAT__

Example[edit]

List the first 10 categories whose name starts with "List of"

Error Codes[edit]

None

See also[edit]

Allimages[edit]

Returns a list of all files, ordered by title or by timestamp. Timestamp order was added in MediaWiki 1.20. Only the most recent version of each file is returned.

Parameters[edit]

  • aisort: Property to sort by (Default: name) 1.20+
    • name: Sort results by name
    • timestamp: Sort results by timestamp
  • aidir: In which direction to list (Default: ascending)
    • ascending: List from A to Z (when aisort=name) or from old to new (when aisort=timestamp)
    • descending: List from Z to A (when aisort=name) or from new to old (when aisort=timestamp)
    • newer: List from A to Z (when aisort=name) or from old to new (when aisort=timestamp) 1.20+
    • older: List from Z to A (when aisort=name) or from new to old (when aisort=timestamp) 1.20+
  • aifrom: Start listing at this title. The title doesn't need to exist. Can only be used with aisort=name
  • aito: Stop listing at this title. The title doesn't need to exist. Can only be used with aisort=name
  • aiprefix: Only list titles that start with this value. Can only be used with aisort=name
  • aistart: The timestamp to start enumerating from. Can only be used with aisort=timestamp 1.20+
  • aiend: The timestamp to end enumerating. Can only be used with aisort=timestamp 1.20+
  • aiminsize: Only list files that are at least this many bytes in size
  • aimaxsize: Only list files that are at most this many bytes in size
  • ailimit: Maximum amount of files to list (Default: 10)
  • aisha1: Only list files with this SHA-1 hash. These hashes are supposed to be unique, so you can use this to track duplicates. If you run into two different files with the same hash, you should report it, since it will be of considerable interest to some people.
  • aisha1base36: Same as aisha1, but in base 36
  • aiuser: Only return files uploaded by this user. Can only be used with aisort=timestamp. Cannot be used together with aifilterbots 1.20+
  • aifilterbots: How to filter files uploaded by bots. Can only be used with aisort=timestamp. Cannot be used together with aiuser. Possible values: all, bots, nobots 1.20+
  • aiprop: Which properties to get (Default: timestamp|url)
    • timestamp: The time and date the most recent version of the file was uploaded
    • user: The name of the user who uploaded the most recent version
    • userid: Add the user ID that uploaded the file version 1.17+
    • comment: The edit comment for the latest upload
    • parsedcomment: Parse the comment on the version 1.17+
    • canonicaltitle: Adds the canonical title of the file 1.23+
    • url: The URL to the most recent version of the file
    • size: The file's size in bytes, its height and its width. Page count and duration are added if applicable
    • dimensions: Alias for size
    • sha1: The file's SHA-1 hash
    • mime: The file's MIME type
    • mediatype: The media type of the file 1.18+
    • metadata: Exif metadata for the file, if any
    • commonmetadata: File format generic metadata for the version of the file 1.23+
    • extmetadata: Formatted metadata combined from multiple sources. Results are HTML formatted. 1.23+
    • bitdepth: The bit depth of the version 1.14+
  • aimime: What MIME type to search for. e.g. image/jpeg. Disabled in Miser Mode 1.18+

Example[edit]

Show a list of first 5 files whose name starts with "Albert"

Alllinks[edit]

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

Parameters[edit]

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

Example[edit]

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

Error Codes[edit]

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




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

Enumerate all links that point to a given namespace.

Parameters:
alcontinue

When more results are available, use this to continue.

alfrom

The title of the link to start enumerating from.

alto

The title of the link to stop enumerating at.

alprefix

Search for all linked titles that begin with this value.

alunique

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

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

Type: boolean (details)
alprop

Which pieces of information to include:

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

The namespace to enumerate.

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

How many total items to return.

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

The direction in which to list.

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

Allpages[edit]

Returns a list of pages in a given namespace, ordered by page title.

  • apfrom: Start listing at this title. The title need not exist.
  • apto: The page title to stop enumerating at
  • apprefix: Only list titles that start with this value
  • apnamespace: The id of the namespace to enumerate (see API:Meta to get the list and the ids of the namespaces). You can only enumerate one namespace at a time. (Default: 0)
  • apfilterredir: How to filter redirects (Default: all)
    • all: List all pages regardless of their redirect flag
    • redirects: Only list redirects
    • nonredirects: Don't list redirects
  • apfilterlanglinks: How to filter based on whether a page has language links (Default: all)
    • all: List all pages regardless of whether they have language links
    • withlanglinks: Only list pages with language links
    • withoutlanglinks: Only list pages without language links
  • apminsize: Only list pages that are at least this many bytes in size
  • apmaxsize: Only list pages that are at most this many bytes in size
  • apprtype: Only list pages that have been protected from this type of action
    • edit: Only list edit-protected pages
    • move: Only list move-protected pages
  • apprlevel: Only list pages that have been protected at this level. Cannot be used without apprtype
    • autoconfirmed: Only autoconfirmed users can edit/move/whatever
    • sysop: Only sysops can edit/move/whatever
  • aplimit: Maximum amount of pages to list. (Default: 10)
  • apdir: In which direction to list (Default: ascending) 1.12+
    • ascending: List from A to Z
    • descending: List from Z to A
  • apprfiltercascade: Filter protections based on cascadingness (ignored when apprtype isn't set). Possible values: cascading, noncascading, all (Default: all)
  • apprexpiry: Which protection expiry to filter the page on (Default: all)
    • 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

Example[edit]

Show a list of first 5 pages starting from "Kre"

Show a list of first 3 categories (Namespace id = 14) starting at Ab...

Error Codes[edit]

  • Unrecognized parameter
    • info: when using allpages as a generator instead of just a list, add a g to the start of its parameter names. E.g. "gapnamespace" instead of "apnamespace"
  • code: apparams
    • info: Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator
  • code: apparams
    • info: prlevel may not be used without prtype

See also[edit]

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]

Parameters[edit]

  • 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 value: ascending, descending. Default: ascending
  • augroup : Limit users to given group name(s). Possible values: bot, sysop, bureaucrat (+ any other group that is defined on the wiki). This is different for every wiki; see the API help or action=paraminfo for a list of possible values
  • auexcludegroup : Exclude users in given group name(s). Can not be used together with 'group'.
  • aurights : Limit users to given right(s)
  • auprop : What 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) 1.12+
  • aulimit : How many total user names to return. No more than 500 (5000 for bots) allowed. (Default: 10)
  • auwitheditsonly: Only list users who have made edits
  • auactiveusers : Only list users active in the last 30 days(s)

Example[edit]

Show a list of usernames starting with Y (or whichever sorts first after that)

Show a list of first 5 sysops

Error Codes[edit]

Code Info
augroup-excludegroup group and excludegroup cannot be used together

Note[edit]

This api call is case sensitive, so aufrom=YA doesn't have the same results as aufrom=Ya.

Backlinks[edit]

Lists pages that link to a given page, similar to Special:Whatlinkshere.

Parameters[edit]

  • bltitle: List pages linking to this title. The title does not need to exist.
  • blpageid: Page ID to search.
  • blnamespace: Only list pages in these namespaces
  • blfilterredir: How to filter redirects. (Default: all)
    • all: List all pages regardless of their redirect flag.
    • redirects: Only list redirects. Note that redirects which include links to the page below the redirect itself will also be included in the results. Use API:Redirects to limit the results to only those pages that redirect directly to the source page.
    • nonredirects: Don't list redirects.
  • bllimit: Maximum amount of pages to list. Maximum limit is halved if blredirect is set. No more than 500 (5000 for bots) allowed. (Default: 10)
  • blredirect: If set, pages linking to bltitle through a redirect will also be listed. See below for more detailed information.
  • blcontinue: Used to continue a previous request.

Example[edit]

Find all redirect pages that link or redirect to the en:Main Page.

Other links[edit]

Links through redirects[edit]

MediaWiki version: 1.12

When the blredirect parameter is set, this module behaves slightly differently. bllimit applies to both levels separately: if e.g. bllimit=10, at most 10 first-level pages (pages that link to bltitle) and 10 second-level pages (pages that link to bltitle through a redirect) will be listed. Continuing queries also works differently, as displayed in the following example.

Get a list of pages linking to Albert Einstein (note: the initial query includes a "blcontinue" parameter for purposes of illustration)

When continuing this request, we see that there are more pages linking to Einstein, and that some of the other first-level pages are listed again. If we continue this query again, the same first-level pages will be listed in the next response, as well. To progress beyond Energy, we have to query-continue again and again until we've had all links to Einstein (or increase bllimit, of course).

Continuing the previous request:

Links through transclusions[edit]

If you need to list pages as they appear in "What links here" on the MediaWiki sites with pages transcluding the desired page, you might want to try API:Embeddedin list.

Links through image usage[edit]

If you need to list pages as they appear in "What links here" on the MediaWiki sites with pages displaying the desired file, you might want to try API:Imageusage list. This also works on non-existent files.

Error Codes[edit]

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

Blocks[edit]

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

Parameters[edit]

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

Example[edit]

Listing the 3 most recent blocks

Error Codes[edit]

None.

See also[edit]




list=blocks (bk)

(main | query | blocks)

List all blocked users and IP addresses.

Parameters:
bkstart

The timestamp to start enumerating from.

Type: timestamp (allowed formats)
bkend

The timestamp to stop enumerating at.

Type: timestamp (allowed formats)
bkdir

In which direction to enumerate:

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

List of block IDs to list (optional).

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

List of users to search for (optional).

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

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

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

bklimit

The maximum number of blocks to list.

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

Which properties to get:

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

Show only items that meet these criteria.

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

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

When more results are available, use this to continue.

Categorymembers[edit]

MediaWiki version: 1.11

GET Request to list pages that belong to a given category.

API documentation[edit]




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.

Examples[edit]

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

GET request[edit]

Response[edit]

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

Sample code[edit]

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)

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

GET Request[edit]

Response[edit]

Sample code[edit]

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

GET request[edit]

Response[edit]

The next subcategories (if there're more than 10) can be continued using the cmcontinue parameter from the response above.

Sample code[edit]

Possible errors[edit]

Code Info
cmnotitle The cmtitle parameter 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

Parameter history[edit]

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

deletedrevs[edit]

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

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

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

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

Parameters[edit]

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

Examples[edit]

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

Error Codes[edit]

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




list=deletedrevs (dr)

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

List deleted revisions.

Operates in three modes:

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

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

Parameters:
drstart

The timestamp to start enumerating from.

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

The timestamp to stop enumerating at.

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

In which direction to enumerate:

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

Start listing at this title.

Mode: 3
drto

Stop listing at this title.

Mode: 3
drprefix

Search for all page titles that begin with this value.

Mode: 3
drunique

List only one revision for each page.

Mode: 3
Type: boolean (details)
drnamespace

Only list pages in this namespace.

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

Only list revisions tagged with this tag.

druser

Only list revisions by this user.

Type: user name
drexcludeuser

Don't list revisions by this user.

Type: user name
drprop

Which properties to get:

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

The maximum amount of revisions to list.

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

When more results are available, use this to continue.

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

Embeddedin[edit]

<translate> List pages that transclude a certain page.

Parameters[edit]

</translate>

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

<translate>

Example[edit]

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

<translate>

Error Codes[edit]

</translate>

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





list=embeddedin (ei)

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

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

Parameters:
eititle

Title to search. Cannot be used together with eipageid.

eipageid

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

Type: integer
eicontinue

When more results are available, use this to continue.

einamespace

The namespace to enumerate.

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

The direction in which to list.

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

How to filter for redirects.

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

How many total pages to return.

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

Exturlusage[edit]

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

Parameters[edit]

</translate>

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

<translate>

Example[edit]

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

Filearchive[edit]

<translate> Enumerate all deleted files sequentially

Parameters[edit]

</translate>

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

<translate>

Error Codes[edit]

</translate>

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

Imageusage[edit]

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

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

<translate>

Parameters[edit]

</translate>

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

<translate>

Errors Codes[edit]

</translate>

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

Iwbacklinks[edit]

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

Parameters[edit]

</translate>

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

<translate>

Error Codes[edit]

</translate>

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

Langbacklinks[edit]

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

Parameters[edit]

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

Errors Codes[edit]

Code Info
missingparam The lang parameter must be set.

Logevents[edit]

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

Parameters[edit]

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

Example[edit]

List the 3 most recent page moves

List the 3 most recent uploads

Error Codes[edit]

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




list=logevents (le)

(main | query | logevents)

Get events from logs.

Parameters:
leprop

Which properties to get:

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

Filter log entries to only this type.

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

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

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

The timestamp to start enumerating from.

Type: timestamp (allowed formats)
leend

The timestamp to end enumerating.

Type: timestamp (allowed formats)
ledir

In which direction to enumerate:

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

Filter entries to those made by the given user.

Type: user name
letitle

Filter entries to those related to a page.

lenamespace

Filter entries to those in the given namespace.

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

Disabled due to miser mode.

letag

Only list event entries tagged with this tag.

lelimit

How many total event entries to return.

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

When more results are available, use this to continue.

Notes[edit]

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

Results[edit]

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

Items can contain these properties, from the logging table:

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

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

Block

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

Move

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

Patrol

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

Rights

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

See also[edit]

Other languages: English

Protectedtitles[edit]

Get a list of titles protected from creation.

Parameters[edit]

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

Example[edit]

Get the first 2 titles only sysops can create

Error Codes[edit]

None

Querypage[edit]

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

Parameters[edit]

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

Values in MediaWiki 1.32.0[edit]

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

Example[edit]

Show a list of first 10 pages which are uncategorized.

Random[edit]

<translate> Get a list of random pages.

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

If the number of pages in the namespace is lower than rnlimit, you will get fewer pages.</translate> <translate> You will not get the same page twice.

Parameters[edit]

</translate>

  • rnlimit: <translate> Limit how many random pages will be returned.</translate> No more than 10 (20 for bots) allowed. (Default: 1)
  • rnnamespace: <translate> Only list pages in these namespaces.</translate> (Default: <translate> all namespaces</translate>)
  • rnredirect: <translate> Load a random redirect instead of a random page.</translate> (Default: false) 1.14+ (deprecated in 1.26)
  • rnfilterredir: <translate> How to filter for redirects.</translate> Possible values: all, redirects, nonredirects (Default: nonredirects) 1.26+

<translate>

Example[edit]

</translate>

<translate> Get 5 random pages</translate>

<translate>

Possible errors[edit]

None </translate>

Recentchanges[edit]

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

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

Parameters[edit]

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

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

Example[edit]

Get the 3 most recent changes with sizes and flags

Possible warnings

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

Error Codes[edit]

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

Output[edit]

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

See also[edit]

References[edit]

Search[edit]

MediaWiki version: 1.11

<translate>

API documentation[edit]

</translate>




list=search (sr)

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

Perform a full text search.

Parameters:
srsearch

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

This parameter is required.
srnamespace

Search only within these namespaces.

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

How many total pages to return.

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

When more results are available, use this to continue.

Type: integer
Default: 0
srqiprofile

Query independent profile to use (affects ranking algorithm).

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

Which type of search to perform.

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

Which metadata to return.

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

Which properties to return:

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

Include interwiki results in the search, if available.

Type: boolean (details)
srenablerewrites

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

Type: boolean (details)
srsort

Set the sort order of returned results.

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

<translate>

GET Request[edit]

</translate>

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

<translate>

Response[edit]

</translate>

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

<translate>

Sample code[edit]

</translate> Search.py

#!/usr/bin/python3

"""
    search.py

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

import requests

S = requests.Session()

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

SEARCHPAGE = "Nelson Mandela"

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

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

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

<translate>

Demo app(s)[edit]

</translate>

<translate> Article suggestion demo app</translate>

<translate>

Possible errors[edit]

</translate>

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

<translate>

Parameter history[edit]

</translate>

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

<translate>

Additional notes[edit]

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

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

See also[edit]

</translate>

Tags[edit]

List valid change tags.

Parameters[edit]

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

Example[edit]

List the hitcount for the first 5 change tags.

Usercontribs[edit]

API:Usercontribs

Users[edit]

API:Users

Watchlist[edit]

API:Watchlist

Watchlistraw[edit]

API:Watchlistraw