Skip to main content

Axes Client Library

Python client for the Axes data API. Send SQL, get parquet back.

pip install axes-client

Quickstart

from axes import sql

result = sql("SELECT state, AVG(income) FROM american_community_survey.demographics GROUP BY state")

result.rows        # int — number of rows
result.bytes       # int — parquet response size in bytes
result.columns     # list[str] — ordered column names
result.elapsed_ms  # int — wall-clock time for the request

# Check size before loading into memory
if result.bytes < 100 * 1024 * 1024:
    df = result.collect()   # polars DataFrame — full result in memory
else:
    lf = result.scan()      # polars LazyFrame — safe for large results

# Save to parquet
result.save("/work/result.parquet")

# Stream directly to a file — never buffers the full response in memory
result = sql(
    "SELECT * FROM american_community_survey.demographics",
    out="/work/result.parquet",
)
lf = result.scan()  # polars LazyFrame over the file

Results under 10 MB are kept in memory. Larger results spill to a temp file in /tmp and are deleted when the SqlResult is garbage collected. .scan() is always safe — it returns a scan_parquet LazyFrame when spilled rather than loading into memory.

Configuration

export AXES_TOKEN=your-personal-access-token

AXES_ENDPOINT defaults to https://app.axes.com. Override it if you are running a self-hosted instance:

export AXES_ENDPOINT=https://your-axes-instance.com
export AXES_TOKEN=your-personal-access-token

Explicit client

from axes import Client, sql

client = Client(
    endpoint="https://your-axes-instance.com",
    token="your-token",
)

result = sql("SELECT * FROM american_community_survey.demographics", client=client)

CLI

# Stream rows to stdout as newline-delimited JSON (ndjson), one object per line
axes sql "SELECT state, AVG(income) FROM american_community_survey.demographics GROUP BY state"

# Pipe to jq — each line is a standalone JSON object
axes sql "SELECT state FROM american_community_survey.demographics" | jq '.state'

# Write parquet and print a JSON summary
axes sql "SELECT * FROM american_community_survey.demographics" --out /work/result.parquet

When --out is provided, a JSON summary is printed to stdout:

{
  "path": "/work/result.parquet",
  "rows": 51,
  "bytes": 4096,
  "columns": ["state", "income"],
  "elapsed_ms": 340
}

Errors

from axes.exceptions import QueryError, ResultTooLarge, AuthError

try:
    result = sql("SELECT * FROM american_community_survey.demographics")
except QueryError as e:
    print(e.message)      # SQL rejected by the server (400)
except ResultTooLarge as e:
    print(e.message)      # Exceeded row/byte cap (413)
except AuthError as e:
    print(e.status_code)  # 401 or 403

Appending data

append_table_data uploads a parquet file to an existing table. It needs a write-scoped token bound to the target dataset — the ingestion runner injects one as AXES_TOKEN; personal access tokens are read-only and raise AuthError.

from axes import append_table_data

# Accepts a polars DataFrame, a parquet path, or raw parquet bytes
result = append_table_data("demographics", df)

result.row_count           # rows written
result.byte_count          # bytes written
result.table_data_file_id  # id of the created file

# Atomically retire this firing's earlier files instead of adding to them
append_table_data("demographics", df, replace=True)

The uploaded parquet's columns must match the table's registered schema; a mismatch raises WriteError (409).

Agent framework

axes.agent is the container-side framework for authoring Chat Plot agents. Agents already read the data catalog through this client, so the framework ships here rather than as a separate package.

from axes.agent import Agent, Tool, RunContext

Author an agent as an Agent subclass with Tool members (and other Agent instances as subagents); the axes-agent console script reads one step off stdin, runs plan_step or run_tool, and writes the result to stdout. Chat Plot drives the multi-turn loop and owns the LLM call, persistence, and streaming. See weather-agent for a worked example.

Development

uv sync

uv run task test    # pytest
uv run task lint    # ruff check
uv run task format  # ruff format
uv run task check   # mypy (strict)

task fix runs ruff check --fix. Linting (ruff), formatting, and strict type checking (mypy) all run in CI on every push and pull request.

Release files for axes-client 0.5.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 axes-client 0.5.0
File Size Uploaded
axes_client-0.5.0.tar.gz 75.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for axes-client 0.5.0
File Interpreter ABI Platform
axes_client-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 103.7 kB

Release files / axes_client-0.5.0.tar.gz

Download URL axes_client-0.5.0.tar.gz
Size 75.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ce413f2e9932d88238d1db8cd31f0b9b4408ebd17152b7a35e175c06caa2709d
BLAKE2b-256 checksum
How to use checksums
f335eaa4d01b133f8ea9b3469d876c14f906978cb42b2de39f85b3136cc59e5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / axes_client-0.5.0-py3-none-any.whl

Download URL axes_client-0.5.0-py3-none-any.whl
Size 28.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78656734316c1188aceead3c8221699fb9cb9fba2d0966c2a0c34cf415eb67b3
BLAKE2b-256 checksum
How to use checksums
c50db3ec73e3b219e37d5bb555735ee9424490281cfcc1be7cf0d19ede49d34e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

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