How to get all contacts using API, was able to retrieve max of 100 contacts

I was trying to read all contacts from Hubspot CRM using their API calls, but was able to get max of 100 contacts only. what are the besy ways to get the remaining 3000 contacts using API calls?

i didn’t find any other way to query next page or so..

Thank you,

Srini

Hey @ysrinivasarao,

Are you using the crm v3 endpoint to retrieve contacts - CRM v3 API | Contacts?

If so, when looking to get the remaining 3000 contacts, you can use the `after` parameters that is returned on the response body to page through the results.

E,g,

{
 "results": [
 {
 "createdAt": "2019-10-30T03:30:17.883Z",
 "archived": false,
 "id": "512",
 "properties": {
 "property_number": "17",
 "property_dropdown": "choice_b",
 "property_radio": "option_1",
 "property_string": "value",
 "property_multiple_checkboxes": "chocolate;strawberry",
 "property_checkbox": "false",
 "property_date": "1572480000000"
 },
 "updatedAt": "2019-12-07T16:50:06.678Z"
 }
 ],
 "paging": {
 "next": {
 "link": "?after=NTI1Cg%3D%3D",
 "after": "NTI1Cg%3D%3D"
 }
 }
}

To retrieve the results on the next page:

GET crm/v3/objects/contacts?hapikey=hapikey&after=NTI1Cg%3D%3D

Hi,

Thank you for your response,

I am actually using Below NugetPackage for this integration…

<package id=“SquaredUp.HubSpot.NET” version=“0.6.17” targetFramework=“net472” />

Hey @ysrinivasarao,

Thanks for sharing! In this case, you’d still need to implement a logic to use the `after` parameter when looking to page through the results returned on this endpoint. Have your team implemented the code logic?

is this not part of the Hubspot.Net SDK?

I am not quite sure on how to implement that after paramenter any help or a sample code would be greatly appretiated…

Hey @ysrinivasarao,

You can refer to the deal examples here: HubSpot.NET/Deals.cs at master · hubspot-net/HubSpot.NET in which there’s a commented out session on `Get all deals` showing how to retrieve more deals when results is more than 100.

This should works the same for the get all contacts endpoint.

Thank you very much, it worked and was able to retrieve all contacts using this approach.