Paginate through API results
masterPaginated requests return a SyncPager or AsyncPager. You can iterate through the items directly or iterate page-by-page using .iter_pages().
When using .iter_pages(), you can access the typed response for each page via the .response attribute.
from intercom import Intercom
client = Intercom(
token="YOUR_TOKEN",
)
response = client.articles.list()
# Iterate through all items directly
for item in response:
yield item
# Alternatively, paginate page-by-page
for page in response.iter_pages():
yield page
# Access the typed response per page
pager = client.articles.list(...)
for page in pager.iter_pages():
print(page.response) # access the typed response for each page
for item in page:
print(item)