Documentation

Use the InfluxDB v1 HTTP query API and InfluxQL

Use the InfluxDB v1 HTTP API /query endpoint and InfluxQL to query data stored in InfluxDB Cloud Serverless and return results in JSON or CSV format. The /query endpoint provides compatibility for InfluxDB 1.x workloads that you bring to InfluxDB v3.

Before you can use the v1 query API, databases and retention policies must be mapped to buckets.

Flight queries don’t use DBRP mappings

When using Flight RPC or Flight SQL to query InfluxDB, specify the bucket name. Flight queries don’t use DBRP mappings. See how to get started querying with Flight and SQL or InfluxQL.

Query the v1 /query endpoint

To query using HTTP and InfluxQL, send a GET or POST request to the v1 /query endpoint.

GET https://cloud2.influxdata.com/query

Parameters

For InfluxDB Cloud Serverless v1 API /query requests, set parameters as listed in the following table:

Parameter Allowed in Ignored Value
chunked Ignored N/A (Note that an unbounded query might return a large amount of data)
db Query string Honored Database name mapped to a bucket
epoch Query string Honored Timestamp precision
pretty Query string Ignored N/A
rp Query string Honored Retention policy mapped to a bucket
q Query string Honored InfluxQL
Authorization header or u and p Token

When bringing v1 API workloads to InfluxDB Cloud Serverless, you’ll need to adjust request parameters in your client configuration or code.

Timestamp precision

Use one of the following values for timestamp precision (epoch):

  • ns: nanoseconds
  • us: microseconds
  • ms: milliseconds
  • s: seconds
  • m: minutes
  • h: hours

Authorization

To authorize a query request, include a token that has read permission for the bucket. Use Token authentication or v1-compatible username and password authentication to include a token in the request.

Return results as JSON or CSV

By default, the /query endpoint returns results in JSON format.

To return results in CSV format, include the Accept header with the application/csv or text/csv MIME type–for example:

curl --get https://cloud2.influxdata.com/query \
  --header "Authorization: Token 
DATABASE_TOKEN
"
\
--header "Accept: application/csv" \ --data-urlencode "db=
DATABASE_NAME
"
\
--data-urlencode "q=SELECT * FROM home"

Tools for querying the v1 API

Interactive clients

To test InfluxDB v1 API queries interactively from the command line, use common HTTP clients such as cURL and Postman.

curl https://cloud2.influxdata.com/query \
  --header "Authorization: Token 
API_TOKEN
"
\
--data-urlencode "db=
DATABASE_NAME
"
\
--data-urlencode "q=SELECT * FROM home"

Replace the following:

curl --get https://cloud2.influxdata.com/query \
  -user "":"API_TOKEN" \
  --data-urlencode "db=
DATABASE_NAME
"
\
--data-urlencode "q=SELECT * FROM home"
curl --get https://cloud2.influxdata.com/query \
  --data-urlencode "u=ignored" \
  --data-urlencode "p=
DATABASE_TOKEN
"
\
--data-urlencode "db=
DATABASE_NAME
"
\
--data-urlencode "q=SELECT * FROM home"

Troubleshoot failures

Troubleshoot problems and errors encountered when using the HTTP API to query InfluxDB Cloud Serverless.

Database not found

If a DBRP doesn’t exist for the db=DATABASE_NAME and rp=RETENTION_POLICY_NAME combination in the query request, the response body contains an error message, for example "database not found:...".

Quota and limit errors

HTTP API /query requests are subject to usage quotas and limits.


Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

InfluxDB Cloud Serverless