API:Tokens
| This page is part of the MediaWiki action API documentation. |
MediaWiki action API
- Introduction and quick start
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Searching (by title, content, coordinates...)
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
- Asserting
| Tokens | ||
|---|---|---|
| Gets tokens for data-modifying actions. This module cannot be used as a Generator. |
||
| Prefix | ||
| Required rights | none | |
| Post only? | No | |
| Generated help | Current | |
| Version added |
|
For the deprecated action module, see 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).
Contents
Parameters[edit]
type: Type of token(s) to request. (Default:csrf)csrfwatchpatrolrollbackuserrightslogin1.27+createaccount1.27+
Example[edit]
| Result |
|---|
<?xml version="1.0"?>
<api>
<query>
<tokens csrftoken="00112233445566778899aabbccddeeff+\" />
</query>
</api>
|
| Result |
|---|
<?xml version="1.0"?>
<api>
<query>
<tokens watchtoken="00112233445566778899aabbccddeeff+\" patroltoken="ffeeddccbbaa99887766554433221100+\" />
</query>
</api>
|
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"

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
