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

Description

Author: herd

Description:
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):

({
"id":"foo",
"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

bzimport added a project: MediaWiki-API.Via ConduitNov 21 2014, 10:19 PM
bzimport set Reference to bz15044.
bzimport created this task.Via LegacyAug 5 2008, 9:24 AM
Catrope added a comment.Via ConduitAug 5 2008, 4:13 PM

Fixed in r38638

Add Comment