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.

acquiretempusername
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.
block
Zablokovat uživatele.
bs-adminuser-store
Lists all users from the database with additional sensitive data. Allows sorting, filtering and pagination. Implements ExtJS Store parameters.
bs-category-store
Lists all categories. Allows sorting, filtering and pagination. Implements ExtJS Store parameters.
bs-category-treestore
Lists the sub-categories of a specific category
bs-categorylinks-store
Lists all categories of a page, including a link to the category page and a marker for explicit and implicit categories.
bs-group-store
Lists all groups except $wgImplicitGroups. Allows sorting, filtering and pagination. Implements ExtJS Store parameters.
bs-interwiki-store
Lists all interwiki links. Allows sorting, filtering and pagination. Implements ExtJS Store parameters.
bs-js-var-config
Provides an API endpoint for retrieving client-side configuration variables
bs-linker
Returns links to pages generated by Linker
bs-ping-tasks
Ping task that provides continuous exchange of data
bs-recentchanges-store
Lists all recent changes. Allows sorting, filtering and pagination. Implements store parameters.
bs-task
Provides the API endpoint for executing registered tasks
bs-templatelinks-store
Lists all templates of a page, including a link to the template.
bs-titlequery-store
Lists page titles and (optionally) namespace prefixes based on a query term. Implements ExtJS Store parameters.
bs-upload-license-store
Lists all available licences for a file upload
bs-user-store
Lists all users from the database. Allows sorting, filtering and pagination. Implements ExtJS Store parameters.
bs-watchlist-store
Lists all watchlist entries. Allows sorting, filtering and pagination. Implements store parameters.
bs-wikipage-store
Lists all wiki pages. Allows sorting, filtering and pagination. Implements ExtJS Store parameters.
bs-wikipage-tasks
Provides common operations for WikiPages
bs-wikisubpage-treestore
Lists the subpages of a specific wikipage
cargoautocomplete
Autocompletion call used by the Cargo extension.
cargofields
Fetches all the fields in the specified table
cargoformatparams
Gets the set of display parameters for each Cargo query format.
cargoquery
Runs a query on the Cargo data.
cargoqueryautocomplete
Autocompletion call used by the CargoQuery (previously ViewData) special page.
cargorecreatedata
Re-populates the data in a Cargo table.
cargorecreatespecialtable
Creates a special Cargo table.
cargorecreatetables
Recreates one or more Cargo tables.
cargotables
Fetches all the tables in the system
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.
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.
discussiontoolsedit
Pridať správu na diskusnú stránku.
discussiontoolsfindcomment
Find a comment by its ID or name.
discussiontoolsgetsubscriptions
Získat stavy odběru daných témat.
discussiontoolssubscribe
Přihlášení (nebo odhlášení) příjmu oznámení o tématu.
echocreateevent
Manually trigger a notification to a user
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.
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.
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.
tag
Add or remove change tags from individual revisions or log entries.
templatedata
Fetch data stored by the TemplateData extension.
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.
webapp-manifest
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.
discussiontoolscompare
Internal. Získat informace o změnách komentářů mezi dvěma revizemi stránky.
discussiontoolspageinfo
Internal. Vrací metadata potřebná k inicializaci Diskusních nástrojů.
discussiontoolspreview
Internal. Náhled zprávy na stránce diskuse.
editcheckreferenceurl
Internal. Check the status of a URL for use as a reference.
oathvalidate
Internal. Validate a two-factor authentication (OATH) token.
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: acquiretempusername, block, bs-adminuser-store, bs-category-store, bs-category-treestore, bs-categorylinks-store, bs-group-store, bs-interwiki-store, bs-js-var-config, bs-linker, bs-ping-tasks, bs-recentchanges-store, bs-task, bs-templatelinks-store, bs-titlequery-store, bs-upload-license-store, bs-user-store, bs-watchlist-store, bs-wikipage-store, bs-wikipage-tasks, bs-wikisubpage-treestore, cargoautocomplete, cargofields, cargoformatparams, cargoquery, cargoqueryautocomplete, cargorecreatedata, cargorecreatespecialtable, cargorecreatetables, cargotables, changeauthenticationdata, changecontentmodel, checktoken, clearhasmsg, clientlogin, compare, createaccount, delete, discussiontoolsedit, discussiontoolsfindcomment, discussiontoolsgetsubscriptions, discussiontoolssubscribe, echocreateevent, echomarkread, echomarkseen, echomute, edit, emailuser, expandtemplates, feedcontributions, feedrecentchanges, feedwatchlist, filerevert, help, imagerotate, import, languagesearch, linkaccount, login, logout, managetags, mergehistory, move, opensearch, options, paraminfo, parse, patrol, protect, purge, query, removeauthenticationdata, resetpassword, revisiondelete, rollback, rsd, setnotificationtimestamp, setpagelanguage, tag, templatedata, transcodereset, unblock, undelete, unlinkaccount, upload, userrights, validatepassword, watch, webapp-manifest, categorytree, cspreport, discussiontoolscompare, discussiontoolspageinfo, discussiontoolspreview, editcheckreferenceurl, oathvalidate, 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
The value must be no less than 0.
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
The value must be no less than 0.
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 cokoli z: používateľské meno a Dočasný uživatel
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&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.

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í:
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 may 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 [email protected] nebo založte chybové hlášení na https://phabricator.wikimedia.org/.