Page MenuHomePhabricator

give API an id type parameter for parallel operations
Closed, ResolvedPublic


Author: herd

Often when working with the API I'll end up needing to do several parallel operations, such as with format=json and using callbacks. This can be annoying, requiring re-scraping the page to figure out what triggered what, and doing fragile matching in the process.

An alternative I've found is to use eval() to generate a unique callback function for each object, eg:

var url = wgServer + wgScriptPath + '/api.php?action=query&format=json&callback=usiCB' + i;

eval('usiCB' + i + ' = function(tobj) { usiCB(tobj,' + i + ')}');

But this can be a pain for hundreds of parallel or potential operations. Per IRC convo with Roan a possible solution vector is a generic ID parameter for all formats:

something like &requestid=foo or &apiid=foo could generate (in the various formats):

"query": {

<api id="foo">

array('api' => array('id' => 'foo', 'query' => ...

This would greatly facilitate usage of parallel scripts by giving the calling code a way to trace back what requested the query.

Version: unspecified
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:19 PM
bzimport set Reference to bz15044.