Jump to content

API:RecentChanges

From mediawiki.org
Revision as of 09:05, 30 March 2018 by AbyxDev (talk | contribs) (Example: updated example API responses)

Get all recent changes to the wiki, à la Special:Recentchanges. This module can be used as a generator (but note that, like all other generators, it generates information about pages, not about revisions). This module is implemented by ApiQueryRecentChanges.php.

Note that, although many log actions can be viewed using this module, patrol actions are not among them (because they are not present in the recentchanges table).

Parameters

Please note that by default, the Recentchanges table is queried is in reverse-chronological order with the most recent changes at the start of the list. This means that any specified rcstart value must be later than any specified rcend value. This requirement is reversed if a rcdir=newer is specified.

  • rcdir: Direction to list in (Default: older)
    • older: List newest changes first. Note: rcstart has to be later than rcend.
    • newer: List oldest changes first. Note: rcstart has to be earlier than rcend.
  • rcstart: The timestamp to start listing from (May not be more than $wgRCMaxAge into the past, which on Wikimedia wikis is 30 days[1])
  • rcend: The timestamp to end listing at
  • rcnamespace: Only list changes in these namespaces
  • rcuser: Only list changes made by this user
  • rcexcludeuser: Do not list changes made by this user
  • rctag: Only list changes tagged with this tag
  • rctype: Only list certain types of changes
    • edit: Regular page edits
    • external: External edits
    • new: Page creations (Uploads are not listed as new but as log)
    • log: Log entries
  • rcshow: Only list items that meet these criteria. Conflicting options (such as minor and !minor) cannot be used together
    • minor: Only list minor edits
    • !minor: Don't list minor edits
    • bot: Only list bot edits
    • !bot: Don't list bot edits
    • anon: Only list edits by anonymous users
    • !anon: Only list edits by registered users
    • redirect: Only list edits to pages that are currently redirects
    • !redirect: Only list edits to pages that currently aren't redirects
    • patrolled: Only list edits flagged as patrolled. Only available to users with the patrol right
    • !patrolled: Only list edits not flagged as patrolled. Only available to users with the patrol right
  • rcprop: Which properties to get (Default: timestamp|title|ids)
    • user: The user who made the change. Also returns anon="" if it was an anonymous edit.
    • userid: The user id who made the change.
    • comment: The edit/log comment
    • parsedcomment: The parsed comment for the edit/log comment
    • timestamp: The time and date of the change
    • title: The title the change was made to
    • ids: Gets the following IDs: pageid (rc_cur_id); revid (rc_this_oldid); old_revid (rc_last_oldid); and rcid (rc_id) (used for patrolling).
    • sha1: content checksum for entries associated with a revision
    • sizes: The page size before (oldlen) and after (newlen) the change
    • redirect: Whether the changed page is currently a redirect. When returned, the value is an empty string; not the redirect destination.
    • patrolled: Whether the change is patrolled. Only available to users with the patrol right. When returned, the value is an empty string.
    • loginfo: If the change was a log event, add the logid, logtype and logaction fields and the log parameters 1.13+
    • tags: List tags for the entry
    • flags
      • new: A new page was created
      • minor: The change was a minor edit
      • bot: The change was a bot edit
  • rctoken: Which tokens to obtain for each change (deprecated in 1.24)
  • rclimit: Maximum amount of changes to list (Default: 10)
  • rctoponly: Only list changes which are the latest revision
  • rccontinue: When more results are available, use this to continue
  • rctitles: Restrict results to these page titles 1.14-1.15 (removed in 1.15)

Example

Get the 3 most recent changes with sizes and flags
Result
{
    "batchcomplete": "",
    "continue": {
        "rccontinue": "20180330090522|1041353210",
        "continue": "-||"
    },
    "query": {
        "recentchanges": [
            {
                "type": "edit",
                "ns": 0,
                "title": "Histology",
                "pageid": 13570,
                "revid": 833218500,
                "old_revid": 833218201,
                "rcid": 1041353213,
                "user": "Iztwoz",
                "oldlen": 25718,
                "newlen": 25749
            },
            {
                "type": "edit",
                "ns": 0,
                "title": "Mario Zorzi",
                "pageid": 45004653,
                "revid": 833218498,
                "old_revid": 724129407,
                "rcid": 1041353212,
                "user": "KolbertBot",
                "bot": "",
                "minor": "",
                "oldlen": 1317,
                "newlen": 1318
            },
            {
                "type": "edit",
                "ns": 4,
                "title": "Wikipedia:Categories for discussion/Log/2018 March 29",
                "pageid": 56683912,
                "revid": 833218499,
                "old_revid": 833205660,
                "rcid": 1041353211,
                "user": "Grutness",
                "oldlen": 7799,
                "newlen": 8008
            }
        ]
    }
}

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

Error Codes

Code Info
rcshow Incorrect parameter - mutually exclusive values may not be supplied
rcpermissiondenied You need the patrol right to request the patrolled flag

Output

The "type" that is returned can be 'edit', 'new', 'move', 'categorize', 'log', 'external', or 'move over redirect'.

See also

References