Get all created contacts since a date - API


#1

I am wondering if there is any contact parameters or a particular APIs to get all the new contacts since a specific Date. I know this API returns the new added contacts

https://api.hubapi.com/contacts/v1/lists/all/contacts/recent?hapikey=demo

but you can not send a Date parameter in order to returns all the contacts between today and the Date parameter.

Appreciate any solutions.


#2

Hi @ribaz,

It's not currently possible to specify a particular date range to pull contacts from. You do have a couple of options:

  • If you need to get contacts within a relatively recent timeframe, you can use the 'Get recently created contacts' endpoint you linked to above. You could page backwards through the recently created contacts until you reached the specific start date you were interested in.
  • If you have access to the Lists tool, you could create a smart list of contacts whose 'Create Date' property is within the timeframe you're interested in, and then pull all the contacts in that list.

#3

Thank you @Derek_Gervais,

Actually, I have chosen the first option which is getting the recent contacts (100 contacts per call). The steps are:

1- foundContacts = result(https://api.hubapi.com/contacts/v1/lists/all/contacts/recent?count=100&hapikey=demo)
2- IF foundContacts !=null
3- IF foundContacts.time-offset>myDate && foundContacts[0].addedAt>myDate THEN grab all the contacts ELSE foreach foundContacts => foundContacts[i].addedAt>myDate THEN grab foundContacts[i]
4- IF has-more==true THEN call https://api.hubapi.com/contacts/v1/lists/all/contacts/recent?count=100&vidOffset=foundContacts.vid-offset&&timeOffset=foundContacts.time-offset&hapikey=demo . go back step2 ELSE END


#4

Hi @Derek_Gervais,

Do you know what is the timeframe of recently created contacts API? Like how recent? Are we talking here about one month old data/Contacts or about few weeks old?

Appreciate your help.


#6

Welcome, @bdmonte.

Happy to clarify! The documentation for the Get recently created contacts method contains everything needed to use the endpoint.

While the endpoint's title implies it will only return contacts within a specific "recent" timeframe, what it really does is get all contacts in reverse chronological order, in sets of 100. Thus, if you wanted, you could continue to page back to the very first contact created in your account.

Most developers using this endpoint will have their system check the addedAt timestamp (in milliseconds since epoch) and stop when the value matches the beginning of the timeframe they are looking for.