API:Parameterinformation
Denna sida är en del av MediaWiki Action API-dokumentation. |
MediaWiki-version: | ≥ 1.12 |
GET-begäran att samla in information om andra action API-moduler , och deras parametrar.
API-dokumentation
Exempel
Get-begäran
Skaffa information om
action=parse
, prop=info
och en fejkad query-modul:
Svar
{
"warnings": {
"paraminfo": {
"*": "The module \"query\" does not have a submodule \"blah\"."
}
},
"paraminfo": {
"helpformat": "none",
"modules": [
{
"name": "parse",
"classname": "ApiParse",
"path": "parse",
...
},
{
"name": "info",
"classname": "ApiQueryInfo",
"path": "query+info",
...
}
]
}
}
Exempelkod
Python
#!/usr/bin/python3
"""
paraminfo.py
MediaWiki API Demos
Demo of `Paraminfo` module: Obtain information about other modules.
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "paraminfo",
"format": "json",
"modules": "parse|query+info|query"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)
PHP
<?php
/*
paraminfo.php
MediaWiki API Demos
Demo of `Paraminfo` module: Get information about other action API modules and their parameters.
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "paraminfo",
"format" => "json",
"modules" => "parse|query+info|query"
];
$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 );
var_dump( $result );
JavaScript
/*
paraminfo.js
MediaWiki API Demos
Demo of `Paraminfo` module: Get information about other action API modules and their parameters.
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "paraminfo",
format: "json",
modules: "parse|query+info|query"
};
url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
fetch(url)
.then(function(response){return response.json();})
.then(function(response) {console.log(response);})
.catch(function(error){console.log(error);});
MediaWiki JS
/*
paraminfo.js
MediaWiki API Demos
Demo of `Paraminfo` module: Get information about other action API modules and their parameters.
MIT License
*/
var params = {
action: 'paraminfo',
format: 'json',
modules: 'parse|query+info|query'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
console.log( data );
} );
Parameterhistorik
- v1.25:
- Avvecklade
querymodules
,mainmodule
,pagesetmodule
,formatmodule
Medanpagesetmodule
inte finns uttryckligen via parameternmodules
, är dess parametrar inbäddade i modulerna som den den tillämpas i. Till exempel,modules=purge
kommer returneratitles
,pageids
, osv. - Introducerade
helpformat
- Avvecklade
- v1.19: Introducerade
formatmodules
- v1.15: Introducerade
pagesetmodule
,mainmodule
Se även
- API:Info - hämtar information om sidor.
- API:User - hämtar information om sidor.
- API:Imageinfo - hämtar information om sidor.