How to loop a paginated query to get more results than API limit

In reading about making API calls to Monday.com, it seems like you are limited to 100 results when you make a query. I found on the forums people things along the lines of
{
boards(ids: 1122334455) {
items(limit: 100, page: 1) {
column_values {
value
text
}
}
}
}
and then they say you increase the page to get more results than the limit. I’m wondering how you actually go about writing something that loops over increasing the page to get more results, and then also ensuring the loop would stop once you get under 100 results from the query. For reference, I am using python to make the API call, and my code looks something like this:

apiKey = “mykey123”
apiUrl = “https://api.monday.com/v2
headers = {“Authorization” : apiKey}

query = ‘’'{
boards(ids: [1234567]) {
name
items_page {
items {
id
name
column_values {
id
type
text
}
}
}
}
}

‘’’

data = {‘query’ : query}

r = requests.post(url=apiUrl, json=data, headers=headers).json()

Any help on this topic would be greatly appreciated. Thank you.

Hello,

Look at the Items Page documentation. The limit is actually 500 but the key for you is to use the cursor parameter. You’ll get a cursor in the response which you can use to fetch the next batch of records. When the cursor is null there are no other offsets to fetch and you are on your last call.