I would not really call all 15 000 contact and all of the associations and then all the companies based on the associations in one call period.
If I would do it I would set up a cron job to call a script every minute or so. I would also create a custom property for a contact called "last sync with my system" and set it to datetime format.
That script would call contacts via the search api looking for the property "last sync with my system" with a date less then x.
Then I would get an array of companies (usually only one company associated with one contact - but there can be more). With this I would use the company API to get company data if I needed it.
If I need specific company properties or specific contact properties I would add ?properties=mypropertyname&properties=asecondproperty to the adress bar in my get call in the API.
1. Use the objects - contacts API and list the properties you want to recieve from contacts within the adress bar
2. First use the associations api (listed above) then you will get the company id (hubspot internal id for the companies) with that you can then use the company api to recieve the company data.
3. You cant. At least 3 calls to get contacts, associations and companies. The workload on the servers to get that amount of contacts, associations and companies in one call would not be good for traffic and you might get a result (limit) of maybe a 100 companies (im not sure what the limits are here ) per call - and you would need to call the seconds page and a third page and so on untill you get all the results you request. With that said there are also call limits on how many requests you can do per minute (one page = one request) and you would pass that limit by far if you need to contact 15000 contacts at once.
So my advice is to create a property - call it something with date - update it whenever you have done your search - and do maybe 100 calls per minute using cron jobs or similar.
What is the best way to retrieve all contacts in hubspot as well as some company properties
SOLVE
hi Michael,
Thanks for the detailed explination.
The steps you provided above is what I had in mind, except the date field example for last synced. This just means i would need to do an update per contacts as well to keep the sunced date populated as well. The only problem is, the system that is calling us to get the nifo cannot confirm and write data back to us, so, ideally I dont want to update the last synced date unless I know it was synced. I will chew on this a bit more.
.I was hoping there would be a better way but I understand the limitation mentioned here. I appreciate the quick response and community feedback.
I would not really call all 15 000 contact and all of the associations and then all the companies based on the associations in one call period.
If I would do it I would set up a cron job to call a script every minute or so. I would also create a custom property for a contact called "last sync with my system" and set it to datetime format.
That script would call contacts via the search api looking for the property "last sync with my system" with a date less then x.
Then I would get an array of companies (usually only one company associated with one contact - but there can be more). With this I would use the company API to get company data if I needed it.
If I need specific company properties or specific contact properties I would add ?properties=mypropertyname&properties=asecondproperty to the adress bar in my get call in the API.
1. Use the objects - contacts API and list the properties you want to recieve from contacts within the adress bar
2. First use the associations api (listed above) then you will get the company id (hubspot internal id for the companies) with that you can then use the company api to recieve the company data.
3. You cant. At least 3 calls to get contacts, associations and companies. The workload on the servers to get that amount of contacts, associations and companies in one call would not be good for traffic and you might get a result (limit) of maybe a 100 companies (im not sure what the limits are here ) per call - and you would need to call the seconds page and a third page and so on untill you get all the results you request. With that said there are also call limits on how many requests you can do per minute (one page = one request) and you would pass that limit by far if you need to contact 15000 contacts at once.
So my advice is to create a property - call it something with date - update it whenever you have done your search - and do maybe 100 calls per minute using cron jobs or similar.