From MediaWiki.org
Jump to navigation Jump to search

Other languages:
Deutsch • ‎English • ‎dansk • ‎español • ‎français • ‎polski • ‎română • ‎български • ‎русский • ‎ไทย • ‎中文 • ‎日本語 • ‎한국어
MediaWiki version: 1.14

POST request to patrol a page or a revision.

API documentation[edit]


(main | patrol)
  • This module requires read rights.
  • This module requires write rights.
  • This module only accepts POST requests.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Patrol a page or revision.


Recentchanges ID to patrol.

Type: integer

Revision ID to patrol.

Type: integer

Change tags to apply to the entry in the patrol log.

Values (separate with | or alternative):

A "patrol" token retrieved from action=query&meta=tokens

This parameter is required.


Patrolling a request is a multi-step process:

  1. Log in, via one of the methods described on API:Login .
  2. GET a patrol token . This token is the same for all pages, but changes at every login.
  3. Send a POST request, with the patrol token, to patrol a request.

The sample code below covers the final step in detail.

POST request[edit]

Patrolling a recent change of rcid 437659.


  "patrol": {
    "rcid": 437659,
    "ns": 0,
    "title": "Sandbox"

Sample code[edit]




    MediaWiki API Demos
    Demo of `Patrol` module: Patrol a recent change
    MIT license

import requests

S = requests.Session()

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

# Step 1: Retrieve a login token
PARAMS_1 = {
    "action": "query",
    "meta": "tokens",
    "type": "login",
    "format": "json"

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

LOGIN_TOKEN = DATA['query']['tokens']['logintoken']

# Step 2: Send a POST request to log in. For this login
# method, obtain bot credentials by first visiting
# https://www.test.wikipedia.org/wiki/Manual:Bot_passwords
# See https://www.mediawiki.org/wiki/API:Login for more
# information on log in methods.
PARAMS_2 = {
    "action": "login",
    "lgname": "name",
    "lgpassword": "password",
    "format": "json",
    "lgtoken": LOGIN_TOKEN

R = S.post(URL, data=PARAMS_2)
DATA = R.json()

# Step 3: While logged in, retrieve a patrol token
PARAMS_3 = {
    "action": "query",
    "meta": "tokens",
    "format": "json"

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

PATROL_TOKEN = DATA["query"]["tokens"]["patroltoken"]

# Step 4: Send a POST request to patrol the recent change
PARAMS_4 = {
    "action": "patrol",
    "format": "json",
    "token": PATROL_TOKEN

R = S.post(url=URL, data=PARAMS_4)
DATA = R.text


Possible errors[edit]

In addition to the standard error messages :

Code Info
patroldisabled Patrolling is disabled on this wiki
noautopatrol You are not allowed to mark your own changes as patrolled.
Only users with the autopatrol right can do this
notpatrollable The revision rid can't be patrolled as it's too old.
nosuchrcid There is no recent change with ID rcid.
nosuchrevid There is no revision with ID revid.

Parameter history[edit]

  • v1.27: Introduced tags
  • v1.22: Introduced revid

Additional notes[edit]

  • For MediaWiki versions earlier than 1.17, the patrol token is the same the edit token.
  • autopatrol rights are required in order to use this module.
  • revid and rcid may be obtained through API:Recentchanges .