|This page is part of the MediaWiki REST API documentation.|
|MediaWiki REST API|
Available in MediaWiki 1.35 and later:
- History: Explore page history, compare revisions.
The REST API returns all data as JSON.
The REST API supports standard HTTP request methods like GET, HEAD, POST, and DELETE.
API endpoints share a consistent URL structure that includes the wiki's base URL, the wiki's install path, and the API version.
# URL structure [project url]/[install path]/rest.php/v[version number]/ # Example URL: Get the history of the Main Page of English Wikipedia https://en.wikipedia.org/w/rest.php/v1/page/Main_Page/history
Designed to provide long-term stability for developers, the MediaWiki REST API is versioned using a global version number in the API path (for example:
Following the principles of semantic versioning, the version is incremented when an endpoint is changed in a backwards-incompatible way, such as removing a response property or adding a required parameter.
Within a major version, the API may change in backwards-compatible ways, such as adding a response property or optional request parameter.
||Available in MediaWiki 1.35|
Accessing Wikimedia projects using the REST API
|Get the history of the main page of Spanish Wikipedia|
|Get the number of revisions to the main page of Vietnamese Wiktionary|
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.
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
<client name>/<version> (<contact information>) <library/framework name>/<version>.
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:
ini_set('user_agent', 'MyCoolTool/1.1 (https://example.org/MyCoolTool/; MyCoolTool@example.org) UsedBaseLibrary/1.4');
To work around this, use the
See Meta-Wiki’s User-Agent policy for more information.
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 tokens.
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
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.
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.