# pagination issue

**URL:** <https://community.hubspot.com/t/pagination-issue/64029>\
**Category:** APIs & Integrations\
**Created:** [August 30, 2022, 11:10am UTC](https://community.hubspot.com/t/pagination-issue/64029 "2022-08-30T11:10:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nturcksin](https://avatars.discourse-cdn.com/v4/letter/n/4da419/32.png) [@nturcksin](https://community.hubspot.com/u/nturcksin)\
**Post date:** [August 30, 2022, 11:10am UTC](https://community.hubspot.com/t/pagination-issue/64029/1 "2022-08-30T11:10:43Z")

</div>

Hi,

we where using the hubspot API to fetch all the contact, we were using the pagination system who will add the after and link value,

but since this morning I can get the 2 first pages but next the pagination seems to be wrong the object return by the API is :

`paging: { next: { after: '100' } }`

instead of :

```lia-code-sample
paging: { next: { after: 'MTY0MDQxOTEx', link: 

'https://api.hubapi.com/crm/v3/owners?after=MTY0MDQxOTEx' }

```

who break or loop .

we use this endpoint :

‘[https://api.hubapi.com/crm/v3/objects/companies/search](https://api.hubapi.com/crm/v3/objects/companies/search)’

is this something expected or it’s a bug ?

Thanks,

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [August 31, 2022, 7:32pm UTC](https://community.hubspot.com/t/pagination-issue/64029/2 "2022-08-31T19:32:41Z")

</div>

@nturcksin

This is expected. I am confused by your code. Looks like you are referencing two different endpoints.

In your post body request for the search the crm API, you will include the after: 100 or whatever is returned to you to get the next set of results. An example would look like this:

```lia-code-sample
{
 "filterGroups": [
 {
 "filters": [
 {
 "value": "larry",
 "propertyName": "firstname",
 "operator": "EQ"
 }
 ]
 }
 ],
 "limit": 1,
 "after": "1"
}

```

I did notice that the docs display it a different way in the example. I will see about getting that corrected!

---

<div class="post-metadata">

**Author:** ![JimLynch-CVI](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@JimLynch-CVI](https://community.hubspot.com/u/JimLynch-CVI)\
**Post date:** [October 8, 2022, 11:35pm UTC](https://community.hubspot.com/t/pagination-issue/64029/3 "2022-10-08T23:35:28Z")

</div>

I believe some of the confusion comes in the documentation located here:  
[CRM API | Companies (hubspot.com)](https://developers.hubspot.com/docs/api/crm/companies)

The example gives the “after” & “link”:

```lia-code-sample
{
 "total": 0,
 "results": [
...
],
 "paging": {
 "next": {
 "after": "NTI1Cg%3D%3D",
 "link": "?after=NTI1Cg%3D%3D"
 }
 }
}

```

instead of the actual “after”: 10.  
That can lead to some confusion if you don’t know to add “after” as a parameter in the body.
