API:Allfileusages

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

Outdated translations are marked like this.
Other languages:
Deutsch • ‎English • ‎dansk • ‎español • ‎français • ‎polski • ‎português do Brasil • ‎română • ‎български • ‎русский • ‎العربية • ‎سنڌي • ‎ไทย • ‎中文 • ‎日本語 • ‎한국어
MediaWiki version: 1.22

แสดงรายการไฟล์ทั้งหมดรวมถึงไฟล์ที่ไม่มีอยู่

API documentation


list=allfileusages (af)

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

List all file usages, including non-existing.

Parameters:
afcontinue

When more results are available, use this to continue.

affrom

The title of the file to start enumerating from.

afto

The title of the file to stop enumerating at.

afprefix

Search for all file titles that begin with this value.

afunique

Only show distinct file titles. Cannot be used with afprop=ids.

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

Type: boolean (details)
afprop

Which pieces of information to include:

ids
Adds the page IDs of the using pages (cannot be used with afunique).
title
Adds the title of the file.
Values (separate with | or alternative): ids, title
Default: title
aflimit

How many total items to return.

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

The direction in which to list.

One of the following values: ascending, descending
Default: ascending

ตัวอย่าง

GET request

แสดงรายการไฟล์ที่ใช้ 10 ไฟล์แรกโดยเริ่มจากคำว่า "ไอคอน" และใช้รหัสผ่านของหน้าเว็บใด

Response

{
    "batchcomplete": "",
    "continue": {
        "afcontinue": "Icon-C4004.jpg|7174658",
        "continue": "-||"
    },
    "query": {
        "allfileusages": [
            {
                "fromid": 12221220,
                "ns": 6,
                "title": "File:Icon"
            },
            {
                "fromid": 12274856,
                "ns": 6,
                "title": "File:Icon"
            },
            {
                "fromid": 14729339,
                "ns": 6,
                "title": "File:Icon"
            }
            ...
        ]
    }
}

Sample code

get_allfileusages.py

#This file is auto-generated. See modules.json and autogenerator.py for details

#!/usr/bin/python3

"""
    get_allfileusages.py

    MediaWiki Action API Code Samples
    Demo of `allfileusage` module: List all file usages, including 
    non-existing

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "query",
    "afprefix": "Icon",
    "list": "allfileusages",
    "afprop": "ids|title",
    "format": "json"
}

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

print(DATA)

See also