---
title: Query data
description: Query data stored in InfluxDB 3 Cloud using SQL or InfluxQL.
url: https://docs.influxdata.com/influxdb3/cloud/api/query-data/
estimated_tokens: 1553
product: InfluxDB 3 Cloud
version: cloud
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb3/cloud/api/query-data/
---

[Download InfluxDB 3 Cloud API Spec](/openapi/influxdb3-cloud-openapi.yml)

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`requiredstring

`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 bodyrequired

Content-Type:`application/json`

Example request[Ask AI about this](#)

```sh
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

200Success. The response body contains query results.

`results`object[]

Example request body

```json
{
  "results": [
    {
      "series": [
        {
          "columns": [
            "time",
            "value"
          ],
          "name": "mytable",
          "values": [
            [
              "2024-02-02T12:00:00Z",
              42
            ]
          ]
        }
      ]
    }
  ]
}
```

400Bad request.

401Unauthorized access.

`data`object

`error`string

403Access denied.

404Database not found.

405Method not allowed.

422Unprocessable 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](#)

```sh
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

200Success. The response body contains query results.

`results`object[]

Example request body

```json
{
  "results": [
    {
      "series": [
        {
          "columns": [
            "time",
            "value"
          ],
          "name": "mytable",
          "values": [
            [
              "2024-02-02T12:00:00Z",
              42
            ]
          ]
        }
      ]
    }
  ]
}
```

400Bad request.

401Unauthorized access.

`data`object

`error`string

403Access denied.

404Database not found.

405Method not allowed.

422Unprocessable entity.

GET`/api/v3/query_sql`

### Execute SQL query

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

#### Parameters

##### Query parameters

`db`requiredstring

The name of the database.

`q`requiredstring \<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 bodyrequired

Content-Type:`application/json`

Example request[Ask AI about this](#)

```sh
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

200Success. The response body contains query results.

`results`object[]

Example request body

```json
{
  "results": [
    {
      "series": [
        {
          "columns": [
            "time",
            "value"
          ],
          "name": "mytable",
          "values": [
            [
              "2024-02-02T12:00:00Z",
              42
            ]
          ]
        }
      ]
    }
  ]
}
```

400Bad request.

401Unauthorized access.

`data`object

`error`string

403Access denied.

404Database not found.

405Method not allowed.

422Unprocessable 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](#)

```sh
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

200Success. The response body contains query results.

`results`object[]

Example request body

```json
{
  "results": [
    {
      "series": [
        {
          "columns": [
            "time",
            "value"
          ],
          "name": "mytable",
          "values": [
            [
              "2024-02-02T12:00:00Z",
              42
            ]
          ]
        }
      ]
    }
  ]
}
```

400Bad request.

401Unauthorized access.

`data`object

`error`string

403Access denied.

404Database not found.

405Method not allowed.

422Unprocessable entity.

#### Related

* [Query data](/influxdb3/cloud/query-data/)
* [InfluxDB 3 API client libraries](/influxdb3/cloud/reference/client-libraries/v3/)
