API:Properties
![]() |
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
- Authentication
- Queries
- Meta information
- Properties
- Lists
- Search suggestions
- Expanding templates and rendering
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
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 |
[edit] info / in
MediaWiki version: | 1.9 |
Retrieves basic page information. The code for retrieving page properties is located on the SVN server at ApiQueryInfo.php.
[edit] Info: Parameters
inprop
: Which properties to getprotection
: The protection leveltalkid
: The page ID of the talk page for each non-talk pagesubjectid
: The page ID of the parent page for each talk pageurl
: The full (fullurl
) and edit (editurl
) for each pagepreload
: Include the text returned by EditFormPreloadText.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.)- 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.
intoken
: Which token to getedit
: Get a token for page editmove
: Get a token for page movedelete
: Get a token for page deletion
incontinue
: When more results are available, use this to continue- When the result is bigger than $wgAPIMaxResultSize
[edit] Info: Example
Get info about the en:Albert Einstein page
<?xml version="1.0" encoding="utf-8"?> <api> <query> <pages> <page pageid="736" ns="0" title="Albert Einstein" touched="2008-03-27T04:42:56Z" lastrevid="201248286" counter="4698" length="81826" talkid="2177"> <protection> <pr type="edit" level="autoconfirmed" expiry="infinity" /> <pr type="move" level="sysop" expiry="infinity" /> </protection> </page> </pages> </query> </api>
[edit] Info: Possible warnings
- 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
[edit] Info: Possible errors
None
[edit] revisions / rv
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 SVN server at ApiQueryRevisions.php
[edit] Revisions: Parameters
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)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)userid
: User id of revision creator, as well as userhidden and anon flagssha1
: SHA-1 (base 16) of the revisioncomment
: The edit comment (default)parsedcomment
: The edit/log comment in HTML format with wikilinks and section references expanded into hyperlinks (MW 1.16. Added in r61761)size
: The size of the revision text in bytescontent
: 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 download might be more efficient).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 userrvexcludeuser
: Do not list revisions made by this userrvexpandtemplates
: Expand templates inrvprop=content
outputrvgeneratexml
: Generate XML parse tree for revision contentrvparse
: Parse revision content. For performance reasons if this option is used, rvlimit is enforced to 1.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 revisionrollback
: Rollback token
rvdiffto
: Revision ID to diff each revision to. Use "prev", "next" and "cur" for the previous, next and current revision respectively.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.
[edit] Revisions: Example
Get data including content for the last revision of titles en:API and en:Main Page
<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>
[edit] Revisions: Possible warnings
- 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
[edit] Revisions: Possible errors
- code: rvrevids
- info: The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).
- code: rvmultpages
- info: 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.
- code: rvaccessdenied
- info: The current user is not allowed to read title
- code: rvbadparams
- info: start and startid cannot be used together
- code: rvbadparams
- info: end and endid cannot be used together
- code: rvbadparams
- info: user and excludeuser cannot be used together
- code: rvnosuchsection
- info: There is no section section in rrevid
[edit] categories / cl
MediaWiki version: | 1.11 |
Gets a list of all categories used on the provided pages. This module can be used as a generator.
[edit] Parameters
clprop
: Which properties to get (cannot be used with a generator)sortkey
: The sort keytimestamp
: The date and time the page was added to the category, or the date and time its sortkey was changed last
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
[edit] Example
Get a list of categories en:Albert Einstein belongs to
<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>
[edit] Possible warnings
- 'title' is not a category
- The title mentioned is not in the Category: namespace
[edit] Possible errors
- code: clshow
- info: Incorrect parameter - mutually exclusive values may not be supplied
[edit] imageinfo / ii
MediaWiki version: | 1.11 |
Gets image information for any titles in the image namespace
[edit] Parameters
iiprop
: Which properties to gettimestamp
: The time and date of the revision (default)user
: The user who made the revision (default)comment
: The edit commenturl
: URL of the imagesize
: The image's size in bytes, plus width and heightsha1
: The image's SHA-1 hashmime
: The image's MIME typemetadata
: Image metadata, if availablearchivename
: Archive name (old images only)
iilimit
: How many image revisions to return (1 by default)iistart
: Timestamp to start listing fromiiend
: Timestamp to stop listing atiiurlwidth
: 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 scalediiurlheight
: Similar toiiurlwidth
[edit] Example
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.
<?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>
[edit] langlinks / ll
MediaWiki version: | 1.9 |
Gets a list of all language links from the provided pages to other languages.
Only returns language links for 50 titles
[edit] Parameters
- llcontinue: When more results are available, use this to continue
- lllimit: How many links to return. Default: 10. No more than 500 (5000 for bots) allowed.
[edit] Example
Get a list of language links en:Albert Einstein has
<?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>
[edit] Possible errors
None
[edit] links / pl
MediaWiki version: | 1.9 |
Gets a list of all links on the provided pages. This module can be used as a generator.
[edit] Parameters
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
[edit] Example
Get a list of links on en:Albert Einstein
<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>
[edit] Possible errors
None
[edit] templates / tl
MediaWiki version: | 1.9 |
Gets a list of all pages (typically templates) transcluded in the provided pages. This module can be used as a generator.
[edit] Parameters
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
[edit] Example
Get a list of templates used on en:Albert Einstein's page
<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>
[edit] Possible errors
None.
[edit] images / im
MediaWiki version: | 1.9 |
In Query API interface, this command found pages that embedded the given image. That function has been renamed to imageusage.
Gets a list of all images used on the provided pages. This module can be used as a generator.
[edit] Parameters
imlimit
: How many images to return (since MW 1.13 r37270)
[edit] Example
Get a list of images on en:Albert Einstein's page
<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>
[edit] Possible errors
None.
[edit] extlinks / el
MediaWiki version: | 1.11 |
Gets a list of all external links on the provided pages
[edit] Parameters
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.
[edit] Example
Get a list of external links on en:Albert Einstein's page
<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>
[edit] Possible errors
None.
[edit] categoryinfo / ci
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.
[edit] Parameters
cicontinue
: When more results are available, use this to continue- When the result is bigger than $wgAPIMaxResultSize
[edit] Example
Get info about a few categories
<?xml version="1.0" encoding="utf-8"?> <api> <query> <normalized> <n from="Category:Templates_using_ParserFunctions" to="Category:Templates using ParserFunctions" /> </normalized> <pages> <page ns="14" title="Category:Foo" missing="" /> <page ns="14" title="Category:Templates using ParserFunctions" missing=""> <categoryinfo size="8" pages="8" files="0" subcats="0" /> </page> <page pageid="736" ns="0" title="Albert Einstein" /> <page pageid="37" ns="14" title="Category:Infobox"> <categoryinfo size="0" pages="1" files="0" subcats="0" /> </page> </pages> </query> </api>
[edit] Possible errors
None
[edit] duplicatefiles / df
MediaWiki version: | 1.14 |
List duplicates of the given files.
[edit] Parameters
dflimit
: How many duplicates to listdfcontinue
: When more results are available, use this to continue
[edit] Example
List duplicates of two images
<?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>
[edit] Possible errors
None.
[edit] pageprops / pp
MediaWiki version: | 1.17 |
Get various properties defined in the page content.
[edit] Parameters
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.
[edit] Example
Get various properties defined in the page content
<?xml version="1.0"?> <api> <query> <pages> <page pageid="323710" ns="0" title="MediaWiki"> <pageprops defaultsort="Mediawiki" /> </page> </pages> </query> </api>
[edit] Possible errors
None.