API:rukunin bayanai

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

Outdated translations are marked like this.
Other languages:
Deutsch • ‎English • ‎Hausa • ‎Türkçe • ‎aragonés • ‎dansk • ‎español • ‎français • ‎italiano • ‎polski • ‎português • ‎română • ‎Ελληνικά • ‎български • ‎русский • ‎العربية • ‎سنڌي • ‎ไทย • ‎中文 • ‎日本語 • ‎한국어
MediaWiki version: 1.13

Samu bayanai akan rukuni

API documentation


prop=categoryinfo (ci)

(main | query | categoryinfo)

Returns information about the given categories.

Parameter:
cicontinue

When more results are available, use this to continue.

Example:
Get information about Category:Foo and Category:Bar.
api.php?action=query&prop=categoryinfo&titles=Category:Foo|Category:Bar [open in sandbox]

Misali

GET request

Get info about a few categories

Response

{
    "batchcomplete": "",
    "query": {
        "pages": {
            "-1": {
                "ns": 14,
                "title": "Category:Foo",
                "missing": "",
                "categoryinfo": {
                    "size": 1,
                    "pages": 1,
                    "files": 0,
                    "subcats": 0
                }
            },
            "1504": {
                "pageid": 1504,
                "ns": 0,
                "title": "Albert"
            },
            "3108204": {
                "pageid": 3108204,
                "ns": 14,
                "title": "Category:Infobox templates",
                "categoryinfo": {
                    "size": 2066,
                    "pages": 2048,
                    "files": 0,
                    "subcats": 18
                }
            }
        }
    }
}

Sample code

get_category_info.py

#!/usr/bin/python3

"""
    get_category_info.py

    MediaWiki Action API Code Samples
    Demo of `Categoryinfo` module: Get information about few categories
    MIT license
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "query",
    "format": "json",
    "titles": "Albert|Category:Foo|Category:Infobox",
    "prop": "categoryinfo"
}

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

print(DATA)

Additional notes

  • If the category page exists, but the category has no members, a categoryinfo field will not be included in the API response.
  • Idan da akwai sakamako da dama,yi amfani da wannan ka ci gaba.

See also