API:RecentChanges

From MediaWiki.org
(Redirected from API:Recentchanges)
Jump to navigation Jump to search
MediaWiki version: 1.9

GET Request to list all the recent changes to the wiki, in the same manner as Special:RecentChanges lists them.

API documentation[edit]


list=recentchanges (rc)

(main | query | recentchanges)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Enumerate recent changes.

Parameters:
rcstart

The timestamp to start enumerating from.

Type: timestamp (allowed formats)
rcend

The timestamp to end enumerating.

Type: timestamp (allowed formats)
rcdir

In which direction to enumerate:

newer
List oldest first. Note: rcstart has to be before rcend.
older
List newest first (default). Note: rcstart has to be later than rcend.
One of the following values: newer, older
Default: older
rcnamespace

Filter changes to only these namespaces.

Values (separate with | or alternative): -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 486, 487, 828, 829, 1198, 1199, 2300, 2301, 2302, 2303, 2600, 5500, 5501
To specify all values, use *.
rcuser

Only list changes by this user.

Type: user name
rcexcludeuser

Don't list changes by this user.

Type: user name
rctag

Only list changes tagged with this tag.

rcprop

Include additional pieces of information:

user
Adds the user responsible for the edit and tags if they are an IP.
userid
Adds the user ID responsible for the edit.
comment
Adds the comment for the edit.
parsedcomment
Adds the parsed comment for the edit.
flags
Adds flags for the edit.
timestamp
Adds timestamp of the edit.
title
Adds the page title of the edit.
ids
Adds the page ID, recent changes ID and the new and old revision ID.
sizes
Adds the new and old page length in bytes.
redirect
Tags edit if page is a redirect.
patrolled
Tags patrollable edits as being patrolled or unpatrolled.
loginfo
Adds log information (log ID, log type, etc) to log entries.
tags
Lists tags for the entry.
sha1
Adds the content checksum for entries associated with a revision.
Values (separate with | or alternative): user, userid, comment, parsedcomment, flags, timestamp, title, ids, sizes, redirect, patrolled, loginfo, tags, sha1
Default: title|timestamp|ids
rctoken
Deprecated.

Use action=query&meta=tokens instead.

Values (separate with | or alternative): patrol
rcshow

Show only items that meet these criteria. For example, to see only minor edits done by logged-in users, set rcshow=minor|!anon.

Values (separate with | or alternative): minor, !minor, bot, !bot, anon, !anon, redirect, !redirect, patrolled, !patrolled, unpatrolled, autopatrolled, !autopatrolled
rclimit

How many total changes to return.

No more than 500 (5,000 for bots) allowed.
Type: integer or max
Default: 10
rctype

Which types of changes to show.

Values (separate with | or alternative): edit, new, log, external, categorize
Default: edit|new|log|categorize
rctoponly

Only list changes which are the latest revision.

Type: boolean (details)
rctitle

Filter entries to those related to a page.

rccontinue

When more results are available, use this to continue.

rcgeneraterevisions

When being used as a generator, generate revision IDs rather than titles. Recent change entries without associated revision IDs (e.g. most log entries) will generate nothing.

Type: boolean (details)

Example[edit]

GET Request[edit]

Get the 3 most recent changes with sizes and flags

Response[edit]

{
    "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
            }
            ...
        ]
    }
}

Sample code[edit]

get_recent_changes.py

#!/usr/bin/python3

"""
    get_recent_changes.py

    MediaWiki Action API Code Samples
    Demo of `RecentChanges` module: Get the three most recent changes 
    with sizes and flags

    MIT License
"""

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

PARAMS = {
    "format": "json",
    "rcprop": "title|ids|sizes|flags|user",
    "list": "recentchanges",
    "action": "query",
    "rclimit": "3"
}

R = S.get(url=URL, params=PARAMS)
DATA = R.json()

print(DATA)

Possible errors[edit]

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

Parameter history[edit]

  • v1.24: Deprecated rctoken
  • v1.15: Removed rctitles
  • v1.14: Introduced rctitles
  • v1.13: Introduced loginfo

Additional notes[edit]

See also[edit]