Documentation menu

Python SDK

The asense package reads your sensor data into pandas or Polars frames and follows the API's paging for you. It also has a command-line tool.

View as Markdown

Coming soon

The package is not on PyPI yet. This page shows how it will work once it is published.

Install

pip install asense            # with pandas
pip install 'asense[polars]'  # adds Polars

First request

The SDK reads your API key from the ASENSE_API_KEY environment variable, or you can pass it to the client.

export ASENSE_API_KEY=...
from asense import Client

client = Client()  # or Client(api_key="...")

# Hourly summaries for one day, one row per hour
hourly = client.get("data", "ASENSE00000005", "2025-10-01", "2025-10-02")

# Five minutes of raw acceleration, one row per sample
acc = client.get("acc", "ASENSE00000005",
                 "2025-10-01T10:00:00Z", "2025-10-01T10:05:00Z")
acc.plot(x="timestamp", y=["acc_x", "acc_y", "acc_z"])

# The same as a Polars frame
acc_pl = client.get("acc", "ASENSE00000005",
                    "2025-10-01T10:00:00Z", "2025-10-01T10:05:00Z", engine="polars")

Times can be Unix milliseconds, ISO 8601 strings, or datetime and date objects. A time without a time zone is read as UTC.

What a frame looks like

Every frame has id, time in Unix milliseconds and timestamp as a UTC datetime. The other columns depend on the table, as described in the data model.

TableOne row perColumns
accsampleacc_x, acc_y, acc_z, plus tamb, w_s and w_d where the packet has them
gyrsamplegyr_x, gyr_y, gyr_z
ainsampleain_a, ain_b
fftrecord and frequency binfreq, fft_x, fft_y, fft_z
datahourly recordevery summary field; w_s_avg is split into w_s_avg_0 to w_s_avg_5
envrecordevery field of the record
connectedconnectionevery field of the record

Options

Client.get, Client.query, Client.pages and Client.items take the API's parameters as keyword arguments: limit, ascending, merge, output_format, enable_correction, sync_acc_gyr, auto_odr and load_prior_elements. An option you leave out is not sent, so the API's default applies. get() always asks for dict_array output, because that is what it turns into a frame. Use extra={...} to send any other query parameter as it is. Requests and parameters describes each one.

Pages and raw responses

client.query("env", "ASENSE00000005", start, end)        # one raw page, as a dict
for page in client.pages("acc", "ASENSE00000005", start, end, limit=64):
    ...                                                   # every raw page in turn
client.timestamps("data", "ASENSE00000005", start, end)  # record times only (data, env)
client.health("ASENSE00000005", start, end)              # connection times

pages() follows next_timestamp for you. It becomes the next page's start time, or its end time when ascending=False. Pagination explains the rule.

Errors

Every error the SDK raises is an asense.AsenseError. ValidationError means an argument was wrong, and no request was sent. BadRequestError (400), AuthenticationError (401 and 403), RateLimitError (429) and ServerError (5xx) are API answers, and each carries status_code, message and body. TransportError means no answer came back, for example because of a network failure or a timeout.

Command line

The package installs an asense command. It reads the key from --api-key or ASENSE_API_KEY.

asense tables
asense get data ASENSE00000005 --start 2025-10-01 --end 2025-10-02
asense get acc ASENSE00000005 --start 2025-10-01T10:00Z --end 2025-10-01T10:05Z -o acc.csv
asense get env ASENSE00000005 --start 2025-10-01 --end 2025-10-08 --descending --format json
asense get fft ASENSE00000005 --start 2025-10-01 --end 2025-10-02 --raw
asense timestamps data ASENSE00000005 --start 2025-10-01 --end 2025-11-01
asense health ASENSE00000005 --start 2025-10-01 --end 2025-10-02

Writing to a .parquet file with -o needs pyarrow installed.