Skip to main content
To send data from a Python app to Axiom, use the Axiom Python SDK.
The Axiom Python SDK is an open-source project and welcomes your contributions. For more information, see the GitHub repository.

Prerequisites

Install SDK

If you use the Axiom CLI, run eval $(axiom config export -f) to configure your environment variables. Otherwise, create an API token and export it as AXIOM_TOKEN. You can also configure the client using options passed to the client constructor:

Use client

For more examples, see the examples in GitHub.

Configure region

By default, the client sends data to api.axiom.co. To target a specific edge region, pass the edge argument with the edge domain that matches the region your dataset lives in:
The following edge domains are available: For more information about edge deployments, see Edge deployments. To point at a custom edge endpoint such as a proxy or load balancer, use edge_url="https://your-edge-host" instead. edge_url takes precedence over edge if both are set.
Edge endpoints require an API token (xaat-), not a personal token (xapt-). Passing a personal token with edge configuration raises an error.
Edge configuration must be passed explicitly when you create the client. Unlike token and org_id, the edge and edge_url arguments are not read from environment variables.

Example with AxiomHandler

The example below uses AxiomHandler to send logs from the logging module to Axiom:
For a full example, see GitHub.

Example with structlog

The example below uses structlog to send logs to Axiom:
For a full example, see GitHub.