Pagination API Contacts


Hi All,

I'm trying to create one big json file with all my contacts. Since the API returns max 100 contacts I have to work with pagination. My lack in php knowledge let me in the dark of how to achieve this. Can anyone point me in the right direction here?

What I have so far:

$limit = 100;
$apikey = "xxxxx";
$feed_url = "". $apikey .'&count='. $limit;
$feed_json = file_get_contents( $feed_url );
$feed_array = json_decode( $feed_json );

// Here I go on and read the data etc.

My question is: how do I go trough 300 contacts and put them into 1 array (json).

Thanks so much.



Hi @Ilja-developer, I do not know much about pagination with PHP, but something like a while loop could work: You could execute a blog of code (the request) multiple times until the has-more property that gets returned is equal to false. After each loop, you can push the values into an array. I can't speak to specifics, but this is a common practice. Any PHP developers have example code that they could provide?


Thanks, That could work, as do a while statement. Question is the specific since the request URL needs to be updated with the vidOffset value.

An example code would be amazing..


Hi @Ilja-developer, I've found the following repo on Github you might be able to check out. I can't personally provide any example code, but know we are working on building out our examples and a possible library in the future. Here's the Github repo:



So I did some digging and found the following:

The repo they use is:

The code works perfectly so I guess my question is answered. Tho this raises a new question.

The repo you shared is much more recent. But I cant get the same results using that repo. How can I use the newer repo to achieve the same result..?

Thanks so much.



Did also posted it on stackoverflow


Hi @Ilja-developer, I'd say the best option would be to wait for a response on stack overflow, or submit a github issue on their repo. I can't speak to why one PHP repo would work but one wouldn't as these are all external developers simply utilizing the HubSpot APIs. Perhaps their code doesn't work for every use-case?