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 ([[ https://www.mediawiki.org/w/api.php?action=help&modules=query%2Bimageinfo | sample]]). Click one and the browser executes it and shows the response.
- GET requests only, no POSTs
- API wiki pages have similar examples using [[https://www.mediawiki.org/wiki/Template:ApiEx | mw:Template:ApiEx]] ([[ https://www.mediawiki.org/wiki/API:Properties#imageinfo_.2F_ii | 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
- [[ https://www.mediawiki.org/wiki/Special:ApiSandbox | 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 embed the generated API help in wiki pages.
- We could add JavaScript to the first two to give users a little sandbox window for running the query and showing 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).