Im testing the api (hubspotClient.crm.contacts.basicApi.getPage) from the website (Accounts Dashboard | HubSpot) 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.
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:
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.