API:Continue

Very often you will not get all the data you want in one API query. When this happens, the API will append an additional element (titled ) to the results to indicate there is more data.

The element that is returned will have two parts to it: One part will be a sub-element also titled. This will typically have an associated value that include the symbols if there is data available to continue. The second part will be a sub-element (or multiple sub-elements) whose title is the abbreviation of the whichever list is used in the query, prefixed to the word. (So, for example, the sub-element for a query using categorymembers would be, the sub-element for a query using allcategories would be  , the sub-element for a query using protectedtitles would be  , etc.)

To retrieve further data when the  element is present, you must add the second sub-element as a parameter to the next API request. For example, if a query using the list allcategories contained additional results, then the next API query made should include  as parameter, along with whatever the value of   was in the results of the first query. To get all results, this can be repeated until an API result does not have a  element in the results, indicating there are no more data matching the query.

batchcomplete
When you make an API request using a generator together with properties, the API result may signal to continue because there are more properties to retrieve for the pages so far (in which case the same set of pages is returned but with the next set of properties), or because there are more pages from the generator, or both. From version 1.25 onwards, the API returns a  element to indicate that all data for the current "batch" of pages has been returned and the   element doesn't contain continuation data for properties, but instead can contain continuation data for the generator. This can be useful to avoid building a combined result set for thousands of pages when using a generator together with prop modules that may themselves need continuation.

Backwards compatibility of continue
From MediaWiki 1.21 to 1.25, it was required to specify  (i.e. with an empty string as the value) in the initial request to get continuation data in the format described above. Without doing that, API results would indicate there is additional data by returning a  element, explained in Raw query continue. Prior to 1.21, that raw continuation was the only option.

If your application needs to use the raw continuation in MediaWiki 1.26 or later, you must specify  to request it.

Example 3: Python code for iterating through all results
Here is Python code showing how to iterate over query results (using the python requests lib). Note that you should not manipulate or depend on any specifics of the values returned inside the  element, as they may change.