Tato technická příručka je určena pro vývojáře a technické přispěvatele. Pro běžné čtenáře MediaWiki může být obtížné jí porozumět. Obecné pokyny k používání MediaWiki naleznete vpříručce MediaWiki.
Tato stránka poskytuje souhrnný přehled o akcích, se kterými pracuje MediaWikiAction API, reprezentovaný koncovým bodemapi.php.Je určena vývojářům a všem, kteří si přejí pochopit fungování MediaWiki Action API a naučit se jej používat.
Rychlé seznámení
Získejte obsah článku na anglické Wikipedii v HTML:
Chcete-li zobrazit adresu URL koncového bodu na konkrétní wiki, podívejte se na sekci "URL vstupních bodů" na stránce Special:Version.
Úvod
MediaWiki Action API jewebová služba, která nabízí akce, přes které lze pracovat s obsahem wiki strojově zpracovatelným způsobem. API umožňuje ověření uživatele, operace se stránkami, vyhledávání aj. Může také poskytovatmeta informace o wiki a přihlášeném uživateli.
Veškerá pravidla týkají se wiki, ke které chcete přistupovat. Takže pro wiki, které spravuje Wikimedia Foundation to jsoupodmínky užití apravidla pro ochranné známky. Pokud přistupujete na stránky nebo je upravujete přes API, vztahují se na vás tyto podmínky úplně stejně, jako kdybyste k tomu používali váš webový prohlížeč.
Dokumentace API
Následující dokumentace je výstupemSpecial:ApiHelp/main, automaticky generovaným pre-release verzí MediaWiki, která je spuštěna na tomto webu (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 tothe 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 seeAPI: Errors and warnings.
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.
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 codemaxlag is returned with a message likeWaiting for $host: $lag seconds lagged. SeeManual: Maxlag parameter for more information.
Type: integer
smaxage
Set thes-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 themax-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 touser,not logged in if set toanon, or has the bot user right ifbot.
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 URI (not the POST body).
For authenticated requests, this must match one of the origins in theOrigin header exactly, so it has to be set to something likehttps://en.wikipedia.org orhttps://meta.wikimedia.org. If this parameter does not match theOrigin header, a 403 response will be returned. If this parameter matches theOrigin header and the origin is allowed, theAccess-Control-Allow-Origin andAccess-Control-Allow-Credentials headers will be set.
For non-authenticated requests, specify the value*. This will cause theAccess-Control-Allow-Origin header to be set, butAccess-Control-Allow-Credentials will befalse 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 oforigin=* 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 URI (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 specifyuser to use the current user's language preference orcontent 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 anderrorsuselocal 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. Specifycontent to use this wiki's content language oruselang to use the same value as theuselang 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. Useaction=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).