APIs & Integrations

EInc
Member

How to fetch more than 10,000 records using Hubspot API

SOLVE

Hi,

I am using Deal search API to fetch records with some conditions on it, but I found from the docs that search API is limited to 10,000 records and we can't paginate more than that, and also there is request limit of 4 request/second. So I suppose that even I can't get all the 10, 000 records since that would contain 100 API calls.

 

My Question is there way I can fetch all the available records with any other API with some conditions applied on the properties

1 Accepted solution
GLanker
Solution
Member

How to fetch more than 10,000 records using Hubspot API

SOLVE

Going off of the previous posts, the way I have solved this is to re-index instead of paging thorugh. To do this, on the "get" I am sorting by the ID ascending, and storing the last id (array[99]) since I am grabbing 100 at a time.  On the next time through I am then checking for hs_object_id to be greater than that stored last id. This is my pseudo code to make this possible and it is pretty seamless

 

  "limit": 100,
  "after": "0",
  "properties": [ "firstname", "email", "lastname"],
  "filterGroups":[
    {
      "filters":[
        {
          "propertyName": "lastmodifieddate",
          "operator": "GTE",
"value": "{last date to get from}"
        },
        {
          "propertyName": "hs_object_id",
          "operator": "GT",
          "value": "{last id stored value (default to 0)}"
        }
      ]
    }
  ],
  "sorts": [
  {
        "propertyName": "id",
        "direction": "ASCENDING"
    }
  ]
}

View solution in original post

4 Replies 4
GLanker
Solution
Member

How to fetch more than 10,000 records using Hubspot API

SOLVE

Going off of the previous posts, the way I have solved this is to re-index instead of paging thorugh. To do this, on the "get" I am sorting by the ID ascending, and storing the last id (array[99]) since I am grabbing 100 at a time.  On the next time through I am then checking for hs_object_id to be greater than that stored last id. This is my pseudo code to make this possible and it is pretty seamless

 

  "limit": 100,
  "after": "0",
  "properties": [ "firstname", "email", "lastname"],
  "filterGroups":[
    {
      "filters":[
        {
          "propertyName": "lastmodifieddate",
          "operator": "GTE",
"value": "{last date to get from}"
        },
        {
          "propertyName": "hs_object_id",
          "operator": "GT",
          "value": "{last id stored value (default to 0)}"
        }
      ]
    }
  ],
  "sorts": [
  {
        "propertyName": "id",
        "direction": "ASCENDING"
    }
  ]
}
DPassman
Contributor | Elite Partner
Contributor | Elite Partner

How to fetch more than 10,000 records using Hubspot API

SOLVE

The Search API returns records starting with the lowest object ID, by default. Therefore, in order to get around this, you'd need to implement a check in your code that logs 2 things.

1. The "after" value

2. The last ID

 

Once the after value reaches 10,000, you'll need to jump to a new loop in your code that resets the after value, and does a seach for record IDs greater than the last ID value from above. Every time you hit the 10000 after value, you'll need to restart your loop.

David Passman
0 Upvotes
TitiCuisset
Community Manager
Community Manager

How to fetch more than 10,000 records using Hubspot API

SOLVE

Hi @EInc 

 

Thank you for reaching out.

 

I want to tag some of our experts on this - @himanshurauthan @JBeatty @Bryantworks do you have any thought for @EInc on this? 

 

Thank you!

Best

Tiphaine

vkumar34
Participant

How to fetch more than 10,000 records using Hubspot API

SOLVE

I Have same question !!
Eagerly Waiting for reply.