How to get a list of all contact_id values (using v3 API)

CEESI
Rookie
0 Votes
My company has around 7,500 contacts, with several thousand that are not part of any contact list. I can't find a way to get a list of ALL contacts, or event all contact_id values. The calls that give the options to request a list of contacts are either for a specific contact list and/or limit the responses to 500. I need a mechanism to get data (or at least a list of all the contact_id values) and it seems like the only way it to export them to .csv.... What is the method to get a list of all contacts (or at least all contact_id values)? Thanks
2 REPLIES 2
Courtney_E
Employee
0 Votes

Hello CEESI,

 

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.

 

When calling the GET /contacts endpoint, you'll need to make multiple calls, as the maximum number of entries that can be returned at a time is 500, but the results use pagination and will include a link to call for the next 500 results (until there are no more pages left).

 

GET Contacts Collection

https://v3.developer.constantcontact.com/api_reference/index.html#!/Contacts/getContacts

 

You'll start by making sure to include the "limit" query parameter in your call with a value of "500", otherwise it defaults to only 50 results. Additionally, if you are wanting to determine which contacts are or are not on lists, using the "include" query parameter with a value of "lists" will include the list IDs for each contact as well.

 

Example call:

GET https://api.cc.email/v3/contacts?include=list_memberships&limit=500

 

At the end of the 500 entries returned, if there are more than 500 results, you will see a section that looks similar to this at the very bottom of the response body:

 

    "_links": {

        "next": {

            "href": "/v3/contacts?cursor={value}"

        }

    }

 

You will use this link to make another call to get the next page of results, like so:

 

Example Call:

GET https://api.cc.email/v3/contacts?cursor={value}

 

Then, if the results of the second call have a next link at the bottom of the response body, you will use that to make a third call, and so on.



Please have a look and let us know if you have any other questions!


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
user6365
Rookie
0 Votes

I believe you have to include the status = all in the parameter of the endpoint you try to retrieve the contacts.

Resources
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up