Template talk:ApiEx

Use plain spaces
Sure wish you used plain ASCII " " spaces. Wouldn't have to go nuts cleaning them up after each cut and paste to try out parts of them.

In fact perhaps any spaces at all is a barrier to people wanting to paste parts of them... Jidanni 20:46, 21 March 2009 (UTC)
 * Yes, it's a pain. I mentioned converting spaces in the p1-p9 URL parameters to %20 in the template documentation. The template could/should escape spaces for you, but the invocation of the API in your own code might need URL escaping, so reminding readers that URL parameters may need escaping isn't harmful. -- SPage (WMF) (talk) 00:25, 25 February 2015 (UTC)


 * OP was talking about spaces between the parameters, which was fixed over two years ago by replacing them with margins. --121.219.123.17 02:32, 25 February 2015 (UTC)

Mysterious post parameter ?
The explanation says
 * post - a "list" of ApiEx/Post objects, to generate a post table

I don't understand that. It would be nice to have an example.

Do any pages use ApiEx/Post? API:Edit doesn't use it, I would expect it to.

Thanks for working on this!

-- SPage (WMF) (talk) 22:20, 5 February 2015 (UTC)

Switch output to json
Now that API output is JSON by default, the examples should probably switch to  | result=  parameter.

That's predictable, but it means the examples drift out of date. Some ideas (also see T88755):

-- SPage (WMF) (talk) 02:35, 7 February 2015 (UTC)
 * a bot could find instances of this template, run the query, and replace the source parameter with result. Downside is unpredictability, e.g. many would include
 * with some JavaScript support, when you click the API example it could actually run the query and display a result in a box. For bonus points it could let you tweak the parameters, similar to what the OOjs UI Living style guide is doing.
 * the examples could have a link to Special:ApiSandbox, pre-populating its the fields for you.


 * Whether we do them on-the-fly or via a bot, the primary problem I see is the various non-query examples, almost all of which do something, and most of them require elevated permissions. I don't think you want a bot e-mailing something as it tries to generate an example for that, or in an on-the-fly scenario, have some prankster decide it would be fun to edit the API:Move example so that it moves a high-use template when clicked on. As to your point about warnings being included, I think most bots could strip those with relative ease. A little string parsing before processing would do the trick, or whatever methods are available with the bot's Json parser. – Robin Hood   (talk)  07:00, 7 February 2015 (UTC)

Adding a link to [try in sandbox]
Special:ApiSandbox has a neat trick: if you take any  query string, and add it as the "hash" or URL fragment   on the end of Special:ApiSandbox, then the ApiSandbox form preloads with those parameters. For example
 * https://en.wikipedia.org/w/api.php?action=query&prop=pageimages%7Cpageterms&titles=Albert%20Einstein
 * https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&prop=pageimages%7Cpageterms&titles=Albert%20Einstein

I'm trying to add a [try in ApiSandbox] link to this template for T89680. It's a useful hack that will encourage developers to play with our APIs in the Data and developer hub. My work in progress template modification is at User:SPage_(WMF)/ApiEx, demo/tests at User:SPage_(WMF)/APIExTest. I hope it's reliable enough to default to on. As usual, I'm not sure about i18n/localization.

-- SPage (WMF) (talk) 02:10, 27 March 2015 (UTC)