APIs & Integrations

crossbill
Member

Custom objects count (without paginating all objects)

SOLVE

Is there an API endpoint available that allows me to get the total count of custom objects for a particular schema, without paginating through all the objects using the "crm/v3/objects/{objectType"?

 

For example, would be great if in the payload sent back from endpoint (above), an additional field would be included like:

 

page: { next: null},total_count: 35000

I suspect there's probably some sort of API (perhaps internally available to hubspot only) that reveals the total count, given that at the top of the Hubspot console page/dashboard, the total count of items is displayed. Without that scalar value (total count) available, we would be required to pagination through all pages, an expensive operation (in terms of number of API calls) since each request permits only 100 records to be returned at a time...so if we have 30000 custom objects, we'd need to issue 300 API calls.

 

Source: https://developers.hubspot.com/docs/api/crm/crm-custom-objects

0 Upvotes
1 Accepted solution
weiliang_lee
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Custom objects count (without paginating all objects)

SOLVE

Hi there,

 

Try using the search endpoint:

/crm/v3/objects/{object}/search

 

Using the Contacts Object as an example, the List endpoint doesn't give the total count indeed. But using the Search endpoint, the payload would include the "total" property. (You can use the Search endpoint and provide an empty body in the request, that would net the same results as doing a List).

weiliang_lee_0-1669948763451.png

 

Cheers

WL

View solution in original post

0 Upvotes
1 Reply 1
weiliang_lee
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Custom objects count (without paginating all objects)

SOLVE

Hi there,

 

Try using the search endpoint:

/crm/v3/objects/{object}/search

 

Using the Contacts Object as an example, the List endpoint doesn't give the total count indeed. But using the Search endpoint, the payload would include the "total" property. (You can use the Search endpoint and provide an empty body in the request, that would net the same results as doing a List).

weiliang_lee_0-1669948763451.png

 

Cheers

WL

0 Upvotes