Make API calls#

The example below demonstrates how to make an API call to 4Insight.io For the complete overview of available API calls see 4Insight REST API.

response = session.get("https://api.4insight.io/v1.1/Campaigns")

Some API endpoints support OData and have paging, which returns a limited number of responses per page. For these endpoints, the get_pages method can be useful:

response = session.get_pages("https://api.4insight.io/v1.1/Campaigns")

# Iterate through response pages:
for page in response:
    print(page)

# Alternatively, get just the next page:
page = next(response)

get_pages returns a generator object, from which the user can iterate through the page, or obtain the pages one by one by calling next(response).