Skip to main content

axiom-py CI PyPI version Python version

Install

pip install axiom-py

Synchronous Client

import axiom_py

client = axiom_py.Client()

client.ingest_events(dataset="DATASET_NAME", events=[{"foo": "bar"}, {"bar": "baz"}])
client.query(r"['DATASET_NAME'] | where foo == 'bar' | limit 100")

Edge Ingestion

For improved data locality, you can configure the client to use regional edge endpoints for ingest and query operations. All other API operations continue to use the main Axiom API endpoint.

import axiom_py

# Using a regional edge domain
edge_client = axiom_py.Client(
    token="xaat-your-api-token",
    edge="eu-central-1.aws.edge.axiom.co"
)

# Or using an explicit edge URL
edge_client = axiom_py.Client(
    token="xaat-your-api-token",
    edge_url="https://custom-edge.example.com"
)

Note: Edge endpoints require API tokens (xaat-), not personal tokens. Edge configuration must be passed explicitly when creating the client.

Metrics Queries (MPL)

To query OTel metrics using MPL (Metrics Processing Language), configure the client with your edge endpoint and use mpl_query:

import axiom_py
from axiom_py import MplOptions
from datetime import datetime, timedelta, timezone

client = axiom_py.Client(
    token="xaat-your-api-token",
    edge="us-east-1.aws.edge.axiom.co"
)

end = datetime.now(timezone.utc)
start = end - timedelta(hours=1)

result = client.mpl_query(
    "`my-metrics`:`http.server.duration` | align to 5m using avg",
    opts=MplOptions(start_time=start, end_time=end),
)

for series in result.series:
    print(series.metric, series.tags, series.data)

Asynchronous Client

The library also provides an async client for use with asyncio:

import asyncio
from axiom_py import AsyncClient

async def main():
    async with AsyncClient() as client:
        # Ingest events
        await client.ingest_events(
            dataset="DATASET_NAME",
            events=[{"foo": "bar"}, {"bar": "baz"}]
        )

        # Query data
        result = await client.query(r"['DATASET_NAME'] | where foo == 'bar' | limit 100")
        print(f"Found {len(result.matches)} matches")

asyncio.run(main())

Concurrent Operations

The async client enables efficient concurrent operations:

import asyncio
from axiom_py import AsyncClient

async def main():
    async with AsyncClient() as client:
        # Ingest to multiple datasets concurrently
        await asyncio.gather(
            client.ingest_events("dataset1", [{"event": "data1"}]),
            client.ingest_events("dataset2", [{"event": "data2"}]),
            client.ingest_events("dataset3", [{"event": "data3"}]),
        )

asyncio.run(main())

Documentation

Read documentation on axiom.co/docs/guides/python.

License

MIT

Metadata

Release files for axiom-py 0.14.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 axiom-py 0.14.0
File Size Uploaded
axiom_py-0.14.0.tar.gz 120.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for axiom-py 0.14.0
File Interpreter ABI Platform
axiom_py-0.14.0-py3-none-any.whl Python 3 none any Details

Total release size: 158.4 kB

Release files / axiom_py-0.14.0.tar.gz

Download URL axiom_py-0.14.0.tar.gz
Size 120.1 kB
Tags Source
SHA-256 checksum
How to use checksums
51bdb4c083b12ae6f9a0fea6c9eaef004de91d71a35ab8483440d7427eb8b447
BLAKE2b-256 checksum
How to use checksums
79ef49577df5c3296169f36b6e4a90eb1e0397dddb8eb909de907137023ff3d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / axiom_py-0.14.0-py3-none-any.whl

Download URL axiom_py-0.14.0-py3-none-any.whl
Size 38.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ecaccb40771204b8bdd8c59acf606ac1c65adbda30fb7aefc2ec6a2e0e3d365
BLAKE2b-256 checksum
How to use checksums
11a299e3903aa650ee366fa7b2f59227f55de358680d2ef7c0aabd717e01f645
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7
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