From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page API:Patrol and the translation is 52% complete.

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

ページまたは版を巡回済みにする POST リクエストです。



(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:ログイン .
  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 リクエスト

Patrolling a recent change of rcid 437659.


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

サンプル コード




    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



In addition to the standard error messages :

コード 情報
patroldisabled Patrolling is disabled on this wiki
noautopatrol あなたには自分の編集を巡回済みにする権限がありません。
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.


  • v1.27: tags を導入しました
  • v1.22: revid を導入しました


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