Page MenuHomePhabricator

API Help should generate [try in ApiSandbox] link to Special:ApiSandbox#action=params from getExamples()
Closed, ResolvedPublic

Description

The API help shown by Special:ApiHelp and action=help includes example API requests. For example Special:ApiHelp/query has this example
api.php?action=query&prop=revisions&meta=siteinfo&titles=Main%20Page&rvprop=user%7Ccomment&continue=
which you can click to see the API response.

This is great but if you want to modify parameters it is fiddly to modify the browser URL. If the wiki has Extension:ApiSandbox it would be nice to provide an extra link "[try in ApiSandbox]".

ApiSandbox supports this \o/ , its doHash() function applies anything in the URL fragment (after the hash mark) to its UI. So take the example URL query string, and append it to Special:ApiSandbox# and we get the desired behavior:
https://www.mediawiki.org/wiki/Special:ApiSandbox#action=query&prop=revisions&meta=siteinfo&titles=Main%20Page&rvprop=user%7Ccomment&continue=

I've added [try in ApiSandbox] to mw.org's Template:ApiEx (T89680).

Event Timeline

Spage raised the priority of this task from to Medium.
Spage updated the task description. (Show Details)
Spage added subscribers: Spage, Qgil, Anomie, Aklapper.
gerritbot added a subscriber: gerritbot.

Change 189921 had a related patch set uploaded (by Spage):
Api help examples add links to Special:ApiSandbox

https://gerrit.wikimedia.org/r/189921

Patch-For-Review

For that matter, you could have a similar link in the format=*fm header.

BTW, since ApiSandbox only works with JS, ideally the link would be applied using JS.

For that matter, you could have a similar link in the format=*fm header.

Do you mean a general link to ApiSandbox for the module, e.g. https://www.mediawiki.org/wiki/Special:ApiSandbox#action=query&prop=extracts ?

BTW, since ApiSandbox only works with JS, ideally the link would be applied using JS.

I agree, I responded in gerrit (thanks for your comments).

Change 191006 had a related patch set uploaded (by Spage):
Add link to Special:ApiSandbox to api.php examples

https://gerrit.wikimedia.org/r/191006

Patch-For-Review

Spage lowered the priority of this task from Medium to Low.Mar 3 2015, 5:40 AM

This task was part of ECT-March-2015, and it is still open and assigned. Assuming that it belongs to ECT-April-2015 as well. Otherwise please edit accordingly.

Spage renamed this task from API Help should generate link to Special:ApiSandbox#action=params from getExamples() to API Help should generate [try in ApiSandbox] link to Special:ApiSandbox#action=params from getExamples().Apr 21 2015, 10:16 AM
Spage updated the task description. (Show Details)
Spage removed a project: ECT-April-2015.

Change 209570 had a related patch set uploaded (by Anomie):
Add Special:ApiSandbox

https://gerrit.wikimedia.org/r/209570

Change 209570 merged by jenkins-bot:
Add Special:ApiSandbox

https://gerrit.wikimedia.org/r/209570

Change 191006 abandoned by Anomie:
Add link to Special:ApiSandbox to api.php examples

Reason:
ApiSandbox was merged into core, so this isn't likely to be needed anymore.

https://gerrit.wikimedia.org/r/191006

Change 189921 abandoned by TTO:
Api help examples add links to Special:ApiSandbox

Reason:
Already implemented in a different way.

https://gerrit.wikimedia.org/r/189921