API:Pagepropnames/ko
Appearance
From mediawiki.org
This page is a translated version of the page API:Pagepropnames and the translation is 9% complete.
Languages:
이 문서는 MediaWiki Action API 문서의 부분입니다.
| 미디어위키 Action API |
|---|
| 기본 |
| 인증 |
| 계정과 사용자 |
| 문서 운영 방법 |
| 검색 |
| 개발자 유틸리티 |
| 튜토리얼 |
| v · d · e |
미디어위키 버전:
≥ 1.21
GET request to list all page properties in use on the wiki.
API documentation
The following documentation is the output of Special: ApiHelp/ query+pagepropnames, automatically generated by the pre-release version of MediaWiki that is running on this site (MediaWiki.org).
list=pagepropnames (ppn)
- This module requires read rights.
- Source: MediaWiki
- License: GPL-2.0-or-later
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
Example:
- Get first 10 property names.
- api.php?action=query&list=pagepropnames [open in sandbox]
예시
GET request
List all page property names in use on the wiki.
Response
{ "batchcomplete":"", "continue":{ "ppncontinue":"kartographer_frames", "continue":"-||" }, "query":{ "pagepropnames":[ { "propname":"defaultsort" }, { "propname":"disambiguation" }, { "propname":"displaytitle" } ... ] } }
Sample code
Python
#!/usr/bin/python3 """ get_pagepropnames.py MediaWiki API Demos Demo of `Pagepropnames` module: List page property names on the given wiki. MIT License """ importrequests 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 */ varurl="https://en.wikipedia.org/w/api.php"; varparams={ action:"query", list:"pagepropnames", format:"json" }; url=url+"?origin=*"; Object.keys(params).forEach(function(key){url+="&"+key+"="+params[key];}); fetch(url) .then(function(response){returnresponse.json();}) .then(function(response){ varpageprops=response.query.pagepropnames; for(varpinpageprops){ 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 */ varparams={ action:'query', list:'pagepropnames', format:'json' }, api=newmw.Api(); api.get(params).done(function(data){ varpageprops=data.query.pagepropnames, p; for(pinpageprops){ console.log(pageprops[p].propname); } });
See also
- API:Pageswithprop - List all pages using a given page property.
- API:Allpages - List all pages fitting certain criteria, within a given namespace.