{"id":3896,"library":"axiom-py","title":"Axiom Python SDK","description":"axiom-py is the official Python SDK for interacting with the Axiom API, allowing users to ingest, query, and manage observability data at scale. It provides both synchronous and asynchronous clients. The current version is 0.10.0 and it maintains an active release cadence with ongoing development.","status":"active","version":"0.10.0","language":"en","source_language":"en","source_url":"https://github.com/axiomhq/axiom-py.git","tags":["observability","logging","metrics","tracing","axiom","sdk","cloud"],"install":[{"cmd":"pip install axiom-py","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"Client","correct":"from axiom_py import Client"},{"symbol":"AsyncClient","correct":"from axiom_py import AsyncClient"},{"symbol":"AxiomHandler","correct":"from axiom_py.logging import AxiomHandler"},{"symbol":"AxiomProcessor","correct":"from axiom_py.structlog import AxiomProcessor"}],"quickstart":{"code":"import os\nfrom axiom_py import Client\nimport asyncio\n\nAXIOM_TOKEN = os.environ.get('AXIOM_TOKEN', 'YOUR_AXIOM_TOKEN')\nAXIOM_ORG_ID = os.environ.get('AXIOM_ORG_ID', 'YOUR_AXIOM_ORG_ID')\nDATASET_NAME = os.environ.get('AXIOM_DATASET', 'your-dataset-name')\n\nasync def main():\n    if not AXIOM_TOKEN or not AXIOM_ORG_ID or not DATASET_NAME:\n        print(\"Please set AXIOM_TOKEN, AXIOM_ORG_ID, and AXIOM_DATASET environment variables or replace placeholders.\")\n        return\n\n    client = Client(token=AXIOM_TOKEN, org_id=AXIOM_ORG_ID)\n\n    # Ingest events\n    try:\n        response = client.ingest_events(\n            dataset=DATASET_NAME,\n            events=[\n                {\"service\": \"my-app\", \"level\": \"info\", \"message\": \"User logged in\"},\n                {\"service\": \"my-app\", \"level\": \"debug\", \"message\": \"Processing data\"}\n            ]\n        )\n        print(f\"Ingest response: {response}\")\n    except Exception as e:\n        print(f\"Error during ingest: {e}\")\n\n    # Query data\n    try:\n        query_result = client.query(f\"['{DATASET_NAME}'] | limit 2\")\n        print(f\"Query result matches: {len(query_result.matches)}\")\n        for match in query_result.matches:\n            print(match.data)\n    except Exception as e:\n        print(f\"Error during query: {e}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to initialize the Axiom client using environment variables for security, ingest sample events, and then query them. It uses the asynchronous client for better performance."},"warnings":[{"fix":"Review your aggregation queries and update them to use the new method for specifying aggregation operations, likely string-based or a different object structure. Refer to the official documentation for updated aggregation syntax.","message":"Version v0.9.0 removed the 'aggregation operation enum'. If you were using this enum for defining aggregation operations, your code will break.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Ensure you generate and use an API token (xaat- prefixed) for edge ingestion and explicitly set the `edge` or `edge_url` parameter when initializing the `Client` or `AsyncClient`.","message":"When using edge endpoints for ingestion and query operations, you must use API tokens (prefixed with `xaat-`) and pass the edge configuration explicitly to the client constructor. Personal tokens are not supported for edge endpoints.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Set the `AXIOM_TOKEN` and `AXIOM_ORG_ID` environment variables, or pass `token` and `org_id` arguments explicitly to the `axiom_py.Client()` or `axiom_py.AsyncClient()` constructor. For example: `client = axiom_py.Client(token='YOUR_TOKEN', org_id='YOUR_ORG_ID')`.","message":"Axiom client initialization requires an API token and optionally an organization ID. These can be passed directly to the constructor or set via `AXIOM_TOKEN` and `AXIOM_ORG_ID` environment variables. Failing to provide these will result in authentication errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}