Skip to main content
The MediaWiki REST API is a modern HTTP API for reading and writing wiki content. It is distinct from the older Action API and uses standard HTTP methods, JSON responses, and predictable URL patterns. All REST API endpoints are served from the base path /w/rest.php on your wiki host. The current stable version of the API uses the /v1/ path prefix.
The REST API is available on all MediaWiki installations running version 1.35 or later. Some endpoints require extensions (such as Parsoid for HTML rendering) to be configured.

Base URL

All endpoints are relative to:
https://{{wiki-host}}/w/rest.php/v1/
For example, on Wikipedia in English:
https://en.wikipedia.org/w/rest.php/v1/

Authentication

The REST API supports two authentication methods.

Cookies (session-based)

Requests made from a browser with an active MediaWiki session will be authenticated automatically using the session cookie. This is the default for browser-based clients.
Cookie-based authentication requires a valid CSRF token for write operations (PUT, POST). Include the token in the token field of the request body. Retrieve the token via the Action API’s action=query&meta=tokens endpoint before making write requests.

OAuth

For server-side or third-party clients, MediaWiki supports OAuth 1.0a and OAuth 2.0 via the OAuth extension. OAuth requests are authenticated using a signed Authorization header and do not require CSRF tokens.
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  https://en.wikipedia.org/w/rest.php/v1/page/Earth

Response format

All responses are JSON (Content-Type: application/json) unless the endpoint explicitly returns another type (for example, GET /v1/page/{title}/html returns text/html). Successful responses use standard HTTP 2xx status codes. Response bodies are objects or arrays as documented for each endpoint.
{
  "id": 9228,
  "key": "Earth",
  "title": "Earth",
  "latest": {
    "id": 1234567,
    "timestamp": "2024-01-15T10:30:00Z"
  },
  "content_model": "wikitext",
  "license": {
    "url": "https://creativecommons.org/licenses/by-sa/4.0/",
    "title": "Creative Commons Attribution-Share Alike 4.0"
  },
  "source": "{{DISPLAYTITLE:Earth}}\n'''''Earth''''' is the third planet..."
}

Error handling

Errors are returned as JSON objects with a messageTranslations field containing localized error messages, a httpCode integer, and a httpReason string.
{
  "messageTranslations": {
    "en": "The title you specified does not exist."
  },
  "httpCode": 404,
  "httpReason": "Not Found"
}

HTTP status codes

CodeMeaning
200Request succeeded
201Resource created
301 / 308Redirect — follow the Location header
400Bad request — invalid parameters
403Forbidden — insufficient permissions
404Not found — page or revision does not exist
409Conflict — edit conflict or page already exists
415Unsupported media type
429Too many requests — rate limit exceeded
500Internal server error

Rate limiting

The REST API enforces per-user rate limits consistent with the wiki’s configured throttle settings. When a limit is exceeded, the API returns HTTP 429 Too Many Requests. Clients should implement exponential backoff when they receive 429 responses.

CORS support

Cross-origin requests are supported for public wikis. The REST API sets appropriate Access-Control-Allow-Origin headers based on the wiki’s $wgCrossSiteAJAXdomains configuration. Requests that include credentials (cookies) require the Origin header to exactly match an allowed domain.

Caching

Read endpoints set Cache-Control headers. Clients and CDNs should respect these headers. ETags and Last-Modified headers are included on most read responses and can be used for conditional requests with If-None-Match and If-Modified-Since.

Endpoints

All routes listed below are served under /w/rest.php/v1/. Routes are defined in includes/Rest/coreRoutes.json.

Pages

MethodPathDescription
GET/v1/page/{title}Get latest revision wikitext source and metadata
GET/v1/page/{title}/bareGet page metadata with a link to the HTML representation
GET/v1/page/{title}/htmlGet the latest Parsoid HTML for a page
GET/v1/page/{title}/with_htmlGet page metadata combined with Parsoid HTML
GET/v1/page/{title}/historyList revisions of a page
GET/v1/page/{title}/history/counts/{type}Count revisions of a specific type
GET/v1/page/{title}/links/languageList interlanguage links
GET/v1/page/{title}/links/mediaList media files used on the page
GET/v1/page/{title}/lintGet lint errors for the page
PUT/v1/page/{title}Create or update a page
POST/v1/pageCreate a new page

Revisions

MethodPathDescription
GET/v1/revision/{id}Get revision wikitext source and metadata
GET/v1/revision/{id}/bareGet revision metadata with a link to the HTML representation
GET/v1/revision/{id}/htmlGet Parsoid HTML for a specific revision
GET/v1/revision/{id}/with_htmlGet revision metadata combined with Parsoid HTML
GET/v1/revision/{id}/lintGet lint errors for a specific revision
GET/v1/revision/{from}/compare/{to}Compare two revisions and return a diff
MethodPathDescription
GET/v1/search/pageFull-text search across page bodies and titles
GET/v1/search/titleTitle prefix completion search
GET/v1/searchOpenSearch description document

Files

MethodPathDescription
GET/v1/file/{title}Get metadata for a file (image, video, audio)

Transforms

MethodPathDescription
POST/v1/transform/wikitext/to/htmlConvert wikitext to Parsoid HTML
POST/v1/transform/wikitext/to/html/{title}Convert wikitext to HTML in the context of a page
POST/v1/transform/wikitext/to/html/{title}/{revision}Convert wikitext to HTML in the context of a specific revision
POST/v1/transform/html/to/wikitextConvert Parsoid HTML to wikitext
POST/v1/transform/html/to/wikitext/{title}Convert HTML to wikitext in page context
POST/v1/transform/html/to/wikitext/{title}/{revision}Convert HTML to wikitext in revision context
POST/v1/transform/wikitext/to/lintCheck wikitext for lint errors
POST/v1/transform/wikitext/to/lint/{title}Check wikitext for lint errors in page context
POST/v1/transform/wikitext/to/lint/{title}/{revision}Check wikitext for lint errors in revision context
For reading public wiki content, most endpoints do not require authentication. Authentication is required for write operations and for accessing restricted content.

Build docs developers (and LLMs) love