Jump to content

Requests for comment/API roadmap/Archive

From mediawiki.org

Simplified query continue

[edit]

Easy continue allows significant client simplification. Easy continue is an API guarantee to the client that by simply adding all items in the 'continue' section to the next query the client will receive all available data, without accidentally skipping some values due to a 'limit' parameters or the generator paging. This change can be made available in all query versions, and made default in action=query~2.

'continue': {
    'continue': '...',
    'plcontinue': '...',
    'gapcontinue': '...',
}
Client logic (in python)

A client library could have this code (uses python requests lib):

for result in pywiki.query( {'generator':'allpages', 'prop':'links', 'continue':''} ):
    # process result data
...
def query(request):
    while True:
        result = requests.get('http://en.wikipedia.org/w/api2.php', params=request).json()
        if 'error' in result: raise Error(result['error'])
        if 'warnings' in result: log.Append(result['warnings'])
        if 'query' in result: yield result['query']
        if 'continue' not in result: break
        request.update(result['continue'])  # re-send all query-continue values in the next call

Cleanups

[edit]
  • Rename 'query-continue' to 'continue' because other actions may also be continuable, or might use pageset generator.