Skip to main content
action=query is the main read interface of the MediaWiki Action API. It is implemented in ApiQuery and works by assembling a set of pages (the page set) and then running one or more sub-modules against that set to collect data. Query sub-modules come in three types:
TypeParameterPurpose
propprop=Retrieve properties of the pages in the page set
listlist=Enumerate items from an index (not page-specific)
metameta=Return information about the wiki or the current session
Multiple sub-modules of any type can be combined in a single request.

Specifying pages

The page set is populated through one of these mutually exclusive parameters:
titles
string
Pipe-separated list of page titles. E.g., titles=MediaWiki|Help:Contents.
pageids
integer
Pipe-separated list of page IDs. E.g., pageids=1|2|3.
revids
integer
Pipe-separated list of revision IDs. Resolves to the pages those revisions belong to.
Up to 50 titles or page IDs can be passed per request (500 for users with the apihighlimits right, typically bots and sysops).

Prop modules

Prop modules attach data to each page in the page set. They are passed as a pipe-separated list in prop=.

revisions

Fetches revision data for each page. Returns the most recent revision by default.
https://en.wikipedia.org/w/api.php?action=query&titles=MediaWiki&prop=revisions&rvprop=content|timestamp|user&format=json&formatversion=2
Key rvprop values:
ValueDescription
idsRevision ID and parent revision ID
flagsMinor-edit flag
timestampTimestamp of the revision
userUsername of the editor
useridUser ID of the editor
commentEdit summary
parsedcommentEdit summary rendered as HTML
contentFull wikitext of the revision (expensive; use with care)
tagsChange tags applied to the revision
rolesSlot roles present in the revision
sha1SHA-1 hash of the revision content
sizeSize of the revision in bytes
Fetching rvprop=content for many pages in a single request is expensive. Prefer fetching content one page at a time or use a generator to control throughput.

info

Returns basic page information: namespace, last-edit timestamp, page ID, talk page, redirect target, protection levels, and more. Implemented in ApiQueryInfo.
https://en.wikipedia.org/w/api.php?action=query&titles=Main_Page&prop=info&inprop=protection|talkid|watched&format=json&formatversion=2

categories

Lists the categories a page belongs to.
https://en.wikipedia.org/w/api.php?action=query&titles=Python_(programming_language)&prop=categories&format=json&formatversion=2
Lists all internal wiki links on a page.

images

Lists all files (images, audio, etc.) embedded on a page.

templates

Lists all templates transcluded on a page.

imageinfo

Returns file metadata for each file page in the page set: dimensions, MIME type, upload timestamp, uploader, SHA-1 hash, and URLs.

pageprops

Returns key-value pairs stored as page properties (e.g., wikibase_item for Wikidata entity IDs, defaultsort for sort keys). Lists all external URLs present in the page’s wikitext. Lists interlanguage links on the page.

contributors

Returns the list of non-anonymous editors who have contributed to the page.

deletedrevisions

Lists deleted revisions for the specified pages. Requires the deletedhistory permission.

List modules

List modules enumerate items from database indexes. They are passed in list=.

allpages

Enumerates all pages in a given namespace.
https://en.wikipedia.org/w/api.php?action=query&list=allpages&apnamespace=0&aplimit=10&format=json&formatversion=2

allrevisions

Enumerates all revisions (across all pages), filterable by user, namespace, and date range.

recentchanges

Returns recent changes to the wiki, equivalent to Special:RecentChanges.
https://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rclimit=5&rcprop=title|timestamp|user|comment&format=json&formatversion=2

watchlist

Returns recent changes to pages on the authenticated user’s watchlist. Requires authentication.

categorymembers

Lists all pages in a given category.
https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Wikipedia&cmlimit=20&format=json&formatversion=2
Performs a full-text search.
https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=MediaWiki&format=json&formatversion=2

logevents

Enumerates log entries (move, delete, protect, block, etc.).

usercontribs

Returns all edits made by a specific user.
https://en.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser=Jimbo_Wales&uclimit=5&format=json&formatversion=2

blocks

Lists active blocks.

allcategories

Enumerates all categories on the wiki.

allusers

Enumerates registered user accounts. Return pages that link to, transclude, or use a given page or file.

Meta modules

Meta modules return information about the wiki or the current session. They are passed in meta=.

siteinfo

Returns wiki-wide configuration. Implemented in ApiQuerySiteinfo.
https://en.wikipedia.org/w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|statistics&format=json&formatversion=2
Key siprop values: general, namespaces, namespacealias, specialpagealiases, statistics, skins, extensiontags, usergroups, libraries, extensions, fileextensions, rightsinfo, interwikimap.

userinfo

Returns information about the currently authenticated user: username, user ID, groups, rights, email address, edit count, and preferences.
https://en.wikipedia.org/w/api.php?action=query&meta=userinfo&uiprop=groups|rights|editcount&format=json&formatversion=2

tokens

Returns security tokens required for write operations. See the Edit API and Authentication pages for usage. Token types (from ApiQueryTokens): csrf, watch, patrol, rollback, userrights, login, createaccount.
https://en.wikipedia.org/w/api.php?action=query&meta=tokens&type=csrf&format=json&formatversion=2

authmanagerinfo

Returns information about the available authentication providers — useful before initiating a clientlogin flow.

Continuation

When a query returns more results than the limit, the response includes a continue object. Pass all key-value pairs from continue back to the next request to retrieve the next page of results.
# First request
curl "https://en.wikipedia.org/w/api.php?action=query&list=allpages&aplimit=10&format=json&formatversion=2"

# Response includes:
# "continue": { "apcontinue": "Anthropology", "continue": "-||" }

# Next request — pass all continue values
curl "https://en.wikipedia.org/w/api.php?action=query&list=allpages&aplimit=10&apcontinue=Anthropology&continue=-||&format=json&formatversion=2"
Always iterate using the continue object wholesale — do not attempt to manually construct continuation parameters. The keys and values in continue are opaque and may change between MediaWiki versions.

Generator pattern

A generator turns a list module into a page-set source, feeding its results as input to prop modules. This avoids a two-step request (first list pages, then query properties for each). Prefix the list module name with generator= and its parameters with g:
https://en.wikipedia.org/w/api.php?action=query
  &generator=categorymembers
  &gcmtitle=Category:MediaWiki
  &gcmlimit=10
  &prop=revisions
  &rvprop=timestamp|user
  &format=json&formatversion=2
This returns the 10 most recent revision timestamps and editors for pages in the Category:MediaWiki category in a single request.

Common query patterns

Get wikitext content of a page

curl "https://en.wikipedia.org/w/api.php?action=query\
  &titles=Python_(programming_language)\
  &prop=revisions\
  &rvprop=content\
  &rvslots=main\
  &format=json&formatversion=2"
query.pages[].revisions[].slots.main.content
string
The raw wikitext of the page’s main slot.

Get the latest revision ID

curl "https://en.wikipedia.org/w/api.php?action=query&titles=MediaWiki&prop=revisions&rvprop=ids&format=json&formatversion=2"

Check whether pages exist

curl "https://en.wikipedia.org/w/api.php?action=query&titles=Real_page|Nonexistent_page_XYZ&prop=info&format=json&formatversion=2"
Missing pages are returned with "missing": true in formatversion=2.

Get recent changes in the last hour

curl "https://en.wikipedia.org/w/api.php?action=query\
  &list=recentchanges\
  &rclimit=50\
  &rcprop=title|timestamp|user|comment|sizes\
  &rcstart=$(date -u +%Y-%m-%dT%H:%M:%SZ)\
  &rcdir=older\
  &format=json&formatversion=2"

Get all pages in a category with their sizes

curl "https://en.wikipedia.org/w/api.php?action=query\
  &generator=categorymembers\
  &gcmtitle=Category:Featured_articles\
  &gcmlimit=20\
  &prop=info\
  &inprop=\
  &format=json&formatversion=2"

Build docs developers (and LLMs) love