APIs & Integrations

Xi_Wang
Member

Export data automatically under then constrain on offset

SOLVE

When I was trying to GET /contacts/v1/lists/all/contacts/all, there is offset issue, which prevented me from getting data automatically since I need to know VID first before getting next page data, any advice to make it more automated? Thank you

0 Upvotes
1 Accepted solution
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Export data automatically under then constrain on offset

SOLVE

Hi, @Xi_Wang,

Could you please describe your goal and issue in more detail?

The Get all contacts endpoint returns a JSON-formatted list of up to 100 contacts. The last two fields in the response are has-more and vid-offset.

If has-more is true, then vid-offset will contain the vid of the last contact returned. You then use this vid-offset value in your next request.

For example, if you query https://api.hubapi.com/contacts/v1/lists/all/contacts/all?count=100&hapikey=your_key, you will receive up to 100 contacts.

If there are more contacts in your account, "has-more": true will appear at the end of the payload followed by "vid-offset": 1234.

You can then use a loop to query the endpoint again, this time with the vid-offset in the request URL:

https://api.hubapi.com/contacts/v1/lists/all/contacts/all?count=100&hapikey=your_key&&vidOffset=1234. This will return the next 100 contacts.

Isaac Takushi

Associate Certification Manager

View solution in original post

0 Upvotes
1 Reply 1
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Export data automatically under then constrain on offset

SOLVE

Hi, @Xi_Wang,

Could you please describe your goal and issue in more detail?

The Get all contacts endpoint returns a JSON-formatted list of up to 100 contacts. The last two fields in the response are has-more and vid-offset.

If has-more is true, then vid-offset will contain the vid of the last contact returned. You then use this vid-offset value in your next request.

For example, if you query https://api.hubapi.com/contacts/v1/lists/all/contacts/all?count=100&hapikey=your_key, you will receive up to 100 contacts.

If there are more contacts in your account, "has-more": true will appear at the end of the payload followed by "vid-offset": 1234.

You can then use a loop to query the endpoint again, this time with the vid-offset in the request URL:

https://api.hubapi.com/contacts/v1/lists/all/contacts/all?count=100&hapikey=your_key&&vidOffset=1234. This will return the next 100 contacts.

Isaac Takushi

Associate Certification Manager
0 Upvotes