Skip to main content

Retrieve air quality data from the Clarity.io API

Project description

clarityio

This package wraps the API for Clarity air quality sensors. It makes calls to v2 of the API, which as of July 2024 is the newest version of the API.

Development status

This package is in alpha status, currently being developed and subject to major changes.

Implemented endpoints

  • Recent measurements: POST {baseUrl}/v2/recent-datasource-measurements-query
  • Per-Org Datasources summary: GET {baseURl}/v2/datasources
  • Per-Datasource details: GET {baseURl}/v2/datasources/:datasourceId

Not yet implemented

  • Continuations
  • Historical measurements
  • All other endpoints.

Usage

Initialize API connection

Find your API key and org in your Clarity.io user profile. Log in at https://dashboard.clarity.io, then click the person icon on the top-right corner.

Use these values to initialize a connection:

import clarityio
import pandas as pd
api_connection = clarityio.ClarityAPIConnection(api_key='YOUR_API_KEY', org='YOUR_ORG')

Retrieve recent measurements

See API docs for valid arguments to pass, e.g., retrieve daily data instead of hourly, or in CSV format instead of JSON.

request_body = { # the required value for 'org' is automatically passed from the connection object
        'allDatasources': True,
        'outputFrequency': 'hour',
        'format': 'json-long',
        'startTime': '2024-07-05T00:00:00Z'
}
response = api_connection.get_recent_measurements(data=request_body)
df = pd.DataFrame(response['data'])

List data sources

datasources_response = api_connection.get_datasources()
datasources = pd.json_normalize(datasources_response['datasources'])

Get details for a specific data source

Obtain the IDs from the prior block of code.

source_details_response = api_connection.get_datasource_details('A_DATA_SOURCE_ID')
source_details = pd.json_normalize(source_details_response['datasource'])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clarityio-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

clarityio-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file clarityio-0.1.0.tar.gz.

File metadata

  • Download URL: clarityio-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for clarityio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 79332cbb82127957fb4ec91723ac414e6d347350bf8b966af0590de5cd2997ad
MD5 6e3c337defcfc7dda123f80be12fb7d9
BLAKE2b-256 d52996b0d312d85fa63a06d544585bdcdba5076f69732232fc6cce3576973278

See more details on using hashes here.

File details

Details for the file clarityio-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clarityio-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for clarityio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 505b54e07769727d33a374a5db08e257e93986951223b734db1d9b925d394fbd
MD5 1155ebea9d318629f443413c2cbc66ed
BLAKE2b-256 15ace982591db07c1f7af6c1f36e7f0f31d84d2ecd0b38dfb481f41716074e36

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