API:Errors and warnings

If something goes wrong in an API request, an error or a warning will be thrown (although the HTTP response will usually still be ). Warnings are thrown for non-fatal conditions such as invalid parameters, whereas errors are only thrown for fatal conditions.

Warnings
Warnings are output in the following format: As shown in the example, warnings are grouped by the name of the module that caused them. Multiple warnings from the same module are separated by a newline.

Disabled submodules
Disabled  submodules will always throw the following warning:
 * The "modulename" module has been disabled.

Missing module warnings
If you specify a module in a multi-value list, such as a,  , or   list of query submodules, and the module is not present on a wiki, for example it is implemented by an extension that isn't loaded, then requesting throws the warning "Unrecognized value for parameter ..." and possibly additional warnings for the submodule's parameters. For example for a list query submodule, raremodule, returns
 * "Unrecognized value for parameter 'list': raremodule"

See also Missing module errors below

You can check to see if a module is available before invoking it, see [How do I] check if an API module is available? in the FAQ.

Parameter validation warnings
The MediaWiki API may return the following warnings when validating parameters of any API module. is replaced by the name of the parameter.


 * Too many values supplied for parameter ' paramname ' : the limit is limit
 * Unrecognized value for parameter ' paramname ' : value
 * Unrecognized values for parameter ' paramname ' : value1, value2, value3

Error formats
Since MediaWiki 1.29 errors are localizable, and available in multiple formats. An error (or warning) is expected to consist of a message, an error code (an arbitrary string, usually generated from the message key; see also below), and optional extra data (and associative array). An API response with errors will look like this (assuming ): (The  key will be missing if there is no extra data to display.)

The way the error message is returned to the client is controlled by the  API parameter:
 * html: intended for human display in HTML-capable clients.
 * wikitext:
 * plaintext: intended for human display in HTML-incapable clients.
 * Plaintext conversion is a minimal, best-effort transformation to make the message (assumed to contain wikitext) more readable: tags are removed, HTML entities are replaced, certain HTML tags are intelligently replaced with punctuation.
 * raw: intended as a machine-readable format (note that the error key is more unique than the error code).
 * Parameters can themselves be objects with  and   fields.
 * none: no message information at all.
 * raw: intended as a machine-readable format (note that the error key is more unique than the error code).
 * Parameters can themselves be objects with  and   fields.
 * none: no message information at all.
 * none: no message information at all.

For the formatting modes which involve message lookup (,  and  ) the API parameter   can be used to set the language (only needed when different from the content language) and   to set whether the MediaWiki: namespace can be used to override default error messages.

Error codes are also returned in the  response HTTP header, separated by commas when there are multiple errors.

For an example error response or to test your client's error handling, visit https://en.wikipedia.org/w/api.php?action=blah&errorformat=plaintext&format=jsonfm&formatversion=2

When  is not set (or set to  ), errors will be displayed in the legacy format instead.

Legacy format
In the legacy error format, there is always at most one error; additional ones are discarded. The response looks like this: (ie. extra data is spliced into the object instead of being under the  key).

With  it looks like this:

Error messages in the documentation
Error messages are documented as follows:

Which corresponds to: for XML or: for json. When using a different formatversion than 1 with json, the "*" field will be named "docref" instead.

Disabled modules
Disabled  modules will always fail with the following error:

Missing module errors
If you specify a module as the single value of a parameter such as  and it is not present on a wiki, for example it is implemented by an extension that isn't loaded, then the request throws the error

You can check to see if a module is available before invoking it, see [How do I] check if an API module is available? in the FAQ.

See also Missing module warnings above.

Parameter validation errors
The MediaWiki API can "throw" the following errors when validating parameters of any API modules.

Standard error messages
Some generic error messages are shared among modules. If a module can throw these errors, that's explicitly mentioned in its  section.