MediaWiki API help - Wikidata (original) (raw)
This is an auto-generated MediaWiki API documentation page.
Documentation and examples: https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page
Main module
- Source: MediaWiki
- License: GPL-2.0-or-later
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 to the 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 see API: Errors and warnings.
Testing: For ease of testing API requests, see Special:ApiSandbox.
Specific parameters:
action
Which action to perform.
Check to see if an AbuseFilter matches a set of variables, an edit, or a logged AbuseFilter event.
Check syntax of an AbuseFilter filter.
Evaluates an AbuseFilter expression.
Unblocks a user from receiving autopromotions due to an abusefilter consequence.
View private details of an AbuseLog entry.
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.
Manage aggregate message groups.
Check a username against AntiSpoof's normalisation checks.
Block a user.
Fetch a centralauthtoken for making an authenticated request to an attached wiki.
centralnoticecdncacheupdatebanner
Request the purge of banner content stored in the CDN (front-end) cache for anonymous users, for the requested banner and language
Get data needed to choose a banner for a given project and language
Get all configuration settings for a campaign.
Change authentication data for the current user.
Change the content model of a page
Check the validity of a token from action=query&meta=tokens.
Dump of CirrusSearch configuration.
Dump of CirrusSearch mapping for this wiki.
Dump of CirrusSearch profiles for this wiki.
Dump of CirrusSearch settings for this wiki.
Clears the hasmsg
flag for the current user.
Log in to the wiki using the interactive flow.
Get the difference between two pages.
Create a new user account.
Forcibly create a local account. The central account must exist.
Delete a page.
Delete a global user.
Post a message on a discussion page.
Find a comment by its ID or name.
discussiontoolsgetsubscriptions
Get the subscription statuses of given topics.
Subscribe (or unsubscribe) to receive notifications about a topic.
Send a public thank-you notification for a comment.
Manually trigger a notification to a user
Mark notifications as read for the current user.
Mark notifications as seen for the current user.
Mute or unmute notifications from certain users or pages.
Create and edit pages.
Edit a mass message delivery list.
Email a user.
Expands all templates within wikitext.
Returns a featured content feed.
Returns a user's contributions feed.
Returns a recent changes feed.
Returns a watchlist feed.
Revert a file to an old version.
Allows actions to be taken on Structured Discussions pages.
Convert text between wikitext and HTML.
Send a public thank-you notification for a Flow comment.
Globally block or unblock a user.
Change local overrides for global preferences for the current user.
Change global preferences of the current user.
Add/remove a user to/from global groups.
Set message group workflow states.
Display help for the specified modules.
This module has been disabled.
Import a page from another wiki, or from an XML file.
Allows direct access to JsonConfig subsystem.
Search for language names in any script.
Link an account from a third-party provider to the current user.
Log in and get authentication cookies.
Log out and clear session data.
Perform management tasks relating to change tags.
Mark a page for translation
Send a message to a list of pages.
Merge page histories.
Move a page.
Search the wiki using the OpenSearch protocol.
Change preferences of the current user.
Obtain information about API modules.
Parses content and returns parser output.
Patrol a page or revision.
Change the protection level of a page.
Purge the cache for the given titles.
Fetch data from and about MediaWiki.
Remove authentication data for the current user.
Send a password reset email to a user.
Delete and undelete revisions.
Undo the last edit to the page.
Export an RSD (Really Simple Discovery) schema.
Search translations.
Hide or lock (or unhide or unlock) a global user account.
Update the notification timestamp for watched pages.
Change the language of a page.
Shorten a long URL into a shorter one.
Get Wikimedia sites list.
Validate one or more URLs against the spam block list.
Exposes event stream config. Returns only format=json with formatversion=2.
Allows admins to strike or unstrike a vote.
Add or remove change tags from individual revisions or log entries.
Fetch data stored by the TemplateData extension.
Send a thank-you notification to an editor.
Validate a page title, filename, or username against the TitleBlacklist.
Check if an IP address is blocked as a Tor exit node.
Users with the 'transcode-reset' right can reset and re-run a transcode job.
Query all translations aids.
Mark translations reviewed.
Fetch translation statistics
Query suggestions from translation memories.
Unblock a user.
Undelete revisions of a deleted page.
Remove a linked third-party account from the current user.
Upload a file, or get the status of pending uploads.
Change a user's group membership.
Validate a password against the wiki's password policies.
Add or remove pages from the current user's watchlist.
Queries available badge items.
Checks the constraint parameters of constraint statements.
Performs constraint checks on any entity you want and returns the result.
Creates Wikibase claims.
Creates Entity redirects.
Creates a single new Wikibase entity and modifies it with serialised information.
Formats entity IDs to HTML.
Formats DataValues.
Gets Wikibase claims.
Gets the data for multiple Wikibase entities.
Associates two pages on two different wikis with a Wikibase item.
Merges two Lexemes.
Merges multiple items.
Parses values using a ValueParser
.
Removes Wikibase claims.
Removes a qualifier from a claim.
Removes one or more references of the same statement.
Searches for entities using labels and aliases.
Sets the aliases for a Wikibase entity.
Creates or updates an entire Statement or Claim.
Sets the value of a Wikibase claim.
Sets a description for a single Wikibase entity.
Sets a label for a single Wikibase entity.
Creates a qualifier or sets the value of an existing one.
Creates a reference or sets the value of an existing one.
Associates a page on a wiki with a Wikibase item or removes an already made such association.
API module for getting suggestions of additional properties to add to a Wikibase entity. The API module is primarily intended for use by the suggester widget when users are editing Wikibase entities.
Returns a webapp manifest.
API Module to communicate between server and client during registration/authentication process.
Internal. Receive a bounce email and process it to handle the failing recipient.
Internal. Internal module for the CategoryTree extension.
Internal. Reports on the correctness of a range of page ids in the search index
Internal. API module for performing various operations on a wiki user's collection.
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.
Internal. Get information about comment changes between two page revisions.
Internal. Returns metadata required to initialize the discussion tools.
Internal. Preview a message on a discussion page.
Internal. Check the status of a URL for use as a reference.
Internal. Get a new FancyCaptcha.
Internal. Retrieve localized JSON data.
managegroupsynchronizationcache
Internal. Manage group synchronization cache.
Internal. Add a message as a rename of an existing message or a new message in the group during imports
Internal. Message group subscription related operations
Internal. Validate a two-factor authentication (OATH) token.
Internal. Parse a page with two different parser configurations.
Internal. Reading list write operations.
Internal. Performs data validation for Kartographer extension
Internal. Internal module for servicing XHR requests from the Scribunto console.
Internal. Allows a remote wiki to authenticate users before granting access to vote in the election.
Internal. Prepare an edit in shared cache.
Internal. Provides timed text content for usage by elements
Internal. Validate translations.
Internal. Search for message groups and messages
Internal. Get the localization of ULS in the given language.
Internal. Update user's preferred interface language.
Internal. Returns HTML5 for a page from the Parsoid service.
Internal. Save an HTML5 page to MediaWiki (converted to wikitext via the Parsoid service).
Internal. Adds Form to Lexeme
Internal. Adds a Sense to a Lexeme
Internal. Edits representations and grammatical features of a Form
Internal. Edits glosses of a Sense
Internal. Removes Form from Lexeme
Internal. Removes Sense from Lexeme
Internal. Log information about blocked edit attempts
One of the following values: abusefiltercheckmatch, abusefilterchecksyntax, abusefilterevalexpression, abusefilterunblockautopromote, abuselogprivatedetails, acquiretempusername, aggregategroups, antispoof, block, centralauthtoken, centralnoticecdncacheupdatebanner, centralnoticechoicedata, centralnoticequerycampaign, changeauthenticationdata, changecontentmodel, checktoken, cirrus-config-dump, cirrus-mapping-dump, cirrus-profiles-dump, cirrus-settings-dump, clearhasmsg, clientlogin, compare, createaccount, createlocalaccount, delete, deleteglobalaccount, discussiontoolsedit, discussiontoolsfindcomment, discussiontoolsgetsubscriptions, discussiontoolssubscribe, discussiontoolsthank, echocreateevent, echomarkread, echomarkseen, echomute, edit, editmassmessagelist, emailuser, expandtemplates, featuredfeed, feedcontributions, feedrecentchanges, feedwatchlist, filerevert, flow-parsoid-utils, flow, flowthank, globalblock, globalpreferenceoverrides, globalpreferences, globaluserrights, groupreview, help, imagerotate, import, jsonconfig, languagesearch, linkaccount, login, logout, managetags, markfortranslation, massmessage, mergehistory, move, opensearch, options, paraminfo, parse, patrol, protect, purge, query, removeauthenticationdata, resetpassword, revisiondelete, rollback, rsd, searchtranslations, setglobalaccountstatus, setnotificationtimestamp, setpagelanguage, shortenurl, sitematrix, spamblacklist, streamconfigs, strikevote, tag, templatedata, thank, titleblacklist, torblock, transcodereset, translationaids, translationreview, translationstats, ttmserver, unblock, undelete, unlinkaccount, upload, userrights, validatepassword, watch, wbavailablebadges, wbcheckconstraintparameters, wbcheckconstraints, wbcreateclaim, wbcreateredirect, wbeditentity, wbformatentities, wbformatvalue, wbgetclaims, wbgetentities, wblinktitles, wblmergelexemes, wbmergeitems, wbparsevalue, wbremoveclaims, wbremovequalifiers, wbremovereferences, wbsearchentities, wbsetaliases, wbsetclaim, wbsetclaimvalue, wbsetdescription, wbsetlabel, wbsetqualifier, wbsetreference, wbsetsitelink, wbsgetsuggestions, webapp-manifest, webauthn, bouncehandler, categorytree, cirrus-check-sanity, collection, cspreport, discussiontoolscompare, discussiontoolspageinfo, discussiontoolspreview, editcheckreferenceurl, fancycaptchareload, jsondata, managegroupsynchronizationcache, managemessagegroups, messagegroupsubscription, oathvalidate, parser-migration, readinglists, sanitize-mapdata, scribunto-console, securepollauth, stashedit, timedtext, translationcheck, translationentitysearch, ulslocalization, ulssetlang, visualeditor, visualeditoredit, wbladdform, wbladdsense, wbleditformelements, wbleditsenseelements, wblremoveform, wblremovesense, wikimediaeventsblockededit
Default: help
format
The format of the output.
Output data in JSON format.
Output data in JSON format (pretty-print in HTML).
Output nothing.
Output data in serialized PHP format.
Output data in serialized PHP format (pretty-print in HTML).
Output data, including debugging elements, in JSON format (pretty-print in HTML).
Output data in XML format.
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
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 code maxlag is returned with a message like Waiting for host:host: host:lag seconds lagged.
See Manual: Maxlag parameter for more information.
Type: integer
smaxage
Set the s-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 the max-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 to user, not logged in if set to anon, or has the bot user right if bot.
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.
Type: boolean (details)
curtimestamp
Include the current timestamp in the result.
Type: boolean (details)
responselanginfo
Include the languages used for uselang and errorlang in the result.
Type: boolean (details)
origin
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 the Origin
header exactly, so it has to be set to something like https://en.wikipedia.org or https://meta.wikimedia.org. If this parameter does not match the Origin
header, a 403 response will be returned. If this parameter matches the Origin
header and the origin is allowed, the Access-Control-Allow-Origin
and Access-Control-Allow-Credentials
headers will be set.
For non-authenticated requests, specify the value *. This will cause the Access-Control-Allow-Origin
header to be set, but Access-Control-Allow-Credentials
will be false
and all user-specific data will be restricted.
uselang
Language to use for message translations. action=query&meta=siteinfo&siprop=languages returns a list of language codes. You can specify user to use the current user's language preference or content 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 and errorsuselocal 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. 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)
centralauthtoken
When accessing the API using a cross-domain AJAX request (CORS), use this to authenticate as the current SUL user. Use action=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).
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 and wikidata-staff
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/.