|This page is part of the MediaWiki Action API documentation.|
This page provides answers to some frequently asked questions about the MediaWiki Action API.
Also read the API:Main page. It answers some questions not answered here and points to other useful pages.
What is an API?Edit
An API is an acronym for Application Programming Interface. It allows different applications to communicate with each other. In general terms, it refers to web-based APIs, which use HTTP requests-response mechanism and produce JSON/XML structured data.
What is a REST API?Edit
REST is an acronym for REpresentational State Transfer. A set of guiding principles or constraints define a RESTful system. A RESTful API or just, a REST API adheres to these principles and hence is a faster, more reliable and scalable service.
What can an API do?Edit
See some uses of API.
Where can I learn more about APIs?Edit
Here are a few resources:
What is the MediaWiki Action API?Edit
What can the MediaWiki Action API be used for?Edit
The MediaWiki Action API can be used to:
- access wiki features.
- interact with a wiki.
- obtain meta-information about wikis and public users.
The right sidebar points to many features supported by the API. Also, see some Wikimedia projects that use the MediaWiki Action API.
How can I use (or call) the MediaWiki Action API?Edit
To play with the Action API:
- Use the Special:ApiSandbox.
- Enable your browser's developer console and watch net requests to
api.phpas you interact with the wiki.
What is a module, a submodule, and a parameter?Edit
The MediaWiki Action API has numerous modules that we use to perform different tasks. In technical terms, a module is a subclass of ApiBase. A module requires parameters. These parameters may (or may not) be submodules.
Consider the following request:
actionis a parameter of the main module.
action=queryis another module. It is called the query module.
listis a parameter of the query module.
list=searchis also a module. It can be called a submodule of
srsearchis a parameter of the search module. It holds the search string 'abc'.
formatis a parameter of the main module.
jsonis the output format.
How do I know which module and submodule to call?Edit
The MediaWiki Action API is big, and extensions further enlarge it. Here are a few ways to work out your API request:
- In the sidebar, look for the feature you wish to implement and follow the link for information about which modules to call.
- The self-documenting API pages contain a list of all modules and submodules with brief descriptions. You can start at the main module and follow the links to different submodules. (Append
recursivesubmodules=1to view the expanded version)
Where can I find sample codes for using the API modules?Edit
How can I control the output format?Edit
In older versions, to control the output format, you can pass
&format=someformat in the query string.
For information, see API:Data_formats.
Do I need an access token?Edit
You will require an access token to perform data modifying actions like logging in, editing, moving pages, etc.
How can I make cross-site requests using the API?Edit
For details, see API:Cross-site_requests.
Is there a limit to query results?Edit
Yes, it depends on the query parameter. For example, the results for
property queries cannot exceed 500 for regular users.
The API pages contain information about these limits in the 'Additional notes' section or the 'Limits' section. Note that some modules impose stricter limits under certain conditions.
If you are unsure about what limit to set and just want as many results as possible, set the limit to
Is there a limit to API calls?Edit
There is no concrete limit. Yet, we recommend making a reasonable number of calls to prevent getting blocked. If you want to make many requests, contact the administrators beforehand.
Also, see API:Etiquette.
Where can I get updates about the MediaWiki Action API?Edit
You can subscribe to the MediaWiki-API-Announce mailing list for announcements and updates.
What are wiki dumps and how can I work with them?Edit
Where can I get more help?Edit
Extension developers and wiki ownersEdit
How can I create an API module in an extension?Edit
API:Extensions will walk you through the complete process of creating an API module in an extension.
What is the internal structure of the API?Edit
How can I restrict the API usage?Edit
To restrict the API usage, you can either restrict the use of write API or disable individual modules.
For instructions and examples, see API:Restricting_API_usage.
How can I allow/restrict users from modifying the wiki content using the API?Edit
In MediaWiki 1.14, users are allowed to modify the wiki content by default. To restrict, you have to set
$wgEnableWriteAPI = false; in LocalSettings.php.
In MediaWiki 1.13 or earlier, you have to enable the write API with
$wgEnableWriteAPI = true; to allow content modification.
For more information, see API:Changing_wiki_content.
Errors and troubleshootingEdit
How do I detect an error?Edit
If you encounter an error, the error response from the API will set the
MediaWiki-API-Error HTTP header and return an error structure.
What does this error mean?Edit
Find your error in the list of standard error messages to understand what the error means.
How do I file a bug/feature requests?Edit
You can report bugs and file feature requests on Wikimedia's task tracking tool, Phabricator.
- Add the MediaWiki-API project tag to your task.
- If your report/request is offered by an extension, add that extension's project. (e.g. MediaWiki-extensions-AbuseFilter, MediaWiki-extensions-FlaggedRevs, etc.)
- Verify for duplicates before creating a new task.
- Understand the task creation terms on Phabricator before proceeding.
See How to report a bug for more details.
Am I facing errors due to my API version?Edit
If a website runs a different version of MediaWiki, it would also run a different version of the API. Some module parameters supported in one version might be deprecated (or removed) in others. Such parameters will throw an exception if used. The API pages document any such deprecations.
See the release notes for information regarding different API versions.
|This page or project is maintained by Core Platform Team.