Aquesta pàgina proporciona una visió general de l'API Acció de MediaWiki.
Aquesta pàgina està pensada per a col·laboradors tècnics i desenvolupadors de programari que volen entendre i utilitzar l'API Acció de MediaWiki.
L'API Acció de MediaWiki és un servei web que permet l'accés a algunes funcionalitats wiki com l'autenticació, les operacions en pàgines i la recerca. Pot proporcionar metainformació sobre la wiki i l'usuari connectat.
Usos de l'API Acció de MediaWiki
Monitoritzar una instal·lació de MediaWiki
Crear un bot per mantenir una instal·lació de MediaWiki.
Iniciar la sessió en una wiki, accedir a dades i publicar canvis mitjançant peticions HTTP al servei web
Primers passos a l'API Acció de MediaWiki
Abans de començar a utilitzar l'API Acció de MediaWiki, hauries de revisar les següents pàgines:
Any policies that apply to the wiki you want to access, such as Wikimedia Foundation wikis' terms of use, trademark policy.
These terms apply to you when you access or edit using the API, just as they do when you use your web browser.
API documentation
The following documentation is the output of Special:ApiHelp/main, automatically generated by the pre-release version of MediaWiki that is running on this site (MediaWiki.org).
Specify the action to perform, the format of the response, and options that apply to all API modules.
Specific parameters:
action
Which action to perform. This parameter should be sent as part of the request URL (not the POST body) for ease of use in debugging, analytics, and request routing or filtering.
Acquire a temporary user username and stash it in the current session, if temp account creation is enabled and the current user is logged out. If a name has already been stashed, returns the same name.
Mark a translatable page as discouraged or not discouraged. Discouraged pages are hidden from the translation interface when searching for pages to translate, but can still be translated directly.
Internal. Retrieve current count of how many unique Chart page usages there are. Multiple uses of the same chart on the same page are considered a single use.
Internal. Used by browsers to report violations of the Content Security Policy. This module should never be used, except when used automatically by a CSP compliant web browser.
Maximum lag can be used when MediaWiki is installed on a database replicated cluster. To save actions causing any more site replication lag, this parameter can make the client wait until the replication lag is less than the specified value. In case of excessive lag, error code maxlag is returned with a message like Waiting for $host: $lag seconds lagged. See Manual: Maxlag parameter for more information.
Type: integer
smaxage
Set the s-maxage HTTP cache control header to this many seconds. Errors are never cached.
Type: integer
The value must be no less than 0.
Default: 0
maxage
Set the max-age HTTP cache control header to this many seconds. Errors are never cached.
Type: integer
The value must be no less than 0.
Default: 0
assert
Verify that the user is logged in (including possibly as a temporary user) if set to user, not logged in if set to anon, or has the bot user right if bot.
One of the following values: anon, bot, user
assertuser
Verify the current user is the named user.
Type: user, by any of username and Temporary user
requestid
Any value given here will be included in the response. May be used to distinguish requests.
servedby
Include the hostname that served the request in the results.
When accessing the API using a cross-domain AJAX request (CORS), set this to the originating domain. This must be included in any pre-flight request, and therefore must be part of the request URL (not the POST body).
For authenticated requests, this must match one of the origins in the Origin header exactly, so it has to be set to something like https://en.wikipedia.org or https://meta.wikimedia.org. If this parameter does not match the Origin header, a 403 response will be returned. If this parameter matches the Origin header and the origin is allowed, the Access-Control-Allow-Origin and Access-Control-Allow-Credentials headers will be set.
For non-authenticated requests, specify the value *. This will cause the Access-Control-Allow-Origin header to be set, but Access-Control-Allow-Credentials will be false and all user-specific data will be restricted.
crossorigin
When accessing the API using a cross-domain AJAX request (CORS) and using a session provider that is safe against cross-site request forgery (CSRF) attacks (such as OAuth), use this instead of origin=* to make the request authenticated (i.e., not logged out). This must be included in any pre-flight request, and therefore must be part of the request URL (not the POST body).
Note that most session providers, including standard cookie-based sessions, do not support authenticated CORS and cannot be used with this parameter.
Language to use for message translations. action=query&meta=siteinfo&siprop=languages returns a list of language codes. You can specify user to use the current user's language preference or content to use this wiki's content language.
Default: user
variant
Variant of the language. Only works if the base language supports variant conversion.
errorformat
Format to use for warning and error text output
plaintext
Wikitext with HTML tags removed and entities replaced.
wikitext
Unparsed wikitext.
html
HTML
raw
Message key and parameters.
none
No text output, only the error codes.
bc
Format used prior to MediaWiki 1.29. errorlang and errorsuselocal are ignored.
One of the following values: bc, html, none, plaintext, raw, wikitext
Default: bc
errorlang
Language to use for warnings and errors. action=query&meta=siteinfo&siprop=languages returns a list of language codes. Specify content to use this wiki's content language or uselang to use the same value as the uselang parameter.
Default: uselang
errorsuselocal
If given, error texts will use locally-customized messages from the MediaWiki namespace.
When accessing the API using a cross-domain AJAX request (CORS), use this to authenticate as the current SUL user. Use action=centralauthtoken on this wiki to retrieve the token, before making the CORS request. Each token may only be used once, and expires after 60 seconds. This should be included in any pre-flight request, and therefore should be included in the request URI (not the POST body).
On this wiki the expected value is a JSON Web Token, which may be validated by proxy servers in front of MediaWiki. If the token has expired or is otherwise invalid, you may receive a HTTP error from a proxy in a different format than a normal API error.
If you do not find what you are looking for in this API documentation, there are many other APIs related to Wikimedia projects.See the Web APIs hub for information on other APIs for Wikimedia project data and their usage.
For the REST API included with MediaWiki 1.35 and later, see API:REST API.