Hi!
I am trying to use a get request to treat my data out of bubble, using python.
The problem is it is always showing only 100 records, even if I set a higher limit.
Does anyone know how to show all data?
Thanks !!
It is a defacto best practice across the web to paginate the return of large datasets. As stated in the Bubble documentation Workflow APIs have a return limit. Likewise Data APIs are automatically paginated. Your choice is to either build a manual pagination Workflow API, or structure your database so that a Data API can return the paginated results.
Hi,
This is the expected behavior 
The max value of limit is 100. So Bubble will never return more than 100 objects per API call.
To get all the objects using the Data API, you have to call it several times.
For example:
-
Call the data API with limit = 100
-
Get the number of remaining objects - response[“remaining”]
-
Compute the number of remaining pages
nb_pages = ceil(remaining / limit) -
Loop to get all the objects
for i in range(nb_pages): cursor = limit * (i + 1) # then you use the cursor parameter on the GET request
The above worked well for me, my final code looks like:
results = []
url = "[Data API root URL]"
myHeaders = {
'Authorization':'Bearer [Your API Key]',
'Content-type':'application/json'
}
response = requests.get(url, headers = myHeaders).json()
raw = response['response']['results']
left = response['response']['remaining']
pages = round(left/100) #should probably use ceil() here but didn't wanna import math
for i in raw:
results.append(i)
cursor = 100*(i+1)
params={'count':100,
'cursor':cursor}
response=requests.get(url, headers=myHeaders,params=params).json()
raw=response['response']['results']
for i in raw:
results.append(i)
df = pd.DataFrame(results)