API:Undelete

From MediaWiki.org
Jump to: navigation, search
Tools clipart.png This page is part of the MediaWiki API documentation.
Language: English  • Deutsch • 日本語
MediaWiki API

Quick overview:

v · d · e
MediaWiki version: 1.12

Contents

[edit] Token

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

<?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>

[edit] Restoring deleted revisions

Deleted revisions can be restored with action=undelete.

[edit] Parameters

  • 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.

[edit] Example

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

<?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>

[edit] Possible errors

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.
  • code: cantundelete
    • info: Couldn't undelete: the requested revisions may not exist, or may have been undeleted already