API:REST API/Get started
| MediaWiki REST API |
|---|
|
Get started Tutorials Reference Guides
|
This page helps you get started using the MediaWiki REST API to perform common types of operations.
Before you begin
[edit]Your use of the MediaWiki REST API must follow the access and usage policies.
Sample call
[edit]# Search English Wikipedia for an article about Earth $ curl "https://en.wikipedia.org/w/rest.php/v1/search/page?q=earth&limit=1"
Data formats
[edit]REST API endpoints return data in JSON or HTML format. See the API reference for the content type supported by each endpoint.
URL structure
[edit]API endpoints share a consistent URL structure that includes the wiki's base URL, the wiki's script path, and the API version:
# URL structure>
[project url]/[script 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
Use conditional requests to optimize API calls
[edit]See Wikimedia APIs/Conditional requests.
Make cross-origin requests
[edit]For instructions on how to use cross-origin resource sharing (CORS) requests in your JavaScript code to communicate between wikis on different domains, see Special:MyLanguage/Manual:CORS.