API:Meta
From MediaWiki.org
This page is part of the MediaWiki API documentation. |
Language: | English • Deutsch • español • 日本語 |
---|
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
Meta queries return information which is not associated with pages.
Contents
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)rights
is what $wgRightsText contains
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-sensitive" 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 true) A boolean value indicating whether the wiki is in this project.url
The URL of the wiki, with "$1" as a placeholder for an article name.language
(if defined) The name of the language used by the wiki, derived by Language::fetchLanguageNames() from $wgExtraLanguageNames. (MW 1.13+)wikiid
The internal name of the database. (MW 1.18+)api
The URL of the file api.php. (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+)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 |
---|
The following content has been placed in a collapsed box for improved usability. |
<?xml version="1.0" encoding="utf-8"?> <api> <query> <general mainpage="Main Page" base="http://en.wikipedia.org/wiki/Main_Page" sitename="Wikipedia" generator="MediaWiki 1.16alpha-wmf" phpversion="5.2.4-2ubuntu5wm1" phpsapi="apache2handler" dbtype="mysql" dbversion="4.0.40-wikimedia-log" rev="54192" case="first-letter" rights="Creative Commons Attribution-Share Alike 3.0 Unported" lang="en" fallback8bitEncoding="windows-1252" writeapi="" timezone="UTC" timeoffset="0" articlepath="/wiki/$1" scriptpath="/w" script="/w/index.php" variantarticlepath="" server="http://en.wikipedia.org" wikiid="enwiki" /> </query> </api> |
The above content has been placed in a collapsed box for improved usability. |
Specific site info
Result |
---|
The following content has been placed in a collapsed box for improved usability. |
<?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> |
The above content has been placed in a collapsed box for improved usability. |
Copyright site info
Result |
---|
The following content has been placed in a collapsed box for improved usability. |
<?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> |
The above content has been placed in a collapsed box for improved usability. |
List namespaces and aliases
Result |
---|
The following content has been placed in a collapsed box for improved usability. |
<?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> |
The above content has been placed in a collapsed box for improved usability. |
Possible errors[edit | edit source]
- code: includeAllDenied
- info: 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 torights
: Which rights the current user haschangeablegroups
: Which groups the current user can add/removeoptions
: Which preferences the current user haseditcount
: The number of edits the current user has maderatelimits
: Rate limits applying to the current userrealname
: User's realname [1.18+]r79433email
: Email address and authentication timestamp in ISO 8601 format [1.15+]
Example[edit | edit source]
General user info
Result |
---|
The following content has been placed in a collapsed box for improved usability. |
<?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> |
The above content has been placed in a collapsed box for improved usability. |
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"- 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.amargs
: Arguments to be substituted into messageamfilter
: Return only messages that contain this stringamlang
: Return messages in this languageamfrom
: Return messages starting at this messageamto
: Return messages ending at this message
Example[edit | edit source]
Get the Dutch translations of some messages
Result |
---|
The following content has been placed in a collapsed box for improved usability. |
<?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> |
The above content has been placed in a collapsed box for improved usability. |
Possible errors[edit | edit source]
None.