As some folks may recall, an action=createaccount was added to the API a few weeks ago. Unfortunately the first pass didn't include CAPTCHA support, so we haven't been able to use it for the live sites yet (which use ConfirmEdit's "FancyCaptcha" mode). We expect to start using this in the next couple weeks for the mobile Commons apps, so it's time to make it captcha-friendly...

I've made a first stab at adding support, based on the existing captcha interfaces for login and editing:

MediaWiki core: https://gerrit.wikimedia.org/r/53793
ConfirmEdit ext: https://gerrit.wikimedia.org/r/53794

So far I've tested it with the default 'math captcha' mode, with this test rig: https://github.com/brion/mw-createaccount-test


If a captcha needs to be run, action=createaccount will spit back a result including a 'captcha' field including several subfields, such as in this example:
https://www.mediawiki.org/wiki/API_talk:Account_creation#Captcha_additions

Since account creation requires a first request to get a token anyway, this shouldn't significantly add to the complexity of using the API.


Text captchas will have a 'question' subfield to be presented; image captchas will have a 'url' field which should be loaded as the image. 'type' and 'mime' will vary, and probably shouldn't be used too closely.

Pass back the captcha id field in 'captchaid' and the response word in 'captchaword' parameters along with the final request, and it should pass the captcha. If the captcha doesn't pass, you get back new captcha info and can continue.


Questions:
* Does this seem to make sense? :)
* Will other API users kill me for this or will it be easy to use?
* Any surprises that may turn up?
* Any bugs/style problems in my code so far?

-- brion