API:Alltransclusions/bn

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

Other languages:
English • ‎polski • ‎русский • ‎বাংলা • ‎日本語
মিডিয়াউইকির সংস্করণ: 1.21

GET request to list all existing and non-existing transclusions .

This module can be used as a generator .

API documentation


list=alltransclusions (at)

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

List all transclusions (pages embedded using {{x}}), including non-existing.

Parameters:
atcontinue

When more results are available, use this to continue.

atfrom

The title of the transclusion to start enumerating from.

atto

The title of the transclusion to stop enumerating at.

atprefix

Search for all transcluded titles that begin with this value.

atunique

Only show distinct transcluded titles. Cannot be used with atprop=ids.

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

Type: boolean (details)
atprop

Which pieces of information to include:

ids
Adds the page ID of the transcluding page (cannot be used with atunique).
title
Adds the title of the transclusion.
Values (separate with | or alternative): ids, title
Default: title
atnamespace

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: 10
atlimit

How many total items to return.

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

The direction in which to list.

One of the following values: ascending, descending
Default: ascending
Examples:
List transcluded titles, including missing ones, with page IDs they are from, starting at B.
api.php?action=query&list=alltransclusions&atfrom=B&atprop=ids|title [open in sandbox]
List unique transcluded titles.
api.php?action=query&list=alltransclusions&atunique=&atfrom=B [open in sandbox]
Gets all transcluded titles, marking the missing ones.
api.php?action=query&generator=alltransclusions&gatunique=&gatfrom=B [open in sandbox]
Gets pages containing the transclusions.
api.php?action=query&generator=alltransclusions&gatfrom=B [open in sandbox]

Example

GET request

Get three unique pages in the main namespace which contain transclusions.

Response

{
    "batchcomplete": "",
    "continue": {
        "atcontinue": "!Hero_(album)",
        "continue": "-||"
    },
    "query": {
        "alltransclusions": [
            {
                "ns": 0,
                "title": "!!Destroy-Oh-Boy!!"
            },
            {
                "ns": 0,
                "title": "!Action Pact!"
            },
            {
                "ns": 0,
                "title": "!Arriba!"
            }
        ]
    }
}

Sample code

get_alltransclusions.py

#!/usr/bin/python3

"""
    get_alltransclusions.py

    MediaWiki API Demos
    Demo of `Alltransclusions` module: Get three unique pages in the main
    namespace which contain transclusions.

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "query",
    "format": "json",
    "list": "alltransclusions",
    "atunique": "1",
    "atnamespace": "0",
    "atlimit": "3"
}

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

print(DATA)

Possible errors

Code Info
unknown_atnamespace Unrecognized value for parameter atnamespace: value.

Results from enumerating a non-existent namespace.

Additional notes

See also