Skip to main content

chronix-client (Python)

Async Python client for the Chronix time-series database.

Features

  • Async-first — built on httpx for non-blocking I/O
  • JSON + Line Protocol writes — both formats supported
  • Structured queries + SQL — first-class support for both query APIs
  • PromQL — instant & range queries via Prometheus-compatible endpoints
  • Arrow Flight SQL — zero-copy queries via ADBC driver
  • Schema introspection — list measurements, get column schemas
  • Multi-tenant — namespace header support
  • Typed — full type annotations with py.typed marker

Installation

pip install chronix-client

With pandas support:

pip install "chronix-client[pandas]"

Quick Start

import asyncio
from chronix_client import ChronixClient, Point, TimeRange

async def main():
    async with ChronixClient("http://localhost:5555") as client:
        # Write
        await client.write([
            Point("cpu", {"usage": 42.5}, tags={"host": "a"})
        ])

        # Query
        result = await client.query(
            "cpu",
            TimeRange(start=0, end=2**63 - 1),
            tag_filters={"host": "a"},
        )
        for row in result:
            print(row)

        # SQL
        result = await client.sql("SELECT * FROM cpu ORDER BY _time DESC LIMIT 10")
        df = result.to_dataframe()  # requires pandas extra

asyncio.run(main())

Line Protocol Writes

await client.write_line_protocol([
    "cpu,host=a usage=42.5 1700000000000000000",
    "mem,host=a total=16384i,used=8192i 1700000000000000000",
])

PromQL Queries

# Instant query
result = await client.prom_query('cpu_usage{host="server-1"}')

# Range query
result = await client.prom_query_range(
    'rate(cpu_usage[5m])',
    start="2024-01-01T00:00:00Z",
    end="2024-01-02T00:00:00Z",
    step="60s",
)

# Label discovery
labels = await client.prom_labels()
values = await client.prom_label_values("host")

Arrow Flight SQL (Zero-Copy)

For high-throughput analytical queries, use Arrow Flight SQL via ADBC:

import adbc_driver_flightsql.dbapi

uri = ChronixClient.flight_sql_uri("localhost", 5557)
conn = adbc_driver_flightsql.dbapi.connect(uri)
cursor = conn.cursor()
cursor.execute("SELECT * FROM cpu WHERE _time > now() - INTERVAL '1 hour'")
table = cursor.fetch_arrow_table()
df = table.to_pandas()

Authentication & Multi-Tenancy

client = ChronixClient(
    "http://localhost:5555",
    api_key="your-api-key",
    namespace="production",
)

Idempotent Writes

await client.write(
    [Point("cpu", {"usage": 42.5})],
    idempotency_key="batch-2024-01-15-001",
)
# Second call with same key → WriteError (HTTP 409)

API Reference

ChronixClient

Method Description
health() Health check
ready() Readiness check
server_info() Server metadata
write(points, *, idempotency_key) Write points (JSON)
write_line_protocol(lines, *, idempotency_key) Write (line protocol)
query(measurement, time_range, *, tag_filters, field_columns, limit) Structured query
sql(query) SQL query
explain(measurement, time_range) Explain query plan
list_measurements() List measurements
get_schema(measurement) Get column schema
drop_measurement(measurement) Drop measurement
delete(measurement, time_range=None, *, tags) Delete data; returns a DeleteResult — check .complete
prom_query(query, *, time) PromQL instant query
prom_query_range(query, start, end, step) PromQL range query
prom_labels() List Prometheus labels
prom_label_values(label) Label values
prom_series(match) Find series
list_rollups() List rollup rules
list_connectors() List connectors
openapi_spec() Fetch OpenAPI spec
flight_sql_uri(host, port) Build Flight SQL URI

Models

Type Description
Point Data point with measurement, tags, fields, timestamp
TimeRange Half-open [start, end) in nanoseconds
QueryResult Query result with .rows, .to_dataframe()
ColumnSchema Column metadata (name, role, data_type)
MeasurementInfo Measurement summary (name)
ServerInfo Server metadata (version, uptime, measurement_count)

Exceptions

Exception When
ChronixError Base exception (server errors)
ConnectionError Cannot reach server
WriteError Write failure (including idempotency conflict)
QueryError Query/client error (4xx)

License

Apache-2.0 — same as Chronix.

Metadata

Release files for chronix-client 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chronix-client 0.2.0
File Size Uploaded
chronix_client-0.2.0.tar.gz 18.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chronix-client 0.2.0
File Interpreter ABI Platform
chronix_client-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.8 kB

Release files / chronix_client-0.2.0.tar.gz

Download URL chronix_client-0.2.0.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d3a644f5486eaaabcc520c8e899f617b6bb4505411ad86b3fef0df21e7124e1a
BLAKE2b-256 checksum
How to use checksums
9b45a3e8882f0329270de3142322d53b7e14ebf776760d1b364791cdf6cfdb17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

Release files / chronix_client-0.2.0-py3-none-any.whl

Download URL chronix_client-0.2.0-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d6a84a4e58d7f9f8c0d3d5afc4e47a497c162d001852708bb753708d80a80e1
BLAKE2b-256 checksum
How to use checksums
bc53e90b73a5b13e0338ec4df6bb56d8b4a42377d4e1d0c2c0437b823d4e389e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page