I am trying to pull more than 100 results from associations.batch_api.read in hubspot-api-python. The function does not seem to support pagination: the API response has no paging key I can use, and when I try passing an after cursor like BatchInputPublicObjectId(inputs=[{'id': from_object_id, 'after': after}]) it silently returns the same page, which puts my loop into an infinite cycle. How do I actually paginate associations?
hubspot-api-python: paginating associations with `batch_api.read` silently loops forever
The v3 associations.batch_api.read does not support pagination at all. Passing after is silently ignored because the BatchInputPublicObjectId model has no after field, which is exactly what causes the infinite loop you are seeing. The maintained answer: switch to the v4 associations API, api_client.crm.associations.v4.basic_api.get_page(...), which supports after, limit, and real paging. One quirk to know: in v4 the paging key is only present in the response when there are more pages, so absence of paging means you are on the last page.
Source: https://github.com/HubSpot/hubspot-api-python/issues/187
Source: https://github.com/HubSpot/hubspot-api-python/issues/187