Nápověda k MediaWiki API

Toto je automaticky generovaná dokumentační stránka k MediaWiki API.

Dokumentace a příklady: https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page

Hlavní modul

Stav: Všechny funkce uvedené na této stránce by měly fungovat, ale API se stále aktivně vyvíjí a může se kdykoli změnit. Upozornění na změny získáte přihlášením se k e-mailové konferenci mediawiki-api-announce.

Chybné požadavky: Pokud jsou do API zaslány chybné požadavky, bude vrácena HTTP hlavička s klíčem „MediaWiki-API-Error“ a hodnota této hlavičky a chybový kód budou nastaveny na stejnou hodnotu. Více informací najdete v dokumentaci.

Parametry:
action

Která akce se má provést.

abusefiltercheckmatch
Check to see if an AbuseFilter matches a set of variables, an edit, or a logged AbuseFilter event.
abusefilterchecksyntax
Zkontroluje syntaxi filtru zneužití.
abusefilterevalexpression
Vyhodnotí výraz filtru zneužití.
abusefilterunblockautopromote
Unblocks a user from receiving autopromotions due to an abusefilter consequence.
abuselogprivatedetails
View private details of an AbuseLog entry.
block
Zablokovat uživatele.
changeauthenticationdata
Change authentication data for the current user.
changecontentmodel
Change the content model of a page
checktoken
Check the validity of a token from action=query&meta=tokens.
cirrus-config-dump
Dump of CirrusSearch configuration.
cirrus-mapping-dump
Dump of CirrusSearch mapping for this wiki.
cirrus-profiles-dump
Dump of CirrusSearch profiles for this wiki.
cirrus-settings-dump
Dump of CirrusSearch settings for this wiki.
clearhasmsg
Clears the hasmsg flag for the current user.
clientlogin
Log in to the wiki using the interactive flow.
compare
Vrátí rozdíl dvou stránek.
createaccount
Vytvořit nový uživatelský účet.
delete
Smazat stránku.
echomarkread
Mark notifications as read for the current user.
echomarkseen
Mark notifications as seen for the current user.
echomute
Mute or unmute notifications from certain users or pages.
edit
Vytvářet a upravovat stránky.
emailuser
Poslat uživateli e-mail.
expandtemplates
Rozbalí všechny šablony ve wikitextu.
feedcontributions
Vrátí kanál příspěvků uživatele.
feedrecentchanges
Returns a recent changes feed.
feedwatchlist
Returns a watchlist feed.
filerevert
Revertovat soubor na starší verzi.
graph
Access graph tag functionality.
help
Zobrazuje nápovědu k uvedeným modulům.
imagerotate
Otočit jeden nebo více obrázků.
import
Import a page from another wiki, or from an XML file.
jsonconfig
Allows direct access to JsonConfig subsystem.
languagesearch
Search for language names in any script.
linkaccount
Link an account from a third-party provider to the current user.
login
Log in and get authentication cookies.
logout
Log out and clear session data.
managetags
Perform management tasks relating to change tags.
mergehistory
Merge page histories.
move
Přesunout stránku.
opensearch
Vyhledávání na wiki pomocí protokolu OpenSearch.
options
Change preferences of the current user.
paraminfo
Obtain information about API modules.
parse
Parses content and returns parser output.
patrol
Patrol a page or revision.
protect
Změnit úroveň zamčení stránky.
purge
Purge the cache for the given titles.
query
Fetch data from and about MediaWiki.
removeauthenticationdata
Remove authentication data for the current user.
resetpassword
Send a password reset email to a user.
revisiondelete
Delete and undelete revisions.
rollback
Undo the last edit to the page.
rsd
Export an RSD (Really Simple Discovery) schema.
setnotificationtimestamp
Update the notification timestamp for watched pages.
setpagelanguage
Change the language of a page.
spamblacklist
Validate one or more URLs against the spam block list.
tag
Add or remove change tags from individual revisions or log entries.
templatedata
Fetch data stored by the TemplateData extension.
thank
Send a thank-you notification to an editor.
titleblacklist
Validate a page title, filename, or username against the TitleBlacklist.
transcodereset
Users with the 'transcode-reset' right can reset and re-run a transcode job.
unblock
Unblock a user.
undelete
Undelete revisions of a deleted page.
unlinkaccount
Remove a linked third-party account from the current user.
upload
Upload a file, or get the status of pending uploads.
userrights
Change a user's group membership.
validatepassword
Validate a password against the wiki's password policies.
watch
Add or remove pages from the current user's watchlist.
categorytree
Internal. Internal module for the CategoryTree extension.
cspreport
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.
scribunto-console
Internal. Internal module for servicing XHR requests from the Scribunto console.
stashedit
Internal. Prepare an edit in shared cache.
timedtext
Internal. Provides timed text content for usage by <track> elements
ulslocalization
Internal. Get the localization of ULS in the given language.
ulssetlang
Internal. Update user's preferred interface language.
visualeditor
Internal. Returns HTML5 for a page from the Parsoid service.
visualeditoredit
Internal. Save an HTML5 page to MediaWiki (converted to wikitext via the Parsoid service).
Jedna z následujících hodnot: abusefiltercheckmatch, abusefilterchecksyntax, abusefilterevalexpression, abusefilterunblockautopromote, abuselogprivatedetails, block, changeauthenticationdata, changecontentmodel, checktoken, cirrus-config-dump, cirrus-mapping-dump, cirrus-profiles-dump, cirrus-settings-dump, clearhasmsg, clientlogin, compare, createaccount, delete, echomarkread, echomarkseen, echomute, edit, emailuser, expandtemplates, feedcontributions, feedrecentchanges, feedwatchlist, filerevert, graph, help, imagerotate, import, jsonconfig, languagesearch, linkaccount, login, logout, managetags, mergehistory, move, opensearch, options, paraminfo, parse, patrol, protect, purge, query, removeauthenticationdata, resetpassword, revisiondelete, rollback, rsd, setnotificationtimestamp, setpagelanguage, spamblacklist, tag, templatedata, thank, titleblacklist, transcodereset, unblock, undelete, unlinkaccount, upload, userrights, validatepassword, watch, categorytree, cspreport, scribunto-console, stashedit, timedtext, ulslocalization, ulssetlang, visualeditor, visualeditoredit
Default: help
format

Formát výstupu.

json
Vypisuje data ve formátu JSON.
jsonfm
Vypisuje data ve formátu JSON (v čitelné HTML podobě).
none
Nevypisuje nic.
php
Vypisuje data v serializačním formátu PHP.
phpfm
Vypisuje data v serializačním formátu PHP (v čitelné HTML podobě).
rawfm
Data včetně ladicích prvků vypisuje ve formátu JSON (v čitelné HTML podobě).
xml
Vypisuje data ve formátu XML.
xmlfm
Vypisuje data ve formátu XML (v čitelné HTML podobě).
Jedna z následujících hodnot: json, jsonfm, none, php, phpfm, rawfm, xml, xmlfm
Default: jsonfm
maxlag

Maximální zpoždění lze použít, když je MediaWiki nainstalováno na cluster s replikovanou databází. Abyste se vyhnuli zhoršování už tak špatného replikačního zpoždění, můžete tímto parametrem nechat klienta čekat, dokud replikační zpoždění neklesne pod uvedenou hodnotu. V případě příliš vysokého zpoždění se vrátí chybový kód „maxlag“ s hlášením typu „Waiting for $host: $lag seconds lagged“.
Více informací najdete v příručce.

Type: integer
smaxage

Nastaví HTTP hlavičku pro řízení kešování s-maxage na uvedený počet sekund. Chyby se nekešují nikdy.

Type: integer
Default: 0
maxage

Nastaví HTTP hlavičku pro řízení kešování max-age na uvedený počet sekund. Chyby se nekešují nikdy.

Type: integer
Default: 0
assert

Pokud je nastaveno na „user“, ověří, že je uživatel přihlášen, pokud je nastaveno na „bot“, ověří, že má oprávnění „bot“.

Jedna z následujících hodnot: anon, bot, user
assertuser

Ověřit, že současným uživatelem je uvedený uživatel.

Typ: uživatel, uvedený jako uživatelské jméno
requestid

Libovolná zde uvedená hodnota bude zahrnuta v odpovědi. Lze použít pro rozlišení požadavků.

servedby

Zahrnout do odpovědi název hostitele, který požadavek obsloužil.

Type: boolean (details)
curtimestamp

Zahrnout do odpovědi aktuální časové razítko.

Type: boolean (details)
responselanginfo

Include the languages used for uselang and errorlang in the result.

Type: boolean (details)
origin

Pokud k API přistupujete pomocí mezidoménového AJAXového požadavku (CORS), nastavte tento parametr na doménu původu. Musí být součástí všech předběžných požadavků, takže musí být součástí URI požadavku (nikoli těla POSTu).

U autentizovaných požadavků hodnota musí přesně odpovídat jednomu z původů v hlavičce Origin, takže musí být nastavena na něco jako https://en.wikipedia.org nebo https://meta.wikimedia.org. Pokud parametr neodpovídá hlavičce Origin, bude vrácena odpověď 403. Pokud parametr odpovídá hlavičce Origin a tento původ je na bílé listině, budou nastaveny hlavičky Access-Control-Allow-Origin a Access-Control-Allow-Credentials.

U neautentizovaných požadavků uveďte hodnotu *. To způsobí nastavení hlavičky Access-Control-Allow-Origin, ale hlavička Access-Control-Allow-Credentials bude false a budou omezena všechna data specifická pro uživatele.

uselang

Jazyk, který se má použít pro překlad hlášení. Pomocí action=query&meta=siteinfo se siprop=languages získáte seznam jazykových kódů nebo zadejte „user“ pro použití předvoleného jazyka aktuálního uživatele či „content“ pro použití jazyka obsahu této wiki.

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.
Jedna z následujících hodnot: 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.

Type: boolean (details)
Příklady:
Nápověda k hlavnímu modulu
api.php?action=help [otevřít v pískovišti]
Veškerá nápověda na jedné stránce
api.php?action=help&recursivesubmodules=1 [otevřít v pískovišti]
Oprávnění:
writeapi
Používání zapisovacího API
Uděleno skupinám: all, user a bot
apihighlimits
Používání vyšších limitů v API dotazech (pomalé dotazy: 500, rychlé dotazy: 5000). Limity pro pomalé dotazy se vztahují i na vícehodnotové parametry.
Uděleno skupinám: bot a sysop

Datové typy

Input to MediaWiki should be NFC-normalized UTF-8. MediaWiki may attempt to convert other input, but this may cause some operations (such as edits with MD5 checks) to fail.

Parameters that take multiple values are normally submitted with the values separated using the pipe character, e.g. param=value1|value2 or param=value1%7Cvalue2. If a value must contain the pipe character, use U+001F (Unit Separator) as the separator and prefix the value with U+001F, e.g. param=%1Fvalue1%1Fvalue2.

Some parameter types in API requests need further explanation:

boolean

Boolean parameters work like HTML checkboxes: if the parameter is specified, regardless of value, it is considered true. For a false value, omit the parameter entirely.

expiry

Expiry values be relative (e.g. 5 months or 2 weeks) or absolute (e.g. 2014-09-18T12:34:56Z). For no expiry, use infinite, indefinite, infinity or never.

timestamp

Timestamps may be specified in several formats, see the Timestamp library input formats documented on mediawiki.org for details. ISO 8601 date and time is recommended: 2001-01-15T14:56:00Z. Additionally, the string now may be used to specify the current timestamp.

Šablonované parametry

Šablonované parametry umožňují situace, kdy modul API potřebuje hodnotu pro každou hodnotu nějakého jiného parametru. Pokud by například existoval modul API pro získání ovoce, mohl by mít parametr ovoce, kterým se určí požadované druhy ovoce, a šablonovaný parametr {ovoce}-počet, kterým se určí požadované počty jednotlivých druhů. Klient API, který by chtěl 1 jablko, 5 banánů a 20 jahod, by mohl vytvořit požadavek ovoce=jablka|banány|jahody&jablka-počet=1&banány-počet=5&jahody-počet=20.

Zásluhy

Vývojáři API:

  • Jurij Astrachan (tvůrce, hlavní vývojář září 2006 – září 2007)
  • Roan Kattouw (hlavní vývojář září 2007–2009)
  • Viktor Vasiljev
  • Bryan Tong Minh
  • Sam Reed
  • Brad Jorsch (hlavní vývojář 2013–2020)

Své komentáře, návrhy či dotazy posílejte na mediawiki-api@lists.wikimedia.org nebo založte chybové hlášení na https://phabricator.wikimedia.org/.