API:Alllinks/es

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

Other languages:
Deutsch • ‎English • ‎dansk • ‎español • ‎français • ‎polski • ‎日本語
Versión de MediaWiki: 1.11

GET request to list links that point to a given namespace , ordered by title.

This module can be used as a generator.

API documentation


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

Enumerate all links that point to a given namespace.

Parameters:
alcontinue

When more results are available, use this to continue.

alfrom

The title of the link to start enumerating from.

alto

The title of the link to stop enumerating at.

alprefix

Search for all linked titles that begin with this value.

alunique

Only show distinct linked titles. Cannot be used with alprop=ids.

When used as a generator, yields target pages instead of source pages.

Type: boolean (details)
alprop

Which pieces of information to include:

ids
Adds the page ID of the linking page (cannot be used with alunique).
title
Adds the title of the link.
Values (separate with | or alternative): ids, title
Default: title
alnamespace

The namespace to enumerate.

One of the following values: -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
Default: 0
allimit

How many total items to return.

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

The direction in which to list.

One of the following values: ascending, descending
Default: ascending
Examples:
List linked titles, including missing ones, with page IDs they are from, starting at B.
api.php?action=query&list=alllinks&alfrom=B&alprop=ids|title [open in sandbox]
List unique linked titles.
api.php?action=query&list=alllinks&alunique=&alfrom=B [open in sandbox]
Gets all linked titles, marking the missing ones.
api.php?action=query&generator=alllinks&galunique=&galfrom=B [open in sandbox]
Gets pages containing the links.
api.php?action=query&generator=alllinks&galfrom=B [open in sandbox]

Ejemplo

By default, this module will return duplicates if a page contains multiple links pointing to the same namespace. This example uses alunique=1 to remove any duplicate titles in the response.

GET request

List distinct links (i.e. no duplicates) which point to the main namespace.

Respuesta

{
    "batchcomplete": "",
    "continue": {
        "alcontinue": "!!!!Hashtagging",
        "continue": "-||"
    },
    "query": {
        "alllinks": [
            {
                "ns": 0,
                "title": "!"
            },
            {
                "ns": 0,
                "title": "!!"
            },
            {
                "ns": 0,
                "title": "!!!"
            },
            ...
}

Sample code

get_alllinks.py

#!/usr/bin/python3

"""
    get_alllinkinks.py

    MediaWiki Action API Code Samples
    Demo of `Alllinks` module: List links 
    pointing to a given namespace.
    MIT license
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action":"query",
    "format":"json",
    "list":"alllinks",
    "alunique":"1"
}

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

print(DATA)

Possible errors

Código Información
badcontinue Parámetro continue no válido. Debes pasar el valor original devuelto por la consulta anterior.
invalidparammix El parámetro alprop=ids no se puede utilizar junto con alunique.
This happens when you use alprop=ids and alunique together

Notas adicionales

  • As with other link modules within the Action API , this module returns the titles of the pages that link to the namespace, not the exact URIs to those pages.
  • This module can be used as a generator.
  • Previous versions would return an error if the user tried to run this module as a generator, and alunique was set to true. This was altered in v1.24, to allow using the module as a generator even if alunique is true.

Véase también