API:REST API

The MediaWiki REST API lets you build apps and scripts that interact with wiki content. Like most web APIs, the MediaWiki REST API accepts HTTP requests at unique URLs and returns structured data.

Endpoints
Available in MediaWiki 1.35 and later:


 * History API: Explore page history, compare revisions.

Data format
The REST API returns all data as JSON.

Methods
The REST API supports standard HTTP request methods like GET, HEAD, POST, and DELETE.

URL structure
API endpoints share a consistent URL structure that includes the wiki's base URL, the wiki's install path, and the API version.

Versioning
Following semantic versioning principles, the API major version increments in the event of breaking changes: changes to an endpoint that are incompatible with the previous version, such as removing an endpoint or changing a request structure in a backwards-incompatible way. Parameters, response types, and response codes are guaranteed to be backwards compatible within a major version. The API minor version increments for backwards-compatible changes, such as adding an endpoint or adding an attribute to a response body. The major version is included in the API path (for example: ); the minor version is listed in the documentation only.

Accessing Wikimedia projects using the REST API
You can use the REST API to access Wikipedia, Wiktionary, and other Wikimedia projects in multiple languages. For a complete list of Wikimedia project URLs, see Meta-Wiki’s site matrix.

Request limit
There is no fixed limit on requests to the API, but your client may be blocked if you endanger the stability of a site. To stay within a safe request rate, make requests in series instead of in parallel by waiting for one request to finish before sending a new request.

Client identification
Wikimedia sites require an HTTP User-Agent header for all API requests. This helps identify your app and ensures that system administrators can contact you if a problem arises. Clients making requests without a User-Agent header may be IP-blocked without notice.

The preferred format for a User-Agent header is. Contact information can include a user page on the local wiki, a user page on a related wiki using interwiki linking syntax, a URL for a relevant external website, or an email address. For example, to set a User-Agent header in PHP:

If you are calling the API from browser-based JavaScript, you may not be able to influence the User-Agent header, depending on the browser. To work around this, use the   header. See Meta-Wiki’s User-Agent policy for more information.

Authorization
To authorize your app to act on behalf of a user, follow the OAuth developer guide to register your app and make requests using OAuth 1.0 tokens and secrets.

Licensing and trademarks
Wikimedia content is free to reuse within the terms specified by the applicable license. Licenses can differ between projects, so see the individual project for information about licenses and content reuse. For example, English Wikipedia’s text can be used under the terms of the Creative Commons Attribution Share-Alike license, while media files on Wikimedia Commons are licensed individually as indicated on the file’s information page. For more information about licensing and trademark use, see Meta-Wiki’s developer app guidelines.

Enabling the REST API on your wiki
The REST API is available in MediaWiki 1.34 and later as disabled by default. To enable the REST API on your wiki, add  to.

Extension endpoints
MediaWiki extensions can surface extension-specific API endpoints using the REST API interface. See the REST API extension interface docs to get started. For documentation for REST API endpoints provided by extensions, see the extension docs. The REST API extension interface is available in MediaWiki 1.34 and later.

Other APIs
There are two families of REST APIs related to Wikimedia projects: the MediaWiki REST API described on this page and the REST API built on RESTBase. While the MediaWiki REST API is part of the MediaWiki platform and can be enabled on any wiki running MediaWiki 1.34 or later, the RESTBase API serves content specific to Wikimedia projects. If you're looking for the full-featured, RPC-style MediaWiki API, see the Action API.