From MediaWiki.org
Jump to: navigation, search
This page is part of the MediaWiki action API documentation.

MediaWiki action API

v · d · e

Returns revisions for a given page, or the latest revision for each of several pages. Pages are specified either by pageids or titles parameter; individual revisions are specified by revids parameter (see API:Query#Specifying pages). When using parameters marked as (enum), titles= must have only one title listed. Prior to version 1.25, this module could not be used as a generator. Version 1.30 deprecated the diffing functionality of this module, and moved it to API:Compare. The code for this query is located on the git repository at ApiQueryRevisions.php.


  • rvprop: Which properties to get for each revision (Default: ids|flags|timestamp|comment|user)
    • ids: Get the revid and, from 1.16 onward, the parentid. 1.11+
    • flags: Whether the revision was a minor edit. 1.11+
    • timestamp: The date and time the revision was made, in ISO 8601 combined date and time format.
    • user: The user who made the revision, and if applicable, the flags: userhidden if revision deleted and/or anon if unregistered.
    • userid: User id of revision creator, as well as userhidden and anon flags. 1.17+
    • size: The size of the revision text in bytes. 1.11+
    • sha1: SHA-1 (base 16) of the revision. 1.19+
    • contentmodel: Content model id of the revision. 1.21+
    • comment: The edit comment.
    • parsedcomment: The edit/log comment in HTML format with wikilinks and section references expanded into hyperlinks 1.16+
    • content: The revision content. If set, the maximum limit will be 10 times as low. (Note: If you want HTML rather than wikitext, use action=parse instead.)
    • tags: Any tags for this revision, such as those added by AbuseFilter. 1.16+
    • parsetree: The XML parse tree of the revision content. 1.26+ (Deprecated in 1.30)
  • 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). (enum) No more than 500 (5000 for bots) allowed.
  • rvexpandtemplates: Expand templates in rvprop=content output. 1.12+ (Deprecated in 1.30)
  • rvgeneratexml: Generate XML parse tree for revision content. 1.14+ (Deprecated in 1.26)
  • rvparse: Parse revision content. For performance reasons if this option is used, rvlimit is enforced to 1. 1.17+ (Deprecated in 1.30)
  • rvsection: If rvprop=content is set, only retrieve the contents of this section. This is an integer, not a string title. 1.13+
  • rvdiffto: Revision ID to diff each revision to. Use "prev", "next" and "cur" for the previous, next and current revision respectively. 1.15+ (Deprecated in 1.30)
  • rvdifftotext: Text to diff each revision to. Only diffs a limited number of revisions. Overrides rvdiffto. If rvsection is set, only that section will be diffed against this text. 1.16+ (Deprecated in 1.30)
  • rvdifftotextpst: Perform a pre-save transform on the text before diffing it. Only valid when used with rvdifftotext. 1.27+ (Deprecated in 1.30)
  • rvcontentformat: Serialization format used for rvdifftotext and expected for output of content. 1.21+
  • 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) (Default: older)
    • older: List newest revisions first. 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. 1.11+
  • rvexcludeuser: Do not list revisions made by this user. 1.11+
  • rvtag: Only list revisions tagged with this tag. 1.16+
  • rvtoken: Gets the rollback token for each revision. Possible values: rollback. 1.12+ (Deprecated in 1.24)
  • 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). 1.15+


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

Possible warnings[edit]

  • Couldn't diff to r######: content is hidden
    • Thrown when the revision has been hidden (e.g., using RevisionDelete or Oversight).
  • Conversion to XML is supported for wikitext only, title uses content model content model
    • Thrown when the parsetree property or generatexml parameter is used and the content model (as returned by the content property) is not set to wikitext
  • Template expansion is supported for wikitext only, title uses content model content model
    • Thrown when the expandtemplates parameter is used and the content model (as returned by the content property) is not set to wikitext
  • The requested format contentFormat is not supported for content model model used by name
    • Thrown when the content of either the current revision or one being diffed to is not supported (typically, not text).
  • Action 'action' is not allowed for the current user
    • Thrown when a token is requested that the current user isn't allowed to use

Possible errors[edit]

Code Info
rvdiffto rvdiffto must be set to "prev", "next", "cur" or a non-negative number.
rvnosuchrevid There is no revision with ID ID
rvnosuchsection There is no section section in rID
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.
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
rvbadformat The requested format contentFormat is not supported for content model model used by name
Note: this is changed to a warning as of MW 1.25