API:Edit

Requires the selected MediaWiki to have the following configuration settings set to :   and. See Manual:DefaultSettings.php.

Token
To edit a page, an edit token is required. This token is the same for all pages, but changes at every login. If you want to protect against edit conflicts (which is wise), you also need to get the timestamp of the last revision. You can obtain these as follows:

Editing pages
Pages can be edited and created with.

Parameters

 * : Page to edit
 * : nth section to edit. Use 0 for the top section, 'new' for a new section. Omit if replacing the entire page
 * : New page (or section) content
 * : Edit token
 * : Edit comment
 * When using, this will be used for the section title
 * : If set to true, mark the edit as minor
 * : If set to true, don't mark the edit as minor, even if you have the "Mark all my edits minor by default" preference enabled
 * : If set, mark the edit as bot, even if you are using a bot account the edits will not be marked unless you set this flag
 * : Timestamp of the last revision, used to detect edit conflicts. Leave unset to ignore conflicts
 * : Timestamp when you obtained the edit token. Used to detect page deletions and recreations. Leave unset and use  to ignore conflicts
 * : If set, suppress errors about the page having been deleted in the meantime and recreate it
 * : If set, throw an error if the page already exists
 * : If set, throw a  error if the page doesn't exist
 * : Specify how the watchlist is affected by this edit, set to one of "watch", "unwatch", "preferences", "nochange":
 * : add the page to the watchlist
 * : remove the page from the watchlist
 * : use the preference settings (Default)
 * : don't change the watchlist
 * : MD5 hash (hex) of the  parameter. If this parameter is set and the hashes don't match, the edit is rejected. This can be used to guard against data corruption
 * : CAPTCHA ID from the previous request
 * : Answer to the CAPTCHA
 * : Revision ID to undo. Overrides,   and
 * : Undo all revisions from  up to but not including this one. If not set, just undo one revision

header of your request to. The token that you received is terminated with, this needs to be urlencoded (so it will end with  ) before it is passed back.

CAPTCHAs and extension errors
If an edit requires a CAPTCHA, you'll get something like: In most cases, you won't get a math CAPTCHA, but a URL to an image (in the  field). When you've solved the CAPTCHA, retry the request (in this case with ).

Other extensions that use the APIEditBeforeSave hook may return errors using either the format described above or the usual error format.

Possible errors
In addition to the usual stuff:
 * code: notitle
 * info: The title parameter must be set
 * code: notext
 * info: One of the text, appendtext, prependtext and undo parameters must be set
 * code: notoken
 * info: The token parameter must be set
 * code: invalidsection
 * info: The section parameter must be set to an integer or 'new'
 * code: protectedtitle
 * info: This title has been protected from creation
 * code: cantcreate
 * info: You don't have permission to create new pages
 * code: cantcreate-anon
 * info: Anonymous users can't create new pages
 * code: articleexists
 * info: The article you tried to create has been created already
 * code: noimageredirect-anon
 * info: Anonymous users can't create image redirects
 * code: noimageredirect
 * info: You don't have permission to create image redirects
 * code: spamdetected
 * info: Your edit was refused because it contained a spam fragment: ``wikitext ''
 * code: filtered
 * info: The filter callback function refused your edit
 * code: contenttoobig
 * info: The content you supplied exceeds the article size limit of bytes bytes
 * code: noedit-anon
 * info: Anonymous users can't edit pages
 * code: noedit
 * info: You don't have permission to edit pages
 * code: pagedeleted
 * info: The page has been deleted since you fetched its timestamp
 * code: emptypage
 * info: Creating new, empty pages is not allowed
 * code: emptynewsection
 * info: Creating empty new sections is not possible.
 * code: editconflict
 * info: Edit conflict detected
 * code: revwrongpage
 * info: rrevid is not a revision of ``pagename ''
 * Thrown if an invalid revid is given for  or
 * code: undo-failure
 * info: Undo failed due to conflicting intermediate edits
 * You may also get a error message returned as HTML, of the type
 * info: This is because wikipedia only accept HTTP 1.0 Requests, and some libraries and frameworks, like PHP-cURL use HTTP 1.1 by default. You will have to make your framework send HTTP 1.0 requests. With PHP-CURL, do