All Collections
Data & the API
Handling paginated responses
Handling paginated responses

Learn about paginated responses and how to deal with them when interacting with the Modo API

Imrith Kyle Singh Sangha avatar
Written by Imrith Kyle Singh Sangha
Updated over a week ago

Pagination is a common technique used to divide a large set of data into smaller, more manageable chunks. When interacting with the Modo API, we paginate our responses to make larger datasets more manageable and help improve the response time. In this article, we'll demonstrate how to handle these paginated responses in your code.

Below is an example of how you access the different pages within a response from the Modo API. The 'next' key in the JSON response enables you to access the next page of the response quickly.

#library imports

import pandas as pd
import requests

# url endpoint from Modo API

url = "'

# define parameters (payload)

params = {'date': '2022-02-01'}

# get token from

headers = { 'X-Token': 'YOUR_API_TOKEN' }

# call Modo API

response = requests.get(url, headers=headers, params=params )

# First page of results

res = pd.DataFrame(response.json()['results'])

# pagination means we now limit each call to 1000 rows, but you can now get the next 1000 rows using the 'next' field of the API response:



# the example below shows a method to get all the data from all the pages # of a response quickly


while url is not None:
response = requests.get(

df = pd.concat([df,pd.DataFrame(response.json()['results'])])
url = response.json()['next']

If you've got any questions about connecting to the Modo API then please feel free to contact us - we're always happy to chat...

Did this answer your question?