# Python implementation for Analytics API

**URL:** <https://community.hubspot.com/t/python-implementation-for-analytics-api/58697>\
**Category:** APIs & Integrations\
**Tags:** oauth, starter\
**Created:** [June 9, 2022, 12:17pm UTC](https://community.hubspot.com/t/python-implementation-for-analytics-api/58697 "2022-06-09T12:17:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ATripathi8](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@ATripathi8](https://community.hubspot.com/u/ATripathi8)\
**Post date:** [June 9, 2022, 12:17pm UTC](https://community.hubspot.com/t/python-implementation-for-analytics-api/58697/1 "2022-06-09T12:17:34Z")

</div>

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)](https://legacydocs.hubspot.com/docs/methods/analytics/get-analytics-data-breakdowns)

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

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [June 10, 2022, 4:07pm UTC](https://community.hubspot.com/t/python-implementation-for-analytics-api/58697/2 "2022-06-10T16:07:42Z")

</div>

Hi, @ATripathi8 👋 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

---

<div class="post-metadata">

**Author:** ![JBeatty](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jbeatty/32/52252_2.png) [@JBeatty](https://community.hubspot.com/u/JBeatty)\
**Post date:** [June 10, 2022, 5:41pm UTC](https://community.hubspot.com/t/python-implementation-for-analytics-api/58697/3 "2022-06-10T17:41:58Z")

</div>

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:

```lia-code-sample
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,
