Skip to main content

Python client for the Axes data API

Project description

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 as JSON to stdout
axes sql "SELECT state, AVG(income) FROM american_community_survey.demographics GROUP BY state"

# Pipe to jq
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

Development

uv sync
uv run python -m pytest tests/ -v

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

axes_client-0.1.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

axes_client-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: axes_client-0.1.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for axes_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c446e8d224f60805be9253633d6dd8a28805753c3d9409a9d5a42043ab3b1155
MD5 8955151ecf0bc7326914d2a4f5b081d2
BLAKE2b-256 adbcf7b3675c3811dacc6b1713c89f3302fffe0ce1c20288b7852ce40c270c74

See more details on using hashes here.

File details

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

File metadata

  • Download URL: axes_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for axes_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bdbf1dca0e91cbdda41e22ef20811d4ed54ee7f910b100ae75e57c73434fdbca
MD5 bf3ccbbe801d266f6b5d8387c8be530e
BLAKE2b-256 bcc1873b023313c77b90924c0588c0359aa75cd1cbf9a29a370ea04f87b5afee

See more details on using hashes here.

Supported by

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