API:Protectedtitles/es

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

Other languages:
English • ‎español • ‎français • ‎polski • ‎中文 • ‎日本語
Versión de MediaWiki: 1.15

GET request to list titles protected from creation.

This module can be used as a generator .

API documentation


list=protectedtitles (pt)

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

List all titles protected from creation.

Parameters:
ptnamespace

Only list titles in these namespaces.

Values (separate with | or alternative): 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 *.
ptlevel

Only list titles with these protection levels.

Values (separate with | or alternative): autoconfirmed, sysop
ptlimit

How many total pages to return.

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

In which direction to enumerate:

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

Start listing at this protection timestamp.

Type: timestamp (allowed formats)
ptend

Stop listing at this protection timestamp.

Type: timestamp (allowed formats)
ptprop

Which properties to get:

timestamp
Adds the timestamp of when protection was added.
user
Adds the user that added the protection.
userid
Adds the user ID that added the protection.
comment
Adds the comment for the protection.
parsedcomment
Adds the parsed comment for the protection.
expiry
Adds the timestamp of when the protection will be lifted.
level
Adds the protection level.
Values (separate with | or alternative): timestamp, user, userid, comment, parsedcomment, expiry, level
Default: timestamp|level
ptcontinue

When more results are available, use this to continue.

Ejemplo

GET request

Get the first 2 titles only sysops can create.

Response

{
    "batchcomplete": "",
    "continue": {
        "ptcontinue": "20190520051937|118|Dj_Consequence",
        "continue": "-||"
    },
    "query": {
        "protectedtitles": [
            {
                "ns": 118,
                "title": "Draft:DJ Consequence",
                "timestamp": "2019-05-20T05:34:39Z",
                "level": "sysop"
            },
            {
                "ns": 0,
                "title": "DJ Consequence",
                "timestamp": "2019-05-20T05:20:31Z",
                "level": "sysop"
            }
        ]
    }
}

Código de ejemplo

get_protectedtitles.py

#!/usr/bin/python3

"""
    get_protectedtitles.py

    MediaWiki API Demos
    Demo of `Protectedtitles` module: Get the first 2 titles which
    only sysops can create

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "query",
    "format": "json",
    "list": "protectedtitles",
    "ptlevel": "sysop",
    "ptlimit": "2"
}

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

print(DATA)

Historial de parámetros

  • v1.23: Introduced continue
  • v1.17: Introducido userid
  • v1.16: Introducido parsedcomment

Véase también

  • API:Protege - cambiar el nivel de protección de una página.