Microsoft Clarity Data Export API
Project description
Microsoft Clarity API
Version: 0.0.3
Microsoft Clarity Data Export API
This Python library allows you to work with the dashboard data. The data can be structured over a specified date range and can break down insights by up to three dimensions.
Find out more about the Clarity Data Export API
This repository is actively maintained - Contributions are welcome!
Getting Started:
Prerequisites
- An active Microsoft Clarity account. Learn how to sign up for Clarity.
- An API access token generated by the project's admin from the settings page.
- Python3.8+
Obtaining Access Tokens
Note: Only project admins can manage access tokens.
- Go to your Clarity project. Select
Settings
->Data Export
->Generate new API token
. - Provide a descriptive name for the token for easy identification.
Parameters
numOfDays
: (1, 2, or 3) The number of days for the data export since the API call, relating to the last 24, 48, or 72 hours, respectively.dimension1
: The first dimension to break down insights.dimension2
: The second dimension to break down insights.dimension3
: The third dimension to break down insights.
Dimension Options:
- Browser
- Device
- Country
- OS
- Source
- Medium
- Campaign
- Channel
- URL
Usage:
#!/usr/bin/python
# coding: utf-8
import clarity_api
# Use token generated from the steps above
token = "<TOKEN>"
url = "https://www.clarity.ms"
client = clarity_api.Api(url=url, token=token)
data = client.get_data_export(number_of_days=2, dimension_1="OS", dimension_2="Channel")
print("Pydantic Object:", data)
print("Raw Request Output:", data.raw_output)
print("JSON Request Output:", data.json_output)
print("Pydantic Object Model Dump:", data.model_dump())
print("Request Status Code:", data.status_code)
print("Request Error:", data.error)
Installation Instructions:
Install Python Package
python -m pip install clarity-api
Tests:
pre-commit check
pre-commit run --all-files
pytest
pytest ./test/test_clarity_models.py
Repository Owners:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file clarity_api-0.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: clarity_api-0.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47f74780e62e6684654e51a5d70f6617d3e6dcbd33872e5187996a6c9a01224b |
|
MD5 | 5d7c564338d84a64ca6a83af47316fe1 |
|
BLAKE2b-256 | 10c0fa14a53ae6e2df41fcf9d9c43de5da1fa6a046ae1721bcfa8799ccaa67ee |