API:Patrol/es

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

Outdated translations are marked like this.
Other languages:
Deutsch • ‎English • ‎dansk • ‎español • ‎français • ‎polski • ‎română • ‎български • ‎русский • ‎ไทย • ‎中文 • ‎日本語 • ‎한국어
Versión de MediaWiki: 1.14

POST request to patrol a page or a revision.

API documentation


action=patrol

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

Parameters:
rcid

Recentchanges ID to patrol.

Type: integer
revid

Revision ID to patrol.

Type: integer
tags

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

Values (separate with | or alternative):
token

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

This parameter is required.

Example

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

Patrolling a recent change of rcid 437659.

Response

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

Sample code

patrol.py

#!/usr/bin/python3

"""
    patrol.py

    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",
    "type":"patrol",
    "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",
    "rcid":"437659",
    "token": PATROL_TOKEN
}

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

print(DATA)

Posibles errores

In addition to the standard error messages :

Código Información
patroldisabled Patrolling is disabled on this wiki
noautopatrol No tienes permisos para marcar tus propios cambios como verificados.
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

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

Additional notes

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