API:Help

MediaWiki version:
1.8

GET request to display help for the specified modules.

API documentation

edit

action=help

(main | help)

Display help for the specified modules.

Specific parameters:
Other general parameters are available.
modules

Modules to display help for (values of the action and format parameters, or main). Can specify submodules with a +.

Separate values with | or alternative.
Maximum number of values is 50 (500 for clients that are allowed higher limits).
Default: main
submodules

Include help for submodules of the named module.

Type: boolean (details)
recursivesubmodules

Include help for submodules recursively.

Type: boolean (details)
wrap

Wrap the output in a standard API response structure.

Type: boolean (details)
toc

Include a table of contents in the HTML output.

Type: boolean (details)


Example

edit

GET request

edit
Get help for a specified module.

Response

edit
{
    "help": {
        "mime": "text/html",
        "filename": "api-help.html",
        "help": "<!DOCTYPE html>\n<html class=\"client-nojs\" lang=\"en\" dir=\"ltr\">\n<head>\n<meta charset=\"UTF-8\"/>\n<title>MediaWiki API help - Wikipedia</title>\n<script>document.documentElement.className=\"client-js\";RLCONF={\"wgBreakFrames\":!0,\"wgSeparatorTransformTable\":[\"\",\"\"],\"wgDigitTransformTable\":[\"\",\"\"],\"wgDefaultDateFormat\":\"dmy\",\"wgMonthNames\":
...
    }
}

Sample code

edit

Python

edit
#!/usr/bin/python3

"""
    get_help.py

    MediaWiki API Demos
    Demo of `Help` module: Get help for a specified module.

    MIT License
"""

import requests

S = requests.Session()

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

PARAMS = {
    "action": "help",
    "modules": "query+tokens",
    "wrap": "",
    "format": "json"
}

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

print(DATA)
<?php
/*
    get_help.php

    MediaWiki API Demos
    Demo of `Help` module: Get help for a specified module.

    MIT License
*/

$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
    "action" => "help",
    "modules" => "query+tokens",
    "wrap" => "",
    "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 );
var_dump( $result );

JavaScript

edit
/*
    get_help.js

    MediaWiki API Demos
    Demo of `Help` module: Get help for a specified module.

    MIT License
*/

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

var params = {
    action: "help",
    modules: "query+tokens",
    wrap: "",
    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) {console.log(response);})
    .catch(function(error){console.log(error);});

MediaWiki JS

edit
/*
	get_help.js

	MediaWiki API Demos
	Demo of `Help` module: Get help for a specified module.

	MIT License
*/

var params = {
		action: 'help',
		modules: 'query+tokens',
		wrap: '',
		format: 'json'
	},
	api = new mw.Api();

api.get( params ).done( function ( data ) {
	console.log( data );
} );

Possible errors

edit
Code Info
badmodule The module name does not have a submodule "name2".

Parameter history

edit
  • v1.25: Introduced submodules, recursivesubmodules, wrap, toc
  • v1.25: Removed querymodules
  • v1.21: Deprecated querymodules
  • v1.17: Introduced action, format, main

See also

edit
  • API:Main page - provides an overview of the MediaWiki action API.
  • API:FAQ - provides answers to some frequently asked questions about the MediaWiki Action API.