API:Properties
![]() |
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
Properties are used to get various data about a list of pages specified with either the titles=, pageids=, or revids= parameters, or by using generators.
Contents
info / in[edit | edit source]
MediaWiki version: | 1.8 |
Retrieves basic page information. The code for retrieving page properties is located on the git repository at ApiQueryInfo.php.
Parameters[edit | edit source]
inprop
: Which properties to getprotection
: The protection level MW 1.11+talkid
: The page ID of the talk page for each non-talk page MW 1.13+watched
: Indicates whether or not the page is being watched by you. (It returns an empty string if you watch the page and the key is missing from answer if you don't watch it.) MW 1.16+watchers
: The number of watchers, if allowed MW 1.21+notificationtimestamp
: The watchlist notification timestamp of each page MW 1.20+subjectid
: The page ID of the parent page for each talk page MW 1.13+url
: The full (fullurl
) and edit (editurl
) for each page MW 1.14+readable
: Whether the user can read this page MW 1.14+preload
: Include the text returned by EditFormPreloadText. MW 1.16+displaytitle
: Gives the way the page title is actually displayed MW 1.17+
intoken
: Request a token to perform a data-modifying action on a page. Available tokens include:edit
,delete
,protect
,move
,block
,unblock
,email
,import
,watch
incontinue
: When more results are available, use this to continue- When the result is bigger than $wgAPIMaxResultSize
By default, the following properties will be listed:
pageid
: page ID.ns
: namespace.title
: title.touched
: page_touched timestamp.lastrevid
: last revision ID.counter
: If $wgDisableCounters is false, gives number of views. Otherwise, gives empty attribute. (note that $wgDisableCounters is set to true on Wikimedia servers.)length
: page size.redirect
: whether the page is a redirect.new
: whether the page has only one revision.contentmodel
: which content model the page has; usually "wikitext". MW 1.22+pagelanguage
: the language code of the page content language (mostly $wgLanguageCode). MW 1.22+
Example[edit | edit source]
Get info about the en:Albert Einstein page
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api> <query> <pages> <page pageid="736" ns="0" title="Albert Einstein" contentmodel="wikitext" pagelanguage="en" touched="2014-05-30T18:56:38Z" lastrevid="610513534" counter="" length="117613" talkid="21091085"> <protection> <pr type="aft" level="aft-reader" expiry="infinity" /> <pr type="edit" level="autoconfirmed" expiry="infinity" /> <pr type="move" level="sysop" expiry="infinity" /> </protection> </page> </pages> </query> </api> |
Possible warnings[edit | edit source]
- Action 'action' is not allowed for the current user
- Thrown when a token is requested that the current user isn't allowed to use
- No support for special pages has been implemented
- Thrown when a special page is requested
Possible errors[edit | edit source]
None.
revisions / rv[edit | edit source]
MediaWiki version: | 1.8 |
Returns revisions for a given page, or the latest revision for each of several pages. When using parameters marked as (enum), titles=
must have only one title listed. The code for this query is located on the git repository at ApiQueryRevisions.php
Parameters[edit | edit source]
rvprop
: Which properties to get for each revisionids
: Get both of these IDs: revid, parentid (default) MW 1.11+flags
: Whether the revision was a minor edit (default) MW 1.11+timestamp
: The date and time the revision was made (default)user
: The user who made the revision, as well as userhidden and anon flags (default) MW 1.8userid
: User id of revision creator, as well as userhidden and anon flags MW 1.17+sha1
: SHA-1 (base 16) of the revision MW 1.19+contentmodel
: Content model id of the revision MW 1.21+comment
: The edit comment (default)parsedcomment
: The edit/log comment in HTML format with wikilinks and section references expanded into hyperlinks MW 1.16size
: The size of the revision text in bytes MW 1.11+content
: The revision content. If set, the maximum limit will be 10 times as lowtags
: Any tags for this revision, such as those added by AbuseFilter MW 1.16+
rvcontinue
: When more results are available, use this to continue. This can be used, for example, for fetching the text of all revisions of a page (although an XML export might be more efficient). MW 1.15+rvlimit
: The maximum number of revisions to return. Use the string "max" to return all revisions (subject to being broken up as usual, using continue). Limited by query limits defined in ApiBase, which equals 500 for users and 5000 for bots. (enum)rvstartid
: Revision ID to start listing from. (enum)rvendid
: Revision ID to stop listing at. (enum)rvstart
: Timestamp to start listing from. (enum)rvend
: Timestamp to end listing at. (enum)rvdir
: Direction to list in. (enum)older
: List newest revisions first (default) NOTE: rvstart/rvstartid has to be higher than rvend/rvendidnewer
: List oldest revisions first NOTE: rvstart/rvstartid has to be lower than rvend/rvendid
rvuser
: Only list revisions made by this user MW 1.11+rvexcludeuser
: Do not list revisions made by this user MW 1.11+rvexpandtemplates
: Expand templates inrvprop=content
output MW 1.12+rvgeneratexml
: Generate XML parse tree for revision content MW 1.14+rvparse
: Parse revision content. For performance reasons if this option is used, rvlimit is enforced to 1. MW 1.17+rvsection
: Ifrvprop=content
is set, only retrieve the contents of this section. This is an integer, not a string title. MW 1.13+rvtoken
: Tokens to get for each revision MW 1.12+rollback
: Rollback token
rvdiffto
: Revision ID to diff each revision to. Use "prev", "next" and "cur" for the previous, next and current revision respectively. MW 1.15+rvdifftotext
: Text to diff each revision to. Only diffs a limited number of revisions. Overrides diffto. If rvsection is set, only that section will be diffed against this text. MW 1.16+rvtag
: Only list revisions tagged with this tag MW 1.16+rvcontentformat
: Serialization format used for difftotext and expected for output of content MW 1.21+
Example[edit | edit source]
Get data including content for the last revision of titles en:API and en:Main Page
Result |
---|
<api> <query> <pages> <page pageid="1191" ns="0" title="API"> <revisions> <rev user="Harryboyles" timestamp="2006-10-31T05:39:01Z" comment="revert unexplained change: see talk ..."> ...content... </rev> </revisions> </page> <page pageid="11105676" ns="0" title="Main Page"> <revisions> <rev user="Ryan Postlethwaite" timestamp="2007-06-26T19:05:06Z" comment="rv - what was that for?"> ...content... </rev> </revisions> </page> </pages> </query> </api> |
Possible warnings[edit | edit source]
- Action 'action' is not allowed for the current user
- Thrown when a token is requested that the current user isn't allowed to use
- No support for special pages has been implemented
- Thrown when a special page is requested
Possible errors[edit | edit source]
Code | Info |
---|---|
rvrevids | The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end). |
rvmultpages | titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page. |
rvdiffto | rvdiffto must be set to a non-negative number, "prev", "next" or "cur" |
rvnosuchrevid | There is no revision with ID ID |
rvaccessdenied | The current user is not allowed to read title |
rvbadparams | start and startid cannot be used together |
rvbadparams | end and endid cannot be used together |
rvbadparams | user and excludeuser cannot be used together |
rvnosuchsection | There is no section section in rID |
rvbadformat | The requested format contentFormat is not supported for content model model used by name |
categories / cl[edit | edit source]
MediaWiki version: | 1.11 |
Gets a list of all categories used on the provided pages. This module can be used as a generator.
Parameters[edit | edit source]
clprop
: Which properties to getsortkey
: The sort keytimestamp
: The date and time the page was added to the category, or the date and time its sortkey was changed lasthidden
: Whether the category is hidden or not
clshow
: Which kinds of categories to list. Conflicting options (such ashidden
and!hidden
) cannot be used together.hidden
: Only list hidden categories!hidden
: Don't list hidden categories
cllimit
: Maximum number of results to returnclcontinue
: When more results are available, use this to continueclcategories
: Only list these categories. Useful to check whether a certain page is in a certain category- This parameter takes full titles, so the Category: prefix must be used
Example[edit | edit source]
Get a list of categories en:Albert Einstein belongs to
Result |
---|
<api> <query> <pages> <page pageid="736" ns="0" title="Albert Einstein"> <categories> <cl ns="14" title="Category:1879 births" /> <cl ns="14" title="Category:1955 deaths" /> <cl ns="14" title="Category:Albert Einstein" /> ... </categories> </page> </pages> </query> </api> |
Possible warnings[edit | edit source]
- 'title' is not a category
- The title mentioned is not in the Category: namespace
Possible errors[edit | edit source]
Code | Info |
---|---|
clshow | Incorrect parameter - mutually exclusive values may not be supplied |
imageinfo / ii[edit | edit source]
MediaWiki version: | 1.11 |
Gets image information for any titles in the image namespace. This will eventually get superseded by prop=fileinfo.
Parameters[edit | edit source]
iiprop
: Which properties to gettimestamp
: The time and date of the revision (default)user
: The user who made the revision (default)userid
: The id of the user who made the revision MW 1.17+comment
: The edit commentparsedcomment
: Parsed version of comment MW 1.17+canonicaltitle
: The canonical title of the image file MW 1.23+url
: URLs of the image and its description pagesize
: The image's size in bytes, plus width and height. A page count is also returned if the image is in a format that supports multiple pages.dimensions
: (Alias for size) MW 1.13+sha1
: The image's SHA-1 hashmime
: The image's MIME type MW 1.13+thumbmime
: The image thumbnail's MIME type (for use with the iiurl parameters) MW 1.17+mediatype
: The media type of the image MW 1.18+metadata
: Exif metadata for the image, if available. See Manual:File_metadata_handling for information on file metadata handling in MediaWiki MW 1.12+commonmetadata
: Generic metadata for the file format, if available. MW 1.23+extmetadata
: HTML metadata from extensions which implement the GetExtendedMetadata hook. Also contains most ofmetadata
, but in a somewhat standardized format. MW 1.23+archivename
: Archive name (old images only) MW 1.13+bitdepth
: The bit depth of the image MW 1.14+uploadwarning
: Used by Special:Upload. Not intended for use outside the MediaWiki core. MW 1.22+
iilimit
: How many image revisions to return (1 by default) MW 1.12+iistart
: Timestamp to start listing from MW 1.12+iiend
: Timestamp to stop listing at MW 1.12+iiurlwidth
: Ifiiprop=url
is set, a URL to an image scaled to this width will be returned as well. Old versions of images can't be scaled MW 1.12+iiurlheight
: Similar toiiurlwidth
MW 1.12+iimetadataversion
What version of metadata to use. Only affects JPEGs (as of this writing). You usually want this set to latest. MW 1.18+iiextmetadatalanguage
What language to fetch extmetadata in. This affects both which translation to fetch, if multiple are available, as well as how things like numbers and various values are formatted. MW 1.23+iiextmetadatamultilang
If translations for extmetadata property are available, fetch all of them. The values of the multi-languaged metadata items will be in the multi-language array format. (Which items are multilanguaged might change from image to image.) MW 1.23+iiextmetadatafilter
: If specified and non-empty, only these keys will be returned for prop=extmetadata MW 1.23+iiurlparam
The thumb parameter string. Allows user to optionally specify other parameters than width and height (like page number for pdfs). Format of the field varies with image format. PDF uses a format like page<number>-<width>px (e.g. page3-140px ). Its generally the part before the filename in the url of a thumbnail. MW 1.18+iilocalonly
Only show local images. MW 1.20+
Example[edit | edit source]
Get image information for the en:Image:Albert Einstein Head.jpg. Note that the image page might be missing when the image exists on commons.
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api> <query> <pages> <page ns="6" title="Image:Albert Einstein Head.jpg" missing="" imagerepository="shared"> <imageinfo> <ii timestamp="2007-10-20T02:29:04Z" user="Rocket000" /> </imageinfo> </page> </pages> </query> <query-continue> <imageinfo iistart="20071020022358" /> </query-continue> </api> |
langlinks / ll[edit | edit source]
MediaWiki version: | 1.11 |
Gets a list of all language links from the provided pages to other languages.
Only returns language links for 50 titles
Parameters[edit | edit source]
lllimit
: How many langlinks to return. Default: 10. No more than 500 (5000 for bots) allowed. MW 1.13+llcontinue
: When more results are available, use this to continue MW 1.13+llurl
: Whether to get the full URL MW 1.17+llprop
: Which additional properties to get for each interlanguage link MW 1.23+url
: Adds the full URLlangname
: Adds the localised language name (best effort, use CLDR extension). Use llinlanguagecode to control the languageautonym
: Adds the native language name",
lllang
: Language code MW 1.18+lltitle
: Link to search for. Must be used with lllang MW 1.18+lldir
: The direction in which to list MW 1.19+llinlanguagecode
: Language code for localised language names MW 1.23+
Example[edit | edit source]
Get a list of language links en:Albert Einstein has
Result |
---|
<?xml version="1.0"?> <api> <query> <pages> <page pageid="736" ns="0" title="Albert Einstein"> <langlinks> <ll lang="af" xml:space="preserve">Albert Einstein</ll> <ll lang="als" xml:space="preserve">Albert Einstein</ll> <ll lang="am" xml:space="preserve">አልበርት አይንስታይን</ll> ... <ll lang="as" xml:space="preserve">এলবাৰ্ট আইনষ্টাইন</ll> <ll lang="ast" xml:space="preserve">Albert Einstein</ll> <ll lang="ay" xml:space="preserve">Albert Einstein</ll> </langlinks> </page> </pages> </query> <query-continue> <langlinks llcontinue="736|az" /> </query-continue> </api> |
Possible errors[edit | edit source]
None.
links / pl[edit | edit source]
MediaWiki version: | 1.11 |
Gets a list of all links on the provided pages. This module can be used as a generator.
Parameters[edit | edit source]
plnamespace
: Only list links to pages in these namespacespllimit
: How many links to return. Default: 10. No more than 500 (5000 for bots) allowed.plcontinue
: When more results are available, use this to continue
Example[edit | edit source]
Get a list of links on en:Albert Einstein
Result |
---|
<api> <query> <pages> <page pageid="736" ns="0" title="Albert Einstein"> <links> <pl ns="0" title="1879" /> <pl ns="0" title="1901" /> ... <pl ns="0" title="Albert Einstein: The Practical Bohemian" /> <pl ns="0" title="Albert Einstein Archives" /> <pl ns="0" title="Albert Einstein Award" /> <pl ns="0" title="Albert Einstein Foundation for Higher Learning, Inc." /> <pl ns="0" title="Albert Einstein Memorial" /> <pl ns="0" title="Albert Einstein Peace Prize" /> ... <pl ns="0" title="Zurich" /> <pl ns="4" title="Wikipedia:Citing sources" /> <pl ns="4" title="Wikipedia:Media help" /> <pl ns="4" title="Wikipedia:Persondata" /> <pl ns="4" title="Wikipedia:Protection policy" /> <pl ns="4" title="Wikipedia:Sister projects" /> <pl ns="6" title="Image:Albert Einstein german.ogg" /> <pl ns="10" title="Template:Nobel Prize in Physics" /> ... <pl ns="10" title="Template:Nobel Prize in Physics Laureates 2001-2025" /> <pl ns="11" title="Template talk:Nobel Prize in Physics Laureates 1901-1925" /> </links> </page> </pages> </query> </api> |
Possible errors[edit | edit source]
None.
templates / tl[edit | edit source]
MediaWiki version: | 1.11 |
Gets a list of all pages (typically templates) transcluded in the provided pages. This module can be used as a generator.
Parameters[edit | edit source]
tlnamespace
: Only list pages in these namespacestllimit
: How many templates to return. Default: 10. No more than 500 (5000 for bots) allowed.tlcontinue
: When more results are available, use this to continuetltemplates
: Only list these templates. Useful to check whether a certain template is transcluded in a certain page
Example[edit | edit source]
Get a list of templates used on en:Albert Einstein's page
Result |
---|
<api> <query> <pages> <page pageid="736" ns="0" title="Albert Einstein"> <templates> <tl ns="10" title="Template:Academia" /> <tl ns="10" title="Template:Age at date" /> <tl ns="10" title="Template:Audio" /> <tl ns="10" title="Template:Birth date" /> ... </templates> </page> </pages> </query> </api> |
Possible errors[edit | edit source]
None.
images / im[edit | edit source]
MediaWiki version: | 1.11 |
Gets a list of all images used on the provided pages. This module can be used as a generator.
Parameters[edit | edit source]
imlimit
: How many images to return 1.13+imcontinue
: When more results are available, use this to continue 1.13+imimages
: Only list these images. Useful for checking whether a certain page has a certain Image. 1.18+imdir
: The direction in which to list 1.19+
Example[edit | edit source]
Get a list of images on en:Albert Einstein's page
Result |
---|
<api> <query> <pages> <page pageid="736" ns="0" title="Albert Einstein"> <images> <im ns="6" title="Image:1919 eclipse positive.jpg" /> <im ns="6" title="Image:Albert Einstein Head.jpg" /> <im ns="6" title="Image:Albert Einstein german.ogg" /> <im ns="6" title="Image:Albert Einstein photo 1921.jpg" /> ... </images> </page> </pages> </query> </api> |
Possible errors[edit | edit source]
None.
extlinks / el[edit | edit source]
MediaWiki version: | 1.11 |
Gets a list of all external links on the provided pages
Parameters[edit | edit source]
ellimit
: How many links to return. No more than 500 (5000 for bots) allowed. Default: 10.eloffset
: When more results are available, use this to continue.
Example[edit | edit source]
Get a list of external links on en:Albert Einstein's page
Result |
---|
<api> <query> <pages> <page pageid="736" ns="0" title="Albert Einstein"> <extlinks> <el>http://albert-einstein.org/</el> <el>http://albert-einstein.org/history5.html</el> <el>http://ame.epfl.ch/biblio/schlatter1.pdf</el> ... </extlinks> </page> </pages> </query> </api> |
Possible errors[edit | edit source]
None.
categoryinfo / ci[edit | edit source]
MediaWiki version: | 1.13 |
Gets information about categories
- Note
- If the category page exists, but the category has no members, a "categoryinfo" field will not be included in the API response.
Parameters[edit | edit source]
cicontinue
: When more results are available, use this to continue- When the result is bigger than $wgAPIMaxResultSize
Example[edit | edit source]
Get info about a few categories
Result |
---|
<?xml version="1.0" encoding="utf-8"?> <api> <query> <pages> <page ns="14" title="Category:Foo" missing=""> <categoryinfo size="0" pages="0" files="0" subcats="0" /> </page> <page pageid="736" ns="0" title="Albert Einstein" /> <page pageid="3108204" ns="14" title="Category:Infobox templates"> <categoryinfo size="57" pages="44" files="0" subcats="13" /> </page> </pages> </query> </api> |
Possible errors[edit | edit source]
None.
duplicatefiles / df[edit | edit source]
MediaWiki version: | 1.14 |
List duplicates of the given files.
Parameters[edit | edit source]
dflimit
: How many duplicates to listdfcontinue
: When more results are available, use this to continue
Example[edit | edit source]
List duplicates of two images
Result |
---|
<?xml version="1.0"?> <api> <query> <pages> <page pageid="99" ns="6" title="Image:Bombers.ogg"> <duplicatefiles> <df name="Bombers2.ogg" user="Catrope" timestamp="2008-09-27T11:12:45Z" /> </duplicatefiles> </page> <page pageid="41" ns="6" title="Image:Welcome.gif"> <duplicatefiles> <df name="Welcome2.gif" user="Catrope" timestamp="2008-09-27T11:30:30Z" /> </duplicatefiles> </page> </pages> </query> </api> |
Possible errors[edit | edit source]
None.
pageprops / pp[edit | edit source]
MediaWiki version: | 1.17 |
Get various properties defined in the page content.
Parameters[edit | edit source]
ppcontinue
: When more results are available, use this to continue- When the result is bigger than $wgAPIMaxResultSize
ppprop
: Page prop to look on the page for. Useful for checking whether a certain page uses a certain page prop.
Example[edit | edit source]
Get various properties defined in the page content
Result |
---|
<?xml version="1.0"?> <api> <query> <pages> <page pageid="323710" ns="0" title="MediaWiki"> <pageprops defaultsort="Mediawiki" page_image="MediaWiki-smaller-logo.png" wikibase_item="Q83" /> </page> </pages> </query> </api> |
Possible errors[edit | edit source]
None.
contributors / pc[edit | edit source]
MediaWiki version: | 1.23 |
Get the list of logged-in contributors and the count of anonymous contributors to a page.
Parameters[edit | edit source]
pcgroup
: Group name(s) to include in list.pcexcludegroup
: Group name(s) to exclude from list.pcrights
: Limit users to those having given right(s).pcexcluderights
: Limit users to those not having given right(s).pclimit
: Maximum number of contributors to list. No more than 500 (5000 for bots) allowed. Default: 10pccontinue
: When more results are available, use this to continue.- When the result is bigger than $wgAPIMaxResultSize
Example[edit | edit source]
Get various properties defined in the page content
Result |
---|
<?xml version="1.0"?> <api> <query-continue> <contributors pccontinue="323710|1591" /> </query-continue> <query> <pages> <page pageid="323710" ns="0" title="MediaWiki" anoncontributors="513"> <contributors> <user userid="1" name="Damian Yerrick" /> <user userid="11" name="Kpjas" /> <user userid="43" name="Lee Daniel Crocker" /> <user userid="51" name="Brion VIBBER" /> <user userid="52" name="Eloquence" /> <user userid="62" name="Mav" /> <user userid="70" name="Zundark" /> <user userid="76" name="The Anome" /> <user userid="901" name="Aldie" /> <user userid="1095" name="Phil Bordelon" /> </contributors> </page> </pages> </query> </api> |
Possible errors[edit | edit source]
?