I have more than 6000 companies in HubSpot and i want to get all companies while hitting the Get all companies API. Currently i can get Max 250 companies at a time. Please suggest me how can i manage such kind of situation.
When looking to get all companies using this endpoint here: Get all companies there is a maximum value of 250 return limit. The reason behind having a limit is because there may be portals with significant number of contacts and returning all of them in a single request would result in timeouts and/or huge response sizes.
That said, your team can look into using a if statement to gather all the companies records. If the has-more value is true, it means that there's another page of company records and for that you can use the offset value to get to the next page.
When looking to get all companies using this endpoint here: Get all companies there is a maximum value of 250 return limit. The reason behind having a limit is because there may be portals with significant number of contacts and returning all of them in a single request would result in timeouts and/or huge response sizes.
That said, your team can look into using a if statement to gather all the companies records. If the has-more value is true, it means that there's another page of company records and for that you can use the offset value to get to the next page.
do we have to change Offset values very time at endpoint ? Or it takes automatically?
i have same problem, i have 3357 companies records , incase if we have to change offsetvalue manually every time at endpoint then what is the use of API if we do manually ??
each request will also return two values, offset and has-more. If has-more is true, you'll need to make another request, using the offset to get the next page of company records. These are often used with a recursive function in order to get all companies stored in a CRM.
For instance, if you've 300 companies in your portal and your team is looking to get all 300 companies records using theGet all companies endpoint:
1. The first API call will return a maximum number of result -250(if the limit is set to 250) i.e. GET companies/v2/companies/paged?limit=250
Assuming, the has-more istrueand the offset value is4552438489
2. On the second API call, you would need to include the offset value on the request url to page to the second page i.e. GET companies/v2/companies/paged?limit=250&offset=4552438489
*If on the second call, has-more is still true, you would need to grab the newly generated offset value and use it on the third call.
i have same problem, i have 3357 companies records , incase if we have to change offsetvalue manually every time at endpoint then what is the use of API if we chnage offset manually ??
We used a recursive function to fetch all our companies as there's a limit.
For example, let's say you have your function "callHubspotApi" with the argument "url". Inside this function you'd call the hubspot API and check if there's a "next page", if there is call the same function within itself while updating the "url" parameter with the next page. Keep doing this until there are no more pages left.