Page MenuHomePhabricator

Improve MediaWiki API example behavior
Closed, DeclinedPublic

Description

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).

Event Timeline

Spage raised the priority of this task from to Low.
Spage updated the task description. (Show Details)
Spage added a project: Web-APIs-Hub.
Spage added subscribers: Anomie, Qgil, Spage.
Spage set Security to None.

Somehow automate the insertion of static API results into the wiki page.

The concern there is that if people can somehow get arbitrary static API results into Scribunto, they'd immediately hack together a module to parse the output to do arbitrary API queries.

Gerrit change 171290 makes that not currently be the case, but comments like this make me wary that new such holes could be opened up as others aren't concerned about it as a general issue.

The Web-APIs-Hub project is dead hence mass-declining its tasks to reflect reality. It might be superseded by a Developer Portal in the future.