API:Meta
![]() |
This page is part of the MediaWiki API documentation. |
Quick overview:
- Quick start guide
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Meta information
- Properties
- Lists
- Search suggestions
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
- Asserting
Meta queries return information which is not associated with pages.
siteinfo / si[edit | edit source]
MediaWiki version: | 1.8 |
Siteinfo returns overall site information. The code for the siteinfo function is located at ApiQuerySiteinfo.php.
Parameters[edit | edit source]
siprop
: Which properties to getgeneral
: General site information (default)articlepath
$wgArticlePath MW 1.15+base
case
dbtype
dbversion
externalimages
fallback
fallback8bitEncoding
favicon
imagelimits
imagewhitelistenabled
(boolean)generator
git-branch
git-hash
lang
MW 1.10+langconversion
linkprefix
MW 1.21+linkprefixcharset
linktrail
MW 1.21+logo
mainpage
maxuploadsize
$wgMaxUploadSizemisermode
MW 1.18+phpsapi
phpversion
readonly
MW 1.13+readonlyreason
MW 1.13+rights
$wgRightsTextrightscode
$wgRightsCode MW 1.15+rtl
server
$wgServer MW 1.15+servername
script
$wgScript MW 1.15+scriptpath
$wgScriptPath MW 1.15+sitename
thumblimits
time
MW 1.16+timeoffset
MW 1.13+timezone
MW 1.13+titleconversion
variantarticlepath
$wgVariantArticlePath MW 1.15+variants
wikiid
wfWikiID()
MW 1.15+writeapi
MW 1.13+
namespaces
: Provides a list of all namespaces.- Each namespace is given within its own element, which contains several attributes:
id
an integer identification number which is unique for each namespace.subpages
if present, will always be a null attribute (subpages=""). This attribute indicates that subpages are allowed within the namespace. MW 1.13+canonical
Provides the canonical namespace name of the namespace, which may or may not be the same as the actual namespace name. For example, all wikis have a "Project:" namespace, but the actual namespace name is normally changed to the name of the wiki (on Wikipedia for example, the "Project:" namespace is "Wikipedia:"). MW 1.14+content
if present, will always be a null attribute (content=""). This attribute indicates that pages within this namespace should be treated as the main content of the wiki. Pages within namespaces with the content value set are counted for statistical purposes, among other things. MW 1.16+case
Either "first-letter" or "case-sensitive". If the first letter of the namespace name is capitalized (the default), then the value of this attribute will be "first-letter". Otherwise, the value will be "case-sensitive" in order to indicate that the namespace name in question intentionally does not use a capital first letter. Note: "case-insensitive" is reserved for future use MW 1.16+
- Each namespace is given within its own element, which contains several attributes:
statistics
: Site statistics in Special:Statistics, plus job queue MW 1.11+- Note: For historical reasons, the number of files on the wiki is labelled as images not files. This number refers to uploaded files of all types, not just images.
dbrepllag
: Ifsishowalldb
is not set, provides information about the database server with the highest replication lag. Ifsishowalldb
is set, shows replication lag for each database server. MW 1.11+interwikimap
: A list of each interwiki prefix, provided within its own element. MW 1.11+- The attributes provided in each
iw
element include:prefix
Is the prefix of the interwiki link; this is used the same way as a namespace is used when editing.local
: If the interwiki prefix points to a site belonging to the current wiki farm, this will be set to an empty string. The value is read straight out of theiw_local
column of the interwiki table.trans
: If transcluding pages from this wiki is allowed, this will be set to an empty string. Note that this has no effect unless crosswiki transclusion is enabled on the current wiki. MW 1.23+url
The URL of the wiki, with "$1" as a placeholder for an article name.protorel
: If the value ofurl
is protocol-relative (begins with//
), this will be set to an empty string MW 1.24+ or the value "true" MW 1.23 and prior).language
If the interwiki prefix is a language code defined in Language::fetchLanguageNames() from $wgExtraLanguageNames, this will be the name of that language. MW 1.13+extralanglink
: If the interwiki prefix is to be considered a language link, despite the prefix not matching a known language code, this will be set to an empty string. MW 1.24+linktext
: If the interwiki prefix is an extra language link, this will contain the display text used for the links. MW 1.24+sitename
: If the interwiki prefix is an extra language link, this will contain the friendly site name used in the tooltip text of the links. MW 1.24+wikiid
The internal name of the database. Not filled in by default; it may be missing for you. The value is read straight out of theiw_wikiid
column of the interwiki table. MW 1.18+api
The URL of the fileapi.php
on that wiki. Not filled in by default; it may be missing for you. The value is read straight out of theiw_api
column of the interwiki table. MW 1.18+
- The attributes provided in each
namespacealiases
: A list of all namespace aliases MW 1.13+specialpagealiases
: A list of all special page aliases MW 1.13+usergroups
: A list of all user groups and their permissions MW 1.13+extensions
: A list of extensions installed on the wiki MW 1.14+ including revision (date and hash) and, if possible, licensing information (MW 1.23+)skins
: A list of skins installed on the wiki MW 1.18+magicwords
: A list of magic words and their aliases MW 1.14+fileextensions
: A list of file extensions allowed to be uploaded MW 1.15+rightsinfo
: Get information about the license governing the wiki's content MW 1.15+- In the best case this will provide:
url
which is what $wgRightsUrl contains (like a license URL)text
which is what $wgRightsText contains (like the license name) and is also provided withgeneral
- If $wgRightsPage is set,
url
is the URL to a page whose meaning has to be interpreted separately and is not output by the API - The API doesn't output whatever MediaWiki:Copyright contains
- In the best case this will provide:
languages
: Get available languages as seen in preferences MW 1.16+
sifilteriw
: Criteria to filter the interwiki map by (ignored ifsiprop=interwikimap
isn't set) MW 1.11+local
: Only list local interwiki prefixes!local
: Only list non-local interwiki prefixes
sishowalldb
: Show information about all DB servers (ignored ifsiprop=dbrepllag
isn't set) MW 1.11+sinumberingroup
: When set to true andsiprop
includesusergroups
the number of users in each usergroup and the groups it can add/remove are included MW 1.17+
Example[edit | edit source]
General site info
Result |
---|
<?xml version="1.0"?> <api> <query> <general mainpage="Main Page" base="http://en.wikipedia.org/wiki/Main_Page" sitename="Wikipedia" logo="//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png" generator="MediaWiki 1.23wmf18" phpversion="5.3.10-1ubuntu3.10+wmf1" phpsapi="apache2handler" dbtype="mysql" dbversion="5.5.34-MariaDB-1~precise-log" imagewhitelistenabled="" langconversion="" titleconversion="" linkprefixcharset="" linkprefix="" linktrail="/^([a-z]+)(.*)$/sD" git-hash="7253e5a024d5e47fd70ae6fdab64378e254a3b08" case="first-letter" lang="en" fallback8bitEncoding="windows-1252" writeapi="" timezone="UTC" timeoffset="0" articlepath="/wiki/$1" scriptpath="/w" script="/w/index.php" server="//en.wikipedia.org" wikiid="enwiki" time="2014-03-25T11:03:27Z" misermode="" maxuploadsize="1048576000" favicon="//bits.wikimedia.org/favicon/wikipedia.ico"> <fallback /> <thumblimits> <limit>120</limit> <limit>150</limit> <limit>180</limit> <limit>200</limit> <limit>220</limit> <limit>250</limit> <limit>300</limit> </thumblimits> <imagelimits> <limit width="320" height="240" /> <limit width="640" height="480" /> <limit width="800" height="600" /> <limit width="1024" height="768" /> <limit width="1280" height="1024" /> </imagelimits> </general> </query> </api> |
Specific site info
Result |
---|
<?xml version="1.0"?> <api> <query> <statistics pages="25546702" articles="3801962" edits="499158028" images="825487" users="15733405" activeusers="144787" admins="1514" jobs="0" /> </query> </api> |
Copyright site info
Result |
---|
<?xml version="1.0"?> <api> <query> <rightsinfo url="//creativecommons.org/licenses/by-sa/3.0/" text="Creative Commons Attribution-Share Alike 3.0 Unported" /> </query> </api> |
List namespaces and aliases
Result |
---|
<?xml version="1.0"?> <api> <query> <namespaces> <ns id="-2" case="first-letter" canonical="Media" xml:space="preserve">Media</ns> <ns id="-1" case="first-letter" canonical="Special" xml:space="preserve">Special</ns> <ns id="0" case="first-letter" content="" xml:space="preserve" /> <ns id="1" case="first-letter" subpages="" canonical="Talk" xml:space="preserve">Talk</ns> <ns id="2" case="first-letter" subpages="" canonical="User" xml:space="preserve">User</ns> <ns id="3" case="first-letter" subpages="" canonical="User talk" xml:space="preserve">User talk</ns> <ns id="4" case="first-letter" subpages="" canonical="Project" xml:space="preserve">Wikipedia</ns> <ns id="5" case="first-letter" subpages="" canonical="Project talk" xml:space="preserve">Wikipedia talk</ns> <ns id="6" case="first-letter" canonical="File" xml:space="preserve">File</ns> <ns id="7" case="first-letter" subpages="" canonical="File talk" xml:space="preserve">File talk</ns> <ns id="8" case="first-letter" canonical="MediaWiki" xml:space="preserve">MediaWiki</ns> <ns id="9" case="first-letter" subpages="" canonical="MediaWiki talk" xml:space="preserve">MediaWiki talk</ns> <ns id="10" case="first-letter" subpages="" canonical="Template" xml:space="preserve">Template</ns> <ns id="11" case="first-letter" subpages="" canonical="Template talk" xml:space="preserve">Template talk</ns> <ns id="12" case="first-letter" subpages="" canonical="Help" xml:space="preserve">Help</ns> <ns id="13" case="first-letter" subpages="" canonical="Help talk" xml:space="preserve">Help talk</ns> <ns id="14" case="first-letter" canonical="Category" xml:space="preserve">Category</ns> <ns id="15" case="first-letter" subpages="" canonical="Category talk" xml:space="preserve">Category talk</ns> <ns id="100" case="first-letter" subpages="" canonical="Portal" xml:space="preserve">Portal</ns> <ns id="101" case="first-letter" subpages="" canonical="Portal talk" xml:space="preserve">Portal talk</ns> <ns id="108" case="first-letter" subpages="" canonical="Book" xml:space="preserve">Book</ns> <ns id="109" case="first-letter" subpages="" canonical="Book talk" xml:space="preserve">Book talk</ns> </namespaces> <namespacealiases> <ns id="4" xml:space="preserve">WP</ns> <ns id="5" xml:space="preserve">WT</ns> <ns id="6" xml:space="preserve">Image</ns> <ns id="7" xml:space="preserve">Image talk</ns> </namespacealiases> </query> </api> |
Possible errors[edit | edit source]
Code | Info |
---|---|
includeAllDenied | Cannot view all servers info unless $wgShowHostnames is true |
userinfo / ui[edit | edit source]
MediaWiki version: | 1.11 |
Returns information about the currently logged-in user. The code for the userinfo function is located at ApiQueryUserInfo.php.
Parameters[edit | edit source]
uiprop
: Which properties to getblockinfo
: Whether the current user is blocked, by whom, and whyhasmsg
: Whether the current user has new messages on their user talk pagegroups
: Which groups the current user belongs toimplicitgroups
: Lists all the groups the current user is automatically a member of MW 1.18+rights
: Which rights the current user haschangeablegroups
: Which groups the current user can add/remove MW 1.16+options
: Which preferences the current user haspreferencestoken
: Get a token to change current user's preferences MW 1.14+editcount
: The number of edits the current user has made MW 1.12+ratelimits
: Rate limits applying to the current user MW 1.12+realname
: User's realname MW 1.18+email
: Email address and authentication timestamp in ISO 8601 format MW 1.15+acceptlang
: Echoes the Accept-Language header sent by the client in a structured format MW 1.17+registrationdate
: Adds the user's registration date MW 1.18+unreadcount
: Adds the count of unread pages on the user's watchlist (maximum 999; returns "1000+" if more) MW 1.24+
Example[edit | edit source]
General user info
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api> <query> <userinfo name="Jborme" messages=""> <rights> <r>createaccount</r> <r>read</r> <r>edit</r> <r>createpage</r> <r>createtalk</r> <r>reupload-own</r> <r>read</r> <r>edit</r> <r>createpage</r> <r>createtalk</r> <r>upload</r> <r>minoredit</r> <r>purge</r> <r>reupload</r> <r>move</r> <r>autoconfirmed</r> <r>skipcaptcha</r> <r>emailconfirmed</r> </rights> </userinfo> </query> </api> |
Possible errors[edit | edit source]
None.
allmessages / am[edit | edit source]
MediaWiki version: | 1.12 |
Lists the contents of all (or a few) interface messages.
Parameters[edit | edit source]
ammessages
: Which messages to output. "*" (default) means all messagesamprop
: Which properties to get, the only (default) prop is "default" MW 1.16+- When the default is identical to the (custom) message, the prop is not added
amenableparser
: Set to enable parser, will preprocess the wikitext of message. Will substitute magic words, handle templates etc. MW 1.16+amnocontent
: If set, do not include the content of the messages in the output. MW 1.19+amincludelocal
: Also include local messages, i.e. messages that don't exist in the software but do exist as a MediaWiki: page. This lists all MediaWiki: pages, so it will also list those that aren't 'really' messages such as Common.js MW 1.19+amtitle
: Page name to use as context when parsing message (for enableparser option) MW 1.18+amargs
: Arguments to be substituted into message MW 1.16+amprefix
: Return messages with this prefix MW 1.18+amfilter
: Return only messages with names that contain this stringamcustomised
: Return only messages in this customisation state MW 1.18+amlang
: Return messages in this languageamfrom
: Return messages starting at this message (must be a valid message name) MW 1.15+amto
: Return messages ending at this message (must be a valid message name) MW 1.17+
Example[edit | edit source]
Get the Dutch translations of some messages
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api> <query> <allmessages> <message name="august">augustus</message> <message name="mainpage">Hoofdpagina</message> <message name="edit">Bewerken</message> <message name="rollback-success">Wijzigingen door $1 teruggedraaid; laatste versie van $2 hersteld.</message> <message name="thismessagedoesntexist" missing="" /> </allmessages> </query> </api> |
Possible errors[edit | edit source]
None.
filerepoinfo / fri[edit | edit source]
MediaWiki version: | 1.22 |
Return meta information about image repositories configured on the wiki.
Parameters[edit | edit source]
friprop
: Which repository properties to get (there may be more available on some wikis):apiurl
: URL to the repository API - helpful for getting image info from the host. (missing in MW 1.25)name
: The key of the repository - used in e.g. $wgForeignFileRepos and imageinfo return values.displayname
: The human-readable name of the repository wiki.rootUrl
(MW 1.25) orrooturl
(?) : Root URL for image paths.local
: Whether that repository is the local one or not.
Example[edit | edit source]
Result |
---|
<?xml version="1.0"?> <api> <warnings> <filerepoinfo xml:space="preserve">Unrecognized value for parameter 'friprop': apiurl</filerepoinfo> </warnings> <query> <repos> <repo name="shared" displayname="Wikimedia Commons" /> <repo name="local" displayname="" /> </repos> </query> </api> |
Possible errors[edit | edit source]
Unknown.
tokens[edit | edit source]
MediaWiki version: | 1.24 |
Gets tokens for data-modifying actions. This module does not use a prefix. The csrf
(cross-site request forgery) token corresponds to the majority of older tokens, like edittoken
and movetoken
.
Parameters[edit | edit source]
type
: Type of token(s) to request. Possible values:csrf
,watch
,patrol
,rollback
,userrights
. (Default:csrf
)
Example[edit | edit source]
Result |
---|
<?xml version="1.0"?> <api> <query> <tokens csrftoken="00112233445566778899aabbccddeeff+\" /> </query> </api> |
Result |
---|
<?xml version="1.0"?> <api> <query> <tokens watchtoken="00112233445566778899aabbccddeeff+\" patroltoken="ffeeddccbbaa99887766554433221100+\" /> </query> </api> |
Possible errors[edit | edit source]
Unknown.