Den här sidan ger en översikt av MediaWikis Action API.
Den här sidan är för tekniska bidragsgivare och mjukvaruutvecklare som vill förstå MediaWikis Action API.
To see the endpoint URL on a particular wiki, see section "Startpunkts-URL:er" on the Special:Version page.
Introduktion
MediaWikis Action API är en webb-service som tillåter tillgång till vissa wiki-funktioner som autentisering, sidoperationer, och sökning. Det kan ge metainformation om wikin och den inloggade användaren.
Användningsområden för MediaWiki Action API
Övervaka en MediaWiki installation
Skapa en bot för att underhålla en MediaWikiinstallation
Logga in i en wiki, komma åt data och publicera ändringar genom att göra förfrågningar till webbtjänsten
Komma igång med MediaWiki Action API
Innan du börjar använda MediaWiki Action API bör du granska följande sidor:
Alla policyer som gäller för den wiki du vill ha åtkomst till, exempelvis Wikimedia Foundation användarvillkor, varumärkespolicy. Dessa villkor gäller för dig när du öppnar eller redigerar med API:et, precis som de gör när du använder din webbläsare.
API-dokumentation
Följande dokumentation är utmatat från Special:ApiHelp/main, automatiskt genererad av tidiga versioner av MediaWiki som driver den här sajten (MediaWiki.org).
Status: The MediaWiki API is a mature and stable interface that is actively supported and improved. While we try to avoid it, we may occasionally need to make breaking changes; subscribe to the mediawiki-api-announce mailing list for notice of updates.
Erroneous requests: When erroneous requests are sent to the API, an HTTP header will be sent with the key "MediaWiki-API-Error" and then both the value of the header and the error code sent back will be set to the same value. For more information see API: Errors and warnings.
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
Default: 0
maxage
Set the max-age HTTP cache control header to this many seconds. Errors are never cached.
Type: integer
Default: 0
assert
Verify that the user is logged in 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 username
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 URI (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.
uselang
Language to use for message translations. action=query&meta=siteinfo with siprop=languages returns a list of language codes, or specify user to use the current user's language preference, or specify 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 with siprop=languages returns a list of language codes, or specify content to use this wiki's content language, or specify 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 10 seconds. This should be included in any pre-flight request, and therefore should be included in the request URI (not the POST body).
Use higher limits in API queries (slow queries: 500; fast queries: 5000). The limits for slow queries also apply to multivalue parameters.
Granted to: bot and sysop
Andra API:er
Om du inte hittar det du letar efter i denna API-dokumentation finns det många andra API:er relaterade till Wikimedia-projekt.
Se hubben för webb-API:er för information om andra API:er för Wikimedia -projektdata och deras användning.
För REST API som ingår i MediaWiki 1.35 och senare, se API:REST API.