API:Parameter information/ca
Appearance
This page is part of the MediaWiki Action API documentation. |
MediaWiki version: | ≥ 1.12 |
GET request to obtain information about other action API modules , and their parameters.
API documentation
Exemple
GET request
Getting information about
action=parse
, prop=info
, and a bogus query module:Response
{
"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",
...
}
]
}
}
Sample code
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 );
} );
Parameter history
- v1.25:
- Deprecated
querymodules
,mainmodule
,pagesetmodule
,formatmodule
Whilepagesetmodule
is not available distinctly through themodules
parameter, its parameters are rolled into the modules to which it applies. For example,modules=purge
will returntitles
,pageids
, etc. - Introduced
helpformat
- Deprecated
- v1.19: Introduced
formatmodules
- v1.15: Introduced
pagesetmodule
,mainmodule
See also
- API:Info - retrieves information about pages.
- API:User - retrieves information about users.
- API:Imageinfo - retrieves information about images.