Use the InfluxDB v1 HTTP query API and InfluxQL to query data
Use the InfluxDB v1 HTTP query API to query data in InfluxDB Cloud Serverless with InfluxQL.
The examples below use cURL to send HTTP requests to the InfluxDB v1 HTTP API, but you can use any HTTP client.
Databases and retention policies map to InfluxDB buckets
InfluxQL databases and retention policies are used to route queries to an InfluxDB bucket based on database and retention policy (DBRP) mappings. For more information, see Map databases and retention policies to buckets.
InfluxQL feature support
InfluxQL is being rearchitected to work with the InfluxDB IOx storage engine. This process is ongoing and some InfluxQL features are still being implemented. For information about the current implementation status of InfluxQL features, see InfluxQL feature support.
Use the v1 /query
endpoint and the GET
request method to query data with InfluxQL:
GET https://cloud2.influxdata.com/query
Provide the following with your request:
- Headers:
- Authorization:
Token API_TOKEN
- Authorization:
- Query parameters:
- db: the database (bucket) to query
- rp: the retention policy to query. Required if you haven’t configured a default retention policy for the bucket.
- q: URL-encoded InfluxQL query
curl --get https://cloud2.influxdata.com/query \
--header "Authorization: Token API_TOKEN" \
--data-urlencode "db=DATABASE_NAME" \
--data-urlencode "q=SELECT * FROM home"
Replace the following configuration values:
DATABASE_NAME
: the name of the database (bucket) to queryAPI_TOKEN
: an API token with read access to the specified database.
Authenticate with username and password
If using basic authentication or query string authentication (username and password) to interact with the v1 HTTP query API, provide the following credentials:
- username: an arbitrary string (InfluxDB Cloud Serverless ignores the username)
- password: an API token with read access to the specified database.
curl --get https://cloud2.influxdata.com/query \
--header "Authorization: Basic ignored:DATABASE_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"
Return results as JSON or CSV
By default, the /query
endpoint returns results in JSON, but it can also
return results in CSV. To return results as CSV, include the Accept
header
with the application/csv
or text/csv
MIME type:
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"
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.