Reputation: 11
I am trying to get all clients (and all their info) from a List/Segment on my Klaviyo account.
I am using python code, helped by this link :
https://github.com/klaviyo/python-klaviyo
The problem is that when I try to get the members of the list I only receive 1000 clients on the 10000 existing profile.
Here is my code :
response = client.Lists.get_all_members('List-id', marker=None)
print(response.data)
I didn't find the answer anywhere so if someone has faced the same problem and could helped me with it, it will be great.
Thank you for your time.
Upvotes: 1
Views: 1323
Reputation: 115
As @Pedro mentioned, think as the markers as pagination, and the id as the page number.
In order to get all your records, you'll have to loop through the different markers in order to get them all.
In my case I did a while
statement that checks for the MARKER
to be None
, otherwise update the request with the marker you got from the last response and you'll get a new page.
You won't be able to hard code the markers since they are not sorted, and if the segment is still active and growing; Klaviyo will keep creating more markers to create the pagination.
Upvotes: 1
Reputation: 11
In the documentation you can see that you must use the marker from your first Response to retrieve the next batch of data. Just use it in your next GET request to obtain the next batch.
Successful requests will include a JSON object containing a list of records containing profile IDs, emails, phone numbers, push tokens, and potentially a marker if there are more records available. Invalid requests will be accompanied by an error message.
{'marker': 103611759985,
'records': [{'id': '01F09CMHJZ2Y9DCVF9MEWMWM44',
'email': '[email protected]'}, ...}
Link to documentation: https://www.klaviyo.com/docs/api/v2/lists
Upvotes: 1