API:Undelete
From MediaWiki.org
This page is part of the MediaWiki API documentation. |
Language: | English • Deutsch • 日本語 • 한국어 |
---|
Quick overview:
- Quick start guide
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Search suggestions
- 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
MediaWiki version: | = 1.12 |
Token[edit | edit source]
You need to obtain an undelete token through list=deletedrevs before you can restore any revisions. This token is equal to the edit token and the same for all pages, but changes at every login.
Get an undelete token
Result |
---|
The following content has been placed in a collapsed box for improved usability. |
<?xml version="1.0" encoding="utf-8"?> <api> <query-continue> <deletedrevs drstart="20070904142729" /> </query-continue> <query> <deletedrevs> <page title="Main Page" ns="0" token="e4c475f13be7824135b4edbebf4140ff+\"> <revisions> <rev timestamp="20070904200804" revid="31" user="Catrope" minor="" len="" /> <rev timestamp="20070904200753" revid="30" user="Catrope" minor="" len="" /> <rev timestamp="20070904193501" revid="29" user="Catrope" minor="" len="568" /> <rev timestamp="20070904193213" revid="28" user="Catrope" minor="" len="470" /> <rev timestamp="20070904193103" revid="27" user="192.168.1.3" len="568" /> <rev timestamp="20070904193048" revid="26" user="192.168.1.3" len="480" /> </revisions> </page> <page title="User:Catrope" ns="2" token="e4c475f13be7824135b4edbebf4140ff+\"> <revisions> <rev timestamp="20070904143938" revid="24" user="Catrope" len="52" /> <rev timestamp="20070904142758" revid="23" user="Catrope" len="37" /> </revisions> </page> </deletedrevs> </query> </api> |
The above content has been placed in a collapsed box for improved usability. |
Restoring deleted revisions[edit | edit source]
Deleted revisions can be restored with action=undelete.
Parameters[edit | edit source]
- title: The page you want to undelete.
- token: The token obtained in the previous request. Take care to urlencode the '+' as '%2B'.
- reason: The reason for the undeletion (optional).
- timestamps: A pipe-separated list of timestamps of the revisions to restore (optional). By default, all revisions will be restored.
- You can get these timestamps through list=deletedrevs.
Example[edit | edit source]
Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=undelete requires POST requests; GET requests will cause an error. Restore the last 5 revisions of the Main Page
Result |
---|
The following content has been placed in a collapsed box for improved usability. |
<?xml version="1.0" encoding="utf-8"?> <api> <undelete title="Main Page" revisions="5" fileversions="0" reason="5 revision(s) restored: Deleted by accident" /> </api> |
The above content has been placed in a collapsed box for improved usability. |
Possible errors[edit | edit source]
In addition to the usual stuff:
- code: notitle
- info: The title parameter must be set
- code: notoken
- info: The token parameter must be set
- code: permissiondenied
- info: You don't have permission to restore deleted revisions
- On most wikis, restoring deleted revisions is restricted to sysops, but other wikis may have stricter rules.
- info: You don't have permission to restore deleted revisions
- code: cantundelete
- info: Couldn't undelete: the requested revisions may not exist, or may have been undeleted already