Got a 'How do I' question? Join 'Ask a Trainer' Monday to Friday, 11am to 4pm ET for instant help and pro tips!

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
3 REPLIES 3
Courtney_E
Moderator
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.

 

You'll also want to set the status parameter to "all" to ensure that in addition to active contacts, you are also getting and contacts in other statuses, such as deleted, not_set, pending_confirmation, temp_hold, and unsubscribed.

 

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?status=all&include=lists&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
Campaign Contributor
0 Votes

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

Courtney_E
Moderator
0 Votes

Hello user6365 ,

 

Thanks for catching that!  I have updated/corrected my original response in case the poster also wants contacts of all statuses, rather than just access to the paginated results.


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.
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