API:Properties

From MediaWiki.org
Jump to: navigation, search
Tools clipart.png This page is part of the MediaWiki API documentation.
Language: English  • Deutsch • español • 日本語 • українська
MediaWiki API

Quick overview:

v · d · e

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.

info / in[edit | edit source]

MediaWiki version: = 1.9

Retrieves basic page information. The code for retrieving page properties is located on the git repository at ApiQueryInfo.php.

Info: Parameters[edit | edit source]

  • inprop: Which properties to get
    • protection: The protection level
    • talkid: The page ID of the talk page for each non-talk page
    • subjectid: The page ID of the parent page for each talk page
    • url: The full (fullurl) and edit (editurl) for each page
    • preload: 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 get
    • edit: Get a token for page edit
    • move: Get a token for page move
    • delete: Get a token for page deletion
  • incontinue: When more results are available, use this to continue

Info: Example[edit | edit source]

Get info about the en:Albert Einstein page

Info: 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

Info: 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

Revisions: Parameters[edit | edit source]

  • rvprop: Which properties to get for each revision
    • ids: 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 flags
    • sha1: SHA-1 (base 16) of the revision
    • comment: 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 bytes
    • content: The revision content. If set, the maximum limit will be 10 times as low
    • tags: 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).
  • 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/rvendid
    • newer: List oldest revisions first NOTE: rvstart/rvstartid has to be lower than rvend/rvendid
  • rvuser: Only list revisions made by this user
  • rvexcludeuser: Do not list revisions made by this user
  • rvexpandtemplates: Expand templates in rvprop=content output
  • rvgeneratexml: Generate XML parse tree for revision content
  • rvparse: Parse revision content. For performance reasons if this option is used, rvlimit is enforced to 1.
  • rvsection: If rvprop=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
  • 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.

Revisions: Example[edit | edit source]

Get data including content for the last revision of titles en:API and en:Main Page

Revisions: 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

Revisions: Possible errors[edit | edit source]

  • 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

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 get (cannot be used with a generator)
    • sortkey: The sort key
    • timestamp: 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 as hidden and !hidden) cannot be used together.
    • hidden: Only list hidden categories
    • !hidden: Don't list hidden categories
  • cllimit: Maximum number of results to return
  • clcontinue: When more results are available, use this to continue
  • clcategories: 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

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: clshow
    • info: 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

Parameters[edit | edit source]

  • iiprop: Which properties to get
    • timestamp: The time and date of the revision (default)
    • user: The user who made the revision (default)
    • comment: The edit comment
    • url: URL of the image
    • size: The image's size in bytes, plus width and height
    • sha1: The image's SHA-1 hash
    • mime: The image's MIME type
    • metadata: Image metadata, if available
    • archivename: Archive name (old images only)
  • iilimit: How many image revisions to return (1 by default)
  • iistart: Timestamp to start listing from
  • iiend: Timestamp to stop listing at
  • iiurlwidth: If iiprop=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
  • iiurlheight: Similar to iiurlwidth

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.

langlinks / ll[edit | edit source]

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

Parameters[edit | edit source]

  • 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.

Example[edit | edit source]

Get a list of language links en:Albert Einstein has

Possible errors[edit | edit source]

None

links / pl[edit | edit source]

MediaWiki version: = 1.9

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 namespaces
  • pllimit : 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

Possible errors[edit | edit source]

None

templates / tl[edit | edit source]

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.

Parameters[edit | edit source]

  • tlnamespace: Only list pages in these namespaces
  • tllimit: How many templates to return. Default: 10. No more than 500 (5000 for bots) allowed.
  • tlcontinue: When more results are available, use this to continue
  • tltemplates: 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

Possible errors[edit | edit source]

None.

images / im[edit | edit source]

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.

Parameters[edit | edit source]

  • imlimit: How many images to return (since MW 1.13 r37270)

Example[edit | edit source]

Get a list of images on en:Albert Einstein's page

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

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

Example[edit | edit source]

Get info about a few categories

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 list
  • dfcontinue: When more results are available, use this to continue

Example[edit | edit source]

List duplicates of two images

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
  • 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

Possible errors[edit | edit source]

None.

See also[edit | edit source]