API:Undelete

Viewing deleted revisions
Deleted revisions can be viewed with list=deletedrevs.

Parameters

 * titles: Pipe-separated list of titles to list deleted revisions for (optional). If not specified, all deleted revisions will be listed.
 * drstart: The timestamp to start listing from (optional). If not specified, all revisions before drend will be listed.
 * drend: The timestamp to end listing at (optional). If not specified, all revisions later than drstart will be listed.
 * drdir: Direction to list in.
 * older: List newest revisions first (default). Note: drstart has to be later than drend.
 * newer: List oldest revisions first. Note: drstart has to be before drend.
 * drnamespace: Pipe-separated list of namespace numbers to search in. By default, all namespaces will be searched.
 * drlimit: Maximum number of revisions to get. If not specified, 10 revisions will be listed.
 * drprop: A pipe-separated list of properties to get. Possible values are revid, user, comment, minor, len, content and token. The default value is user|comment.

Possible errors
All errors are formatted as: Naturally, all errors reported by action=query can also occur.
 * code: drpermissiondenied
 * info: You don't have permission to view deleted revisions
 * On most wikis, viewing deleted revisions is restricted to sysops, but other wikis may have stricter rules.

Restoring deleted revisions
Deleted revisions can be restored with action=undelete. Note that you need to obtain an undelete token through list=deletedrevs, as demonstrated in the previous example. This token is equal to the edit token and the same for all pages, but changes at every login.

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.

Possible errors
All errors are formatted as:


 * 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: blocked
 * info: You have been blocked from editing
 * code: readonly
 * info: The wiki is in read-only mode
 * In read-only mode, absolutely nothing can be changed.
 * code: badtoken
 * info: Invalid token
 * code: invalidtitle
 * info: Bad title title
 * This means title contains invalid characters or is blank. Note that titles like Talk: and User: are also considered blank.
 * code: norevs
 * info: No revisions could be restored
 * This means the page you're trying to restore has no deleted revisions.
 * code: revsnotfound
 * info: Not all requested revisions could be found
 * This means one of the timestamps you specified doesn't have a matching deleted revision.
 * code: unknownerror
 * info: Undeletion failed with unknown error
 * This usually means some very rare coincidence occurred. Try the same request again, and you'll get a sensible error message.