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