Solved

How can I limit the number of results in API response?

  • 14 April 2024
  • 3 replies
  • 26 views

Badge

I am using the get_lists API from the latest version with revision: 2024-02-15, and wondering why there is no option to limit the no of results I want in the API response. I nowhere found in documentation about how many results it will return by default. 
Ideally, the users should be allowed to put the batch size as per their requirement (under a max-batch size). 
Looking forward to hear back on this.
Thanks.

icon

Best answer by DavidV 14 April 2024, 22:35

View original

3 replies

Userlevel 5
Badge +19

Hi @shubham773,

Welcome to the Klaviyo community!

The GET Lists API will return a maximum of 10 results, and the API supports pagination:

curl --request GET \
--url 'https://a.klaviyo.com/api/lists/?page[cursor]=XXXXXXXXX' \
--header 'Authorization: Klaviyo-API-Key your-private-api-key' \
--header 'accept: application/json' \
--header 'revision: 2024-02-15'

You are also able to use filters.

I hope that helps!

Thanks
David

Badge

Hi @DavidV , Thanks for the answer. How can I change it if I want to change the batch limit from 10 to a lesser number? Filtering and pagination options do not have any option to change it.

Userlevel 5
Badge +19

Hi @shubham773,

No worries! I don’t think you are able to change the batch limit unless there are less than 10 results or you are able to filter down the list based on the Name, ID, Created date or updated date. 

Hope that helps!

Thanks
David

Reply