It should be easy to go from seeing a MediaWiki API example, to seeing its dynamic output, to experimenting based on the example.
Currently
We have three ways to make an API request and see a response
- api.php has examples from PHP code shown as query strings (sample). Click one and the browser executes it and shows the response.
- GET requests only, no POSTs
- API wiki pages have similar examples using mw:Template:ApiEx (sample). Click one and the browser executes it and shows the response, and you can expand to see API response (currently static)
- GET requests only, no POSTs
- the API response is static text that someone copy-pasted
- Special:ApiSandbox is an interactive sandbox. Choose an action and it has buttons to show documentation and examples (generated from source, like api.php). It can do POSTs.
- Doesn't support some query submodules.
Some ideas:
- Link the sample API requests in the first two to Special:ApISandbox, pre-populating its fields.
- In that mode Special:ApISandbox could look more like the api.php help instead of a confusing form.
- We can transclude the generated API help in wiki pages, e.g. {{Special:ApiHelp/query+extracts}}
- Somehow automate the insertion of static API results into the wiki page.
- We could add JavaScript to the first two to give users a little sandbox window. It would initially show the canned example query and show the result; maybe even let you edit the query as in a JSFiddle and see the new results. Similar to OOjsUI demos and the OOjs UI Living Style Guide
- There are some security implications (e.g. vandal modifies wiki page, gets users to make bad API requests).