API:Pagepropnames

This page is a translated version of the page API:Pagepropnames and the translation is 100% complete.
MediaWiki バージョン:
1.21

ウィキで使用されているページ プロパティをすべて列挙する GET リクエストです。

APIの説明文書


list=pagepropnames (ppn)

(main | query | pagepropnames)

List all page property names in use on the wiki.

Specific parameters:
Other general parameters are available.
ppncontinue

When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.

ppnlimit

The maximum number of names to return.

Type: integer or max
The value must be between 1 and 500.
Default: 10

GET リクエスト

ウィキで使用されているページ プロパティをすべて列挙します。


レスポンス

{
    "batchcomplete": "",
    "continue": {
        "ppncontinue": "kartographer_frames",
        "continue": "-||"
    },
    "query": {
        "pagepropnames": [
            {
                "propname": "defaultsort"
            },
            {
                "propname": "disambiguation"
            },
            {
                "propname": "displaytitle"
            }
            ...
        ]
    }
}

サンプル コード

Python

#!/usr/bin/python3

"""
    get_pagepropnames.py

    MediaWiki API Demos
    Demo of `Pagepropnames` module: List page property names on the given wiki.

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "query",
    "list": "pagepropnames",
    "format": "json"
}

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

PAGEPROPS = DATA["query"]["pagepropnames"]

for p in PAGEPROPS:
    print(p["propname"])

PHP

<?php
/*
    get_pagepropnames.php

    MediaWiki API Demos
    Demo of `Pagepropnames` module: List page property names on the given wiki.

    MIT License
*/

$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
    "action" => "query",
    "list" => "pagepropnames",
    "format" => "json"
];

$url = $endPoint . "?" . http_build_query( $params );

$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );

$result = json_decode( $output, true );

foreach( $result["query"]["pagepropnames"] as $k => $v ) {
    echo( $v["propname"] . "\n" );
}

JavaScript

/*
    get_pagepropnames.js

    MediaWiki API Demos
    Demo of `Pagepropnames` module: List page property names on the given wiki.

    MIT License
*/

var url = "https://en.wikipedia.org/w/api.php"; 

var params = {
    action: "query",
    list: "pagepropnames",
    format: "json"
};

url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});

fetch(url)
    .then(function(response){return response.json();})
    .then(function(response) {
        var pageprops = response.query.pagepropnames;
        for (var p in pageprops) {
            console.log(pageprops[p].propname);
        }
    })
    .catch(function(error){console.log(error);});

MediaWiki JS

/*
	get_pagepropnames.js

	MediaWiki API Demos
	Demo of `Pagepropnames` module: List page property names on the given wiki.

	MIT License
*/

var params = {
		action: 'query',
		list: 'pagepropnames',
		format: 'json'
	},
	api = new mw.Api();

api.get( params ).done( function ( data ) {
	var pageprops = data.query.pagepropnames,
		p;
	for ( p in pageprops ) {
		console.log( pageprops[ p ].propname );
	}
} );

関連項目

  • API:Pageswithprop - 指定したページ プロパティを使用しているページをすべて列挙します。
  • API:すべてのページ - 指定した名前空間内で、指定した条件に合致するページをすべて列挙します。