API:Rollback
![]() |
This page is part of the MediaWiki API documentation. |
Language: | English • Deutsch • 日本語 |
---|
Quick overview:
- Quick start guide
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Authentication
- Queries
- Search suggestions
- Expanding templates and rendering
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
MediaWiki version: | 1.12 |
Contents |
[edit] Rollback
Rolling back a page means undoing the last series of edits by one user. In other words, rollback keeps undoing revision after revision until it encounters one made by someone different. This functionality is identical to the one provided by the [rollback] links in the graphical interface. The rollback revision will be marked as minor. Optionally, both the rollback and the edits being rolled back can be marked as bot, which hides them from Special:Recentchanges by default.
[edit] Token
To rollback a page, a rollback token is required. Unlike most other tokens, rollback tokens aren't universal: they're not only different for every login, but also depend on the title of the page and the name of the user whose edits are to be rolled back. A rollback token can be obtained as follows: Obtaining a rollback token
<?xml version="1.0" encoding="utf-8"?> <api> <query> <pages> <page pageid="5" ns="0" title="Main Page" rollbacktoken="094a45ddbbd5e90d55d79d2a23a8c921+\"> <revisions> <rev revid="20" user="Catrope" timestamp="2007-09-03T20:32:20Z" /> </revisions> </page> </pages> </query> </api>
[edit] Rolling back pages
Pages can be rolled back with action=rollback.
[edit] Parameters
title
: The page you want to rollback.token
: The token obtained in the previous request. Take care to urlencode the '+' as '%2B'.user
: The author of the last revision.summary
: Edit summary (optional). If not set, a default summary will be used.markbot
: If set, both the rollback and the revisions being rolled back will be marked as bot edits.
[edit] Example
Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=rollback requires POST requests; GET requests will cause an error. Rollback Username's edits to the Main Page with a default summary, and mark them as bot edits
<?xml version="1.0" encoding="utf-8"?> <api> <rollback title="Main Page" pageid="5" summary="Reverted edits by [[Special:Contributions/Username|Username]] ([[User talk:Username|Talk]]); changed back to last version by [[User:PreviousEditor|PreviousEditor]]" revid="28" old_revid="27" last_revid="20" /> </api>
[edit] Returned fields
revid
: The revision ID of the rollback.old_revid
: The revision ID of the first (most recent) revision that was rolled back.last_revid
: The revision ID of the last (oldest) revision that was rolled back.
If rolling back wouldn't change the page, no new revision is made. In this case, revid
will be equal to old_revid
.
[edit] Possible errors
In addition to the usual stuff:
- code: notitle
- info: The title parameter must be set
- code: nouser
- info: The user parameter must be set
- code: notoken
- info: The token parameter must be set
- code: alreadyrolled
- info: The page you tried to rollback was already rolled back
- code: onlyauthor
- info: The page you tried to rollback only has one author