Skip to content

Official Python bindings for the Axiom API

License

Notifications You must be signed in to change notification settings

axiomhq/axiom-py

Repository files navigation

Warning

Version v0.9.0 removes the aggregation operation enum, see #158.

axiom-py CI PyPI version Python version

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")

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())

Install

pip install axiom-py

Documentation

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

License

MIT

About

Official Python bindings for the Axiom API

Topics

Resources

License

Stars

Watchers

Forks

Contributors 24

Languages