Querying Multiple companies With filtering and associations

Hi, I’ve been looking through the API for hubspot, specifically looking at the company object, and I’m having a hard time finding an endpoint with the capabilities i’m looking for. I’m looking to look up companies and get the associated contacts for the filtered entities. I understand that the API doesn’t support directly querying association properties from another object, and I’m trying to most efficiently find a way to get company + contact information where company’s creation date is after a certain time

Potential options:

company search: (POST: /crm/v3/objects/companies/search)

  • Doesn’t allow for association returns (unless undocumented)
  • Allows filtering
  • Multiple companies returned

List company: (GET:/crm/v3/objects/companies)

  • doesn’t allow filtering
  • allows querying associations
  • multiple companies returned
  • (Is the after property persistent and able to be leveraged later, similar to a kafka cursor?)

Batch Query (POST: /crm/v3/objects/companies/batch/read)

  • Allows querying by ID (perhaps by property, unclear what idProperty means)
  • multiple companies returned
  • Does not allow for association returns

Singular query (GET: /crm/v3/objects/companies/{companyId})

  • Shows associations
  • singular company returned
  • requires multiple calls, one per company. Demanding on API call limit

Potential call combinations:

Search → looped singular query

  • Requires N calls + N/100 where N is the number of results of search.
    • getting contacts requires parsing associations, deduplicating, and making an additional M calls where M is the number of unique contacts found among N.
  • If N is over 400, will take over 1 second to return due to rate limits

List → batch contact query

  • Requires in-memory filtering, does NOT scale to large data sets.
    • Requires N/100 calls to list, M/100 calls to batch query
    • Not subject to limited search rate limit
  • No filtering means this is only viable on small data sets.

Is there an approach I’m missing, or a parameter on one of these endpoints that will allow simultaneous filtering and association querying? Thanks in advance.

EDIT: Is the best way to handle this export companies (with filter) → parse export → batch query contact?

Hey, @MasterplanDev :waving_hand: Thank you so much for the detailed breakdown.

Right off the bat, your last suggestion (the EDIT) seems to be a practical workaround for your requirements. I’ve noticed this challenge brought up by multiple members of our community, and your breakdown echoes the constraints and concerns they’ve shared.

I’d like to take some time to reflect on this and present it to our Product team for consideration.

I’ll keep you posted on any updates.

Talk soon! — Jaycee

I just wanted to chime in and say that I’ve come across this exact same dilemma just today. We are planning to build a HubSpot integration for our platform, since several of our customers are asking for it.

I’m not yet sure how we will realistically work around this, since our customers are wanting to bring thousands of deals through our integration, along with associated companies, contacts, products, etc.

In our particular case, we will be basing most of our data needs around the `deal` object, rather than the `company` object. But it’s the same underlying limitations.

PS: thanks @MasterplanDev for the awesome writeup of the situation!

Hi,

Is there any update on this topic ? We still have this issue on our side.

Thanks,

Bernard