do_search
The hubspot-python client only lets me pull 100 contacts at a time. I want to pull at least 2000. I saw that I would do that through pages but how do I implement in python?
def search(riding):
public_object_search_request = PublicObjectSearchRequest(
filter_groups=[
{
"filters": [
{
"value": riding,
"propertyName": "riding",
"operator": "EQ"
}
]
}
], properties=['firstname','lastname','email','phone','address','city','zip','riding','ballot1','ballot2','ballot3','ballot4','recruited_by'], limit=100
)
try:
api_response = api_client.crm.contacts.search_api.do_search(public_object_search_request=public_object_search_request)
pprint(api_response)
return api_response.__dict__
except ApiException as e:
print("Exception when calling search_api->do_search: %s\n" % e)
How can I iteratively page through to get every contact
Hi @SSyed94 ,
I hope you’re doing well. I just wanted to provide you with some guidance on using the “after” keyword in the API request payload.
To achieve this, please utilize the following curl command:
curl --request GET \
--url ‘https://api.hubapi.com/crm/v3/objects/contacts?limit=10&after=<PUT%20Value(paging.next.after)%20from%20the%20response%20of%20first%20call%20of%20api>&archived=false’ \
--header ‘authorization: Bearer YOUR_ACCESS_TOKEN’
Upon making the initial API call, you will receive a response that contains a JSON Object called “paging”. Inside this object, you will find the “after” value. This value can be used to access the next set of 100 contacts. Please note that you will continue making these calls until the “paging” field is no longer present in the response.
When implementing the iteration process, it is recommended to use a do-while loop.
If you have any further questions or need additional assistance, please don’t hesitate to reach out.
Hope this will helps you out. Please mark it as Solution Accepted & Upvote to help other Community member.
Thanks!
I was wondering how to do it using the python-api client that Hubspot provides