Query data

Query data stored in InfluxDB 3 Cloud using SQL or InfluxQL.
GET /api/v3/query_influxql

Execute InfluxQL query

Executes an InfluxQL query to retrieve data from the specified database.

Parameters

Query parameters
db string

The name of the database.

If you provide a query that specifies the database, you can omit the ‘db’ parameter from your request.

q required string
format string
params string
JSON-encoded query parameters for parameterized queries.
Header parameters
Accept string
The content type that the client can understand.
Allowed values: application/json , application/jsonl , application/vnd.apache.parquet , text/csv
Default: application/json

Request body required

Content-Type: application/json
Example request Ask AI about this
curl --request GET \
  "https://cluster-host.a.influxdb.io/api/v3/query_influxql?q=Q" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json"

Responses

200 Success. The response body contains query results.
results object[]
Example request body
{
  "results": [
    {
      "series": [
        {
          "columns": [
            "time",
            "value"
          ],
          "name": "mytable",
          "values": [
            [
              "2024-02-02T12:00:00Z",
              42
            ]
          ]
        }
      ]
    }
  ]
}
400 Bad request.
401 Unauthorized access.
data object
error string
403 Access denied.
404 Database not found.
405 Method not allowed.
422 Unprocessable entity.
POST /api/v3/query_influxql

Execute InfluxQL query

Executes an InfluxQL query to retrieve data from the specified database.

Parameters

Header parameters
Accept string
The content type that the client can understand.
Allowed values: application/json , application/jsonl , application/vnd.apache.parquet , text/csv
Default: application/json
Content-Type string
The format of the data in the request body.
Allowed values: application/json

Request body

Content-Type: application/json
Example request Ask AI about this
curl --request POST \
  "https://cluster-host.a.influxdb.io/api/v3/query_influxql" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{"db":"mydb","format":"json","params":{},"q":"SELECT * FROM mytable"}'

Responses

200 Success. The response body contains query results.
results object[]
Example request body
{
  "results": [
    {
      "series": [
        {
          "columns": [
            "time",
            "value"
          ],
          "name": "mytable",
          "values": [
            [
              "2024-02-02T12:00:00Z",
              42
            ]
          ]
        }
      ]
    }
  ]
}
400 Bad request.
401 Unauthorized access.
data object
error string
403 Access denied.
404 Database not found.
405 Method not allowed.
422 Unprocessable entity.
GET /api/v3/query_sql

Execute SQL query

Executes an SQL query to retrieve data from the specified database.

Parameters

Query parameters
db required string
The name of the database.
q required string <SQL>
The query to execute.
format string
params string
JSON-encoded query parameters for parameterized queries.
Header parameters
Accept string
The content type that the client can understand.
Allowed values: application/json , application/jsonl , application/vnd.apache.parquet , text/csv
Default: application/json
Content-Type string
The format of the data in the request body.
Allowed values: application/json

Request body required

Content-Type: application/json
Example request Ask AI about this
curl --request GET \
  "https://cluster-host.a.influxdb.io/api/v3/query_sql?db=DB&q=Q" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json"

Responses

200 Success. The response body contains query results.
results object[]
Example request body
{
  "results": [
    {
      "series": [
        {
          "columns": [
            "time",
            "value"
          ],
          "name": "mytable",
          "values": [
            [
              "2024-02-02T12:00:00Z",
              42
            ]
          ]
        }
      ]
    }
  ]
}
400 Bad request.
401 Unauthorized access.
data object
error string
403 Access denied.
404 Database not found.
405 Method not allowed.
422 Unprocessable entity.
POST /api/v3/query_sql

Execute SQL query

Executes an SQL query to retrieve data from the specified database.

Parameters

Header parameters
Accept string
The content type that the client can understand.
Allowed values: application/json , application/jsonl , application/vnd.apache.parquet , text/csv
Default: application/json
Content-Type string
The format of the data in the request body.
Allowed values: application/json

Request body

Content-Type: application/json
Example request Ask AI about this
curl --request POST \
  "https://cluster-host.a.influxdb.io/api/v3/query_sql" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{"db":"mydb","format":"json","params":{},"q":"SELECT * FROM mytable"}'

Responses

200 Success. The response body contains query results.
results object[]
Example request body
{
  "results": [
    {
      "series": [
        {
          "columns": [
            "time",
            "value"
          ],
          "name": "mytable",
          "values": [
            [
              "2024-02-02T12:00:00Z",
              42
            ]
          ]
        }
      ]
    }
  ]
}
400 Bad request.
401 Unauthorized access.
data object
error string
403 Access denied.
404 Database not found.
405 Method not allowed.
422 Unprocessable entity.

Was this page helpful?

Thank you for your feedback!