API:Delete
From MediaWiki.org
| 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
| MediaWiki version: | 1.12 |
Token[edit | edit source]
To delete a page, a CSRF token is required. The CSRF token is the same for all pages, but changes at every login. CSRF tokens can be obtained via action=query&meta=tokens with type=csrf (MW 1.24+).
Deleting pages[edit | edit source]
Pages can be deleted with action=delete.
Parameters[edit | edit source]
- title: The page you want to delete.
- pageid: The page id of the page you want to delete
- token: The CSRF token obtained in the previous request. Take care to urlencode the trailing
+\as%2B%5C. - reason: The reason for the deletion (optional). If not provided, an automatically generated reason will be used.
- watch: Add the page to your watchlist
- unwatch: Remove the page from your watchlist
- oldimage: The name of the old image to delete as provided by
iiprop=archivename
Example[edit | edit source]
Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=delete requires POST requests; GET requests will cause an error.
Deleting the Main Page with an auto-generated reason
api.php? action=delete& title=Main%20Page& token=58b54e0bab4a1d3fd3f7653af38e75cb%2B\ [try in ApiSandbox]
| Result |
|---|
{
"delete": {
"title": "Main Page",
"reason": "content was: 'content goes here' and the only contributor was Username",
"logid": 1234567
}
}
|
Possible errors[edit | edit source]
In addition to the usual stuff:
| Code | Info |
|---|---|
| notitle | The title parameter must be set |
| notoken | The token parameter must be set |
| permissiondenied | You don't have permission to delete pages Note: On most wikis, deleting pages is restricted to sysops, but other wikis may have stricter rules. |
| cantdelete | Couldn't delete "title". Maybe it was deleted already by someone else |