Skip to main content

Microsoft Clarity Data Export API

Project description

Microsoft Clarity API

PyPI - Version PyPI - Downloads GitHub Repo stars GitHub forks GitHub contributors PyPI - License GitHub

GitHub last commit (by committer) GitHub pull requests GitHub closed pull requests GitHub issues

GitHub top language GitHub language count GitHub repo size GitHub repo file count (file type) PyPI - Wheel PyPI - Implementation

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.

  1. Go to your Clarity project. Select Settings -> Data Export -> Generate new API token.
  2. 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:

GitHub followers GitHub User's stars

Project details


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

clarity_api-0.0.3-py2.py3-none-any.whl (8.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file clarity_api-0.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for clarity_api-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 47f74780e62e6684654e51a5d70f6617d3e6dcbd33872e5187996a6c9a01224b
MD5 5d7c564338d84a64ca6a83af47316fe1
BLAKE2b-256 10c0fa14a53ae6e2df41fcf9d9c43de5da1fa6a046ae1721bcfa8799ccaa67ee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page