Query data via Axiom API
Learn how to use the Axiom API to query data.
This page explains how to query data via the Axiom API using the following:
For an introduction to the basics of the Axiom API and to the authentication options, see Introduction to Axiom API.
The API requests on this page use the query data endpoint. For more information, see the API reference.
Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to update 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
startTime
andendTime
. For more information, see the query data API reference. - Set the
Content-Type
header toapplication/json
. - Set the
Authorization
header toBearer API_TOKEN
. ReplaceAPI_TOKEN
with the Axiom API token you have generated. - Send the POST request to one of the following:
- For tabular output, use
https://api.axiom.co/v1/datasets/_apl?format=tabular
. - For legacy output, use
https://api.axiom.co/v1/datasets/_apl?format=legacy
.
- For tabular output, use
Example
Replace API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable.
Example response
Query data with Axiom Node.js
-
Install and configure the Axiom Node.js library.
-
Build the APL query. For more information, see Introduction to APL.
-
Pass the APL query as a string to the
axiom.query
function.
For more examples, see the examples in GitHub.
For more information on other libraries you can use to query data, see Send data.
Was this page helpful?