How to handle /contacts pagination in v3 API,
there is no specification for it in the documentation,
I can only retrieve first 500 contacts of a list
Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.
If your response for GET /contacts has over 500 results, at the bottom of the response body there will be a link you can make a GET call to for viewing the next 500 results, and if there are more results after that, there will be another link in the next response body, and so on:
"contacts": [ … ],
"list_memberships": [ … ],
"href": ""href": "/v3/contacts?cursor=/04fe9a97-a579-43c5-bb1a-58ed29bf0a6a"
*You can view an example Response Sample in the upper right of the GET Contacts Collection section of our API Reference tester page:
So, for the above link to the next page of results, you would make a GET call to:
Then, if the response also has a value for "_links": "next", then you’d make another call to that link until you reach the final results page, which will be indicated by not having a "_links": "next" value.
You should be able to set up a variable within your program for if there is a "_links": "next" value in your response body, and then have it make the additional GET call with the provided URL and append the response data.
Alternatively, if you are just wanting to view your contacts in one response file, you can use our Bulk Activities endpoint for Exporting Contacts to a File by making a POST call to /activities/contact_exports. This endpoint works similarly to when you export contacts from the website UI; it will not export deleted contacts, only those visible within the Contacts tab of your account. The export is formatted as a .csv file and the entries do not include Contact IDs.
Bulk Activities endpoint - Export Contacts to a File
Response body example:
In the "_links" section of the response body, you can make a GET call to the URL value for "self": "href" to see if the activity is completed:
Example Request URL:
GET an Activity Status
Then, if the "state" value shows as "completed" in the response body of this call, you can make a GET call the URL value in "_links" that shows for "results":"href":
Example Request URL:
You can then download the .csv file, or have your program parse the data.
Please have a look and let us know if you have any other questions!
View API documentation, code samples, get your API key.Visit Page
Join our list to be notified of new features and updates to our V3 API.Sign Up