واجه التطبيقات البرمجية: كل استخدامات الملف

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

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

GET request' لعرض قائمة تحتوى على جميع استخدامات الملف، بالإضافة إلى غير الموجوده.

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 ملفات تم استخدامها تبدء بكلمة "Icon" وما هو رقم الصفحة التعريفى الذى يستخدمه كل ملف

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