Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to ingest data to the dataset you have created.
Query data with cURL
To query data with cURL:- Build the APL query. For more information, see Introduction to APL.
- Encode the APL query as a JSON object and enter it into the body of the API request.
- Optional: In the body of the request, set optional parameters such as
startTimeandendTime. For more information, see the query data API reference. - Set the
Content-Typeheader toapplication/json. - Set the
Authorizationheader toBearer API_TOKEN. - Send the POST request to one of the following:
- For tabular output, use
https://AXIOM_DOMAIN/v1/query/_apl?format=tabular. - For legacy output, use
https://AXIOM_DOMAIN/v1/query/_apl?format=legacy.
- For tabular output, use
Example
Replace
AXIOM_DOMAIN with the base domain of your edge deployment. For more information, see Edge deployments.Replace API_TOKEN with the Axiom API token you have generated. For added security, store the API token in an environment variable.Replace DATASET_NAME with the name of the Axiom dataset where you send your data.Query data with the Axiom JavaScript library
-
Install and configure the Axiom JavaScript library (
@axiomhq/js). - Build the APL query. For more information, see Introduction to APL.
-
Pass the APL query as a string to the
axiom.queryfunction.ReplaceDATASET_NAMEwith the name of the Axiom dataset where you send your data.
edge option when you create the client. The client then routes queries to the edge query endpoint automatically. For more information, see Configure region.
For more examples, see the examples in GitHub.
For more information on other libraries you can use to query data, see Send data.