API:Tokens

From MediaWiki.org
Jump to: navigation, search

Other languages:
Deutsch • ‎English • ‎español • ‎français • ‎日本語 • ‎polski • ‎русский • ‎sicilianu • ‎中文
Tools clipart.png This page is part of the MediaWiki action API documentation.
MediaWiki APIsAPI:Main page

MediaWiki action API

v · d · e

For the deprecated action module, see API:Tokens (action)API:Tokens (action).

Gets tokens required by data-modifying actions. If you request one of these actions without providing a token, the API returns an error code such as notoken. This module does not use a prefix. The csrf (cross-site request forgery) token corresponds to the majority of older tokens, like edit and move, that were retrieved using the API action tokens (deprecated in MediaWiki 1.24).

Parameters[edit]

  • type: Type of token(s) to request. (Default: csrf)
    • csrf
    • watch
    • patrol
    • rollback
    • userrights
    • login 1.27+
    • createaccount 1.27+

Example[edit]


Possible errors[edit]

In addition to the usual errors, other errors may be returned in the following format:

<?xml version="1.0"?>
<api batchcomplete="">
  <warnings>
    <tokens xml:space="preserve">Unrecognized value for parameter 'type': XXX</tokens>
  </warnings>
  <query>
    <tokens />
  </query>
</api>

Possible errors include:

  • Unrecognized value for parameter "type"

See also[edit]