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

Other languages:
Deutsch • ‎English • ‎dansk • ‎español • ‎français • ‎polski • ‎日本語
MediaWiki version: 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.


When more results are available, use this to continue.


The title of the link to start enumerating from.


The title of the link to stop enumerating at.


Search for all linked titles that begin with this value.


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)

Which pieces of information to include:

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

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

How many total items to return.

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

The direction in which to list.

One of the following values: ascending, descending
Default: ascending
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]


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.


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

Sample code




    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"


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


Possible errors

Code Info
badcontinue Invalid continue param. You should pass the original value returned by the previous query.
invalidparammix The alprop=ids parameter cannot be used with alunique.
This happens when you use alprop=ids and alunique together

Additional notes

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

See also