# contacts API is returning same data

**URL:** <https://community.hubspot.com/t/contacts-api-is-returning-same-data/80100>\
**Category:** APIs & Integrations\
**Tags:** timeline-and-extensions-apis\
**Created:** [April 26, 2023, 3:04pm UTC](https://community.hubspot.com/t/contacts-api-is-returning-same-data/80100 "2023-04-26T15:04:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelhsu2011](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@michaelhsu2011](https://community.hubspot.com/u/michaelhsu2011)\
**Post date:** [April 26, 2023, 3:04pm UTC](https://community.hubspot.com/t/contacts-api-is-returning-same-data/80100/1 "2023-04-26T15:04:48Z")

</div>

Im testing the api (hubspotClient.crm.contacts.basicApi.getPage) from the website ([Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/crm/contacts)) and when I set the limit to 10 and after to 0 is returning results. However when I set the limit to 10 again and after to 10, it is returning the same results. Looks like a bug.

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [April 27, 2023, 8:27am UTC](https://community.hubspot.com/t/contacts-api-is-returning-same-data/80100/2 "2023-04-27T08:27:31Z")

</div>

Hello @michaelhsu2011

It’s possible that the issue you’re experiencing is related to the way the API is handling pagination. When using pagination in the HubSpot API, you should always make sure to store the vidOffset value returned in the response and pass it back in subsequent requests using the vidOffset parameter. This ensures that you’re retrieving the next page of results and not duplicating previous results.

Here’s an example of how to use pagination with the hubspotClient.crm.contacts.basicApi.getPage method in Python:

```lia-code-sample
import hubspot
from hubspot.crm.contacts.basic_api import BasicApi

hubspot = hubspot.HubSpot()
basic_api = BasicApi(hubspot.api_client)

limit = 10
vid_offset = None

while True:
 # Set up the query params
 query_params = {
 "limit": limit,
 "vidOffset": vid_offset
 }

 # Get the page of contacts
 response = basic_api.get_page(**query_params)
 contacts = response.results

 # Do something with the contacts
 for contact in contacts:
 print(contact)

 # If there are no more results, exit the loop
 if not response.has_more:
 break

 # Set the vidOffset for the next page
 vid_offset = response.paging.next.vid_offset

```

In this example, we use a `while` loop to retrieve all pages of contacts, storing the `vidOffset` value returned in each response and passing it back in subsequent requests. Note that we’re also checking the `has_more` property in the response to determine when we’ve reached the end of the results.

If you’re already using pagination correctly and still experiencing the issue, it may be worth contacting HubSpot support for further assistance.
