Даведка 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: Памылкі і папярэджаньні.

Parameters:
action

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

abusefiltercheckmatch
Праверце, ці адпавядае Фільтру злоўжываньняў набор зьменных, рэдагаваньне ці запратакаляваная падзея Фільтру.
abusefilterchecksyntax
Праверыць сынтаксыс фільтру злоўжываньняў.
abusefilterevalexpression
Ацэньвае значэньне выразу фільтара злоўжываньняў.
abusefilterunblockautopromote
Разблякаваць карыстальніка ад атрыманьня аўтаматычных рэклямных акцыяў з-за наступстваў abusefilter.
abuselogprivatedetails
Прагляд прыватных зьвестак пра запіс журналу злоўжываньняў.
block
Блякаваньне ўдзельніка.
changeauthenticationdata
Зьмена зьвестак аўтэнтыфікацыі для цяперашняга ўдзельніка.
changecontentmodel
Change the content model of a page
checktoken
Праверыць карэктнасьць токену з action=query&meta=tokens.
clearhasmsg
Ачышчае сьцяг hasmsg для актуальнага карыстальніка.
clientlogin
Увайсьці ў вікі з дапамогай інтэрактыўнага струменя.
compare
Атрымаць розьніцу паміж 2 старонкамі.
createaccount
Стварэньне новага рахунку ўдзельніка.
delete
Выдаліць старонку.
echomarkread
Пазначыць апавяшчэнні для бягучага ўдзельніка як прачытаныя.
echomarkseen
Пазначыць апавяшчэнні як прагледжаныя для бягучага ўдзельніка.
echomute
Mute or unmute notifications from certain users or pages.
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.
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.
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.
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.
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. Унутраны модуль для пашырэньня структуры катэгорыяў.
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. Атрымаць інфармацыю пра змены каментароў паміж двума версіямі старонак.
discussiontoolsedit
Internal. Апублікаваць паведамленне на старонцы размовы.
discussiontoolsgetsubscriptions
Internal. Атрымаць станы падпіскі на зададзеныя тэмы.
discussiontoolspageinfo
Internal. Вяртае метададзеныя, неабходныя для ініцыялізацыі інструментаў размоў.
discussiontoolspreview
Internal. Перадпрагляд паведамлення на старонцы размоў.
discussiontoolssubscribe
Internal. Падпісацца (або адпісацца), каб атрымліваць апавяшчэнні па тэме.
oathvalidate
Internal. Праверыць токен двухфактарнай аўтэнтыфікацыі (OATH).
scribunto-console
Internal. Internal module for servicing XHR requests from the Scribunto console.
stashedit
Internal. Prepare an edit in shared cache.
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: abusefiltercheckmatch, abusefilterchecksyntax, abusefilterevalexpression, abusefilterunblockautopromote, abuselogprivatedetails, block, changeauthenticationdata, changecontentmodel, checktoken, clearhasmsg, clientlogin, compare, createaccount, delete, echomarkread, echomarkseen, echomute, edit, emailuser, expandtemplates, feedcontributions, feedrecentchanges, feedwatchlist, filerevert, help, imagerotate, import, 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, unblock, undelete, unlinkaccount, upload, userrights, validatepassword, watch, categorytree, cspreport, discussiontoolscompare, discussiontoolsedit, discussiontoolsgetsubscriptions, discussiontoolspageinfo, discussiontoolspreview, discussiontoolssubscribe, oathvalidate, scribunto-console, stashedit, 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
Default: 0
maxage

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

Type: integer
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 і ўсе зьвесткі пра карыстальніка будуць абмежаваныя.

uselang

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

Default: user
variant

Variant of the language. Only works if the base language supports variant conversion.

errorformat

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

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

Мова для выкарыстаньня ў папярэджаньнях і памылках. action=query&meta=siteinfo з 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]
Permissions:
writeapi
выкарыстаньне API для запісу
Granted to: all, user і bot
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/.