Даведка MediaWiki API

This is an auto-generated MediaWiki API documentation page.

Documentation and examples: https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page

Main module

Статус: MediaWiki API — сфармаваны і стабільны інтэрфэйс, які актыўна падтрымліваецца і паляпшаецца. І хаця мы імкнемся гэтага пазьбягаць, але часам нам трэба ўносіць істотныя зьмены; падпісвайцеся на рассылку mediawiki-api-announce дзеля паведамленьняў пра абнаўленьні.

Памылковыя запыты: калі да API дасылаюцца памылковыя запыты, HTTP-загаловак будзе дасланы з ключом «MediaWiki-API-Error», а потым значэньне загалоўку і код памылкі будуць выстаўленыя на аднолькавае значэньне. Дзеля дадатковай інфармацыі глядзіце API: Памылкі і папярэджаньні.

Specific parameters:
action

Дзеяньне для выкананьня.

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
Блякаваньне ўдзельніка.
changeauthenticationdata
Зьмена зьвестак аўтэнтыфікацыі для цяперашняга ўдзельніка.
changecontentmodel
Change the content model of a page
checktoken
Праверыць карэктнасьць токену з action=query&meta=tokens.
clearhasmsg
Ачышчае сьцяг hasmsg для актуальнага карыстальніка.
clientlogin
Увайсьці ў вікі з дапамогай інтэрактыўнага струменя.
compare
Атрымаць розьніцу паміж 2 старонкамі.
createaccount
Стварэньне новага рахунку ўдзельніка.
cxdelete
Delete a draft translation created using the Content Translation extension.
cxtoken
Get JWT tokens to authenticate with cxserver.
delete
Выдаліць старонку.
edit
Ствараць і правіць старонкі.
emailuser
Email a user.
expandtemplates
Expands all templates within wikitext.
feedcontributions
Returns a user's contributions feed.
feedrecentchanges
Returns a recent changes feed.
feedwatchlist
Returns a watchlist feed.
filerevert
Revert a file to an old version.
globalpreferenceoverrides
Change local overrides for global preferences for the current user.
globalpreferences
Change global preferences of the current user.
help
Display help for the specified modules.
imagerotate
Rotate one or more images.
import
Import a page from another wiki, or from an XML file.
languagesearch
Пошук назваў моваў любым альфабэтам.
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
Перанесьці старонку
opensearch
Search the wiki using the OpenSearch protocol.
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
Change the protection level of a page.
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.
sxdelete
Delete the draft section translation and its parallel corpora from database.
tag
Add or remove change tags from individual revisions or log entries.
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
Вяртае маніфест вэб-прыкладання.
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.
cxcheckunreviewed
Internal. Check if any fast, unreviewed translation has been published recently for the current user.
cxfavoritesuggestions
Internal. Add or remove a favorite suggestion to the current user's list.
cxpublish
Internal. Захавайце старонку, створаную з дапамогай пашырэння Content Translation.
cxpublishsection
Internal. Save a section created using the Content Translation extension's section translation feature.
cxsave
Internal. This module allows to save draft translations by section to save bandwidth and to collect parallel corpora.
cxsplit
Internal. Create and save a section translation to database, for every translated section of the given article translation
editcheckreferenceurl
Internal. Check the status of a URL for use as a reference.
stashedit
Internal. Prepare an edit in shared cache.
sxsave
Internal. Save the draft section translation and store the parallel corpora
ulslocalization
Internal. Атрымаць лякалізацыю ULS на пададзенай мове.
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).
One of the following values: acquiretempusername, block, changeauthenticationdata, changecontentmodel, checktoken, clearhasmsg, clientlogin, compare, createaccount, cxdelete, cxtoken, delete, edit, emailuser, expandtemplates, feedcontributions, feedrecentchanges, feedwatchlist, filerevert, globalpreferenceoverrides, globalpreferences, 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, sxdelete, tag, unblock, undelete, unlinkaccount, upload, userrights, validatepassword, watch, webapp-manifest, cspreport, cxcheckunreviewed, cxfavoritesuggestions, cxpublish, cxpublishsection, cxsave, cxsplit, editcheckreferenceurl, stashedit, sxsave, ulslocalization, ulssetlang, visualeditor, visualeditoredit
Default: help
format

Фармат вываду.

json
Output data in JSON format.
jsonfm
Output data in JSON format (pretty-print in HTML).
none
Output nothing.
php
Output data in serialized PHP format.
phpfm
Output data in serialized PHP format (pretty-print in HTML).
rawfm
Output data, including debugging elements, in JSON format (pretty-print in HTML).
xml
Output data in XML format.
xmlfm
Output data in XML format (pretty-print in HTML).
One of the following values: json, jsonfm, none, php, phpfm, rawfm, xml, xmlfm
Default: jsonfm
maxlag

Максымальная затрымка можа ўжывацца, калі MediaWiki ўсталяваная ў клястэр з рэплікаванай базай зьвестак. Дзеля захаваньня дзеяньняў, якія выклікаюць затрымку рэплікацыі, гэты парамэтар можа прымусіць кліента чакаць, пакуль затрымка рэплікацыі меншая за яго значэньне. У выпадку доўгай затрымкі, вяртаецца код памылкі maxlag з паведамленьнем кшталту Чаканьне $host: $lag сэкундаў затрымкі.
Глядзіце Інструкцыя:Парамэтар maxlag дзеля дадатковай інфармацыі.

Type: integer
smaxage

Выстаўце HTTP-загаловак кантролю кэшу s-maxage на зададзеную колькасьць сэкундаў. Памылкі ніколі не кэшуюцца.

Type: integer
The value must be no less than 0.
Default: 0
maxage

Выстаўляе HTTP-загаловак кантролю кэшу max-age на зададзеную колькасьць сэкундаў. Памылкі ніколі не кэшуюцца.

Type: integer
The value must be no less than 0.
Default: 0
assert

Упэўніцеся, што ўдзельнік увайшоў у сыстэму (магчыма, як часовы карыстальнік), калі зададзена user, не ўвайшоў, калі зададзена anon, або мае правы робата, калі зададзена bot.

One of the following values: anon, bot, user
assertuser

Праверыць, што імя цяперашняга ўдзельніка супадае з зададзеным.

Тып: карыстач, любым з імя карыстача і Часовы ўдзельнік
requestid

Любое значэньне, пададзенае тут, будзе ўключанае ў адказ. Можа быць выкарыстанае для адрозьненьня запытаў.

servedby

Уключае ў вынік назву сэрвэра, які апрацаваў запыт.

Type: boolean (details)
curtimestamp

Уключае ў вынік пазнаку актуальнага часу.

Type: boolean (details)
responselanginfo

Уключыць мовы, выкарыстаныя для uselang і errorlang, у вынік.

Type: boolean (details)
origin

Пры звароце да API з дапамогай міждамэннага AJAX-запыту (CORS), выстаўце парамэтру значэньне зыходнага дамэну. Ён мусіць быць уключаны ў кожны папярэдні запыт і такім чынам мусіць быць часткай URI-запыту (ня цела POST).

Для аўтэнтыфікаваных запытаў ён мусіць супадаць з адной з крыніц у загалоўку Origin, павінна быць зададзена нешта кшталту https://en.wikipedia.org або https://meta.wikimedia.org. Калі парамэтар не супадае з загалоўкам Origin, будзе вернуты адказ з кодам памылкі 403. Калі парамэтар супадае з загалоўкам Origin і крыніца дазволеная, будуць выстаўленыя загалоўкі Access-Control-Allow-Origin і Access-Control-Allow-Credentials.

Для неаўтэнтыфікаваных запытаў выстаўце значэньне *. Гэта прывядзе да выстаўленьня загалоўку Access-Control-Allow-Origin, але Access-Control-Allow-Credentials будзе мець значэньне false і ўсе зьвесткі пра карыстальніка будуць абмежаваныя.

crossorigin

Пры доступе да API з дапамогай кросдамэнавых запытаў AJAX request (CORS) і сэсійнага пастаўніка, абароненага ад кросбачынавых атакаў падробкі запытаў (CSRF, прыкладам, OAuth), дзеля аўтэнтыфікацыі запыту (т. б. бяз выхаду з сыстэмы) карыстайцеся гэтым замест origin=*. Гэта трэба ўключаць у любыя перадпалётныя запыты, а значыць, у склад запыту URI (ня ў цела POST).

Зьвярніце ўвагу, што большасьць сэсійных пастаўнікоў, у тым ліку стандартныя сэсіі на базе маркёраў, не падтрымліваюць аўтэнтыфікаваныя CORS і ня могуць выкарыстоўвацца з гэтым парамэтрам.

Type: boolean (details)
uselang

Мова для выкарыстаньня ў перакладах паведамленьняў. action=query&meta=siteinfo&siprop=languages з siprop=languages вяртае сьпіс кодаў мовы. Вы можаце пазначыць user, каб ужываць налады мовы цяперашняга карыстальніка, або пазначыць content, каб ужываць мову зьместу гэтай вікі.

Default: user
variant

Варыянт мовы. Працуе толькі ў выпадку, калі базавая мова падтрымлівае пераўтварэньне варыянтаў.

errorformat

Фармат для вываду тэксту папярэджаньняў і памылак

plaintext
Вікітэкст з выдаленымі HTML-цэтлікамі і замененымі існасьцямі.
wikitext
Неразабраны вікітэкст.
html
HTML
raw
Ключ паведамленьня і парамэтры.
none
Бяз тэкставага вываду, толькі коды памылак.
bc
Фармат, які выкарыстоўваўся да MediaWiki 1.29. errorlang і errorsuselocal ігнаруюцца.
One of the following values: bc, html, none, plaintext, raw, wikitext
Default: bc
errorlang

Мова для выкарыстаньня ў папярэджаньнях і памылках. action=query&meta=siteinfo&siprop=languages з siprop=languages вяртае сьпіс кодаў моваў. Пазначце content для выкарыстаньня мовы зьместу гэтай вікі, ці пазначце uselang для выкарыстаньня таго ж значэньня, што і ў парамэтры uselang.

Default: uselang
errorsuselocal

Калі зададзена, тэксты памылак будуць выкарыстоўваць лякальна-наладжаныя паведамленьні з прасторы назваў MediaWiki.

Type: boolean (details)
Прыклады:
Help for the main module.
api.php?action=help [open in sandbox]
Уся дапамога на адной старонцы.
api.php?action=help&recursivesubmodules=1 [open in sandbox]
Permission:
apihighlimits
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 і sysop

Data types

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.

Templated parameters

Templated parameters support cases where an API module needs a value for each value of some other parameter. For example, if there were an API module to request fruit, it might have a parameter fruits to specify which fruits are being requested and a templated parameter {fruit}-quantity to specify how many of each fruit to request. An API client that wants 1 apple, 5 bananas, and 20 strawberries could then make a request like fruits=apples|bananas|strawberries&apples-quantity=1&bananas-quantity=5&strawberries-quantity=20.

Credits

API developers:

  • Yuri Astrakhan (creator, lead developer Sep 2006–Sep 2007)
  • Roan Kattouw (lead developer Sep 2007–2009)
  • Victor Vasiliev
  • Bryan Tong Minh
  • Sam Reed
  • Brad Jorsch (lead developer 2013–2020)

Please send your comments, suggestions and questions to mediawiki-api@lists.wikimedia.org or file a bug report at https://phabricator.wikimedia.org/.