Python implementation for Analytics API

Hi,

I am looking for a python sample or documentation for Analytics API implementation using private apps.

Get analytics data breakdowns | Analytics API (hubspot.com)

Is there any tutorial or code sample available for the same?

Hi, @ATripathi8 :waving_hand: Can you tell us more about your goal? I have a feeling we can get help from the minds of @taran42 and @JBeatty, but we’ll probably need additional information to be able to give you a specific recommendation if possible.

Thank you! — Jaycee

Hi @ATripathi8,

Here is a simple python example using enviornmental variables for the secret app token, and the requests library to actually make the request:

import requests
import os

url = 'https://api.hubapi.com/analytics/v2/reports/totals/total'
params = {'start': '20220101', 'end': '20220301'}
headers = {'Authorization': 'Bearer '+ os.environ['APPTOKEN']}

r = requests.get(url, headers=headers, params=params)

print(r.json())

Best,