API talk:Calling internally

Creating Pages from within the MediaWiki interface
If you are writing an extension that creates pages from within the MediaWiki user interface, you will be bypassing the API entry script, api.php. Therefore, you will need to pass the arguments normally handled by this script.

For example, api.php takes care of passing $wgEnableWriteAPI as the second parameter when you create an object from the ApiMain class; however your script will need to handle this by passing the value yourself:

If you don't pass the "true" value as the second parameter, your script will error out, and you'll get a stack trace and error message:

Unexpected non-MediaWiki exception encountered, of type "UsageException" noapiwrite: Editing of this wiki through the API is disabled. Make sure the $wgEnableWriteAPI=true; statement is included in the wiki's LocalSettings.php file --Lhridley 20:53, 12 July 2009 (UTC)

doEdit is deprecated
The main page recommends calling WikiPage::doEdit; however, that function is deprecated as of 1.21. Maiden taiwan (talk) 16:53, 17 April 2014 (UTC)
 * Also $user->editToken is recommended on the main page but deprecated. Maiden taiwan (talk) 17:04, 17 April 2014 (UTC)

Complete example of editing a page?
It would be great to see a working example (1.21+) of a script that obtains an edit token and makes an edit via the API. Maiden taiwan (talk) 17:59, 17 April 2014 (UTC)