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

[Download InfluxDB 3 Enterprise API Spec](/openapi/influxdb3-enterprise-openapi.yml)

Query data stored in InfluxDB 3 Enterprise using SQL or InfluxQL.

GET`/api/v3/query_influxql`

### Execute InfluxQL query

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

With the [performance upgrade preview](/influxdb3/enterprise/performance-preview/) enabled
(`--use-pacha-tree` flag), queries automatically merge results from Parquet and`.pt` files (hybrid query mode).

#### 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://localhost:8181/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.

With the [performance upgrade preview](/influxdb3/enterprise/performance-preview/) enabled
(`--use-pacha-tree` flag), queries automatically merge results from Parquet and`.pt` files (hybrid query mode).

#### 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://localhost:8181/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.

With the [performance upgrade preview](/influxdb3/enterprise/performance-preview/) enabled
(`--use-pacha-tree` flag), queries automatically merge results from Parquet and`.pt` files (hybrid query mode). Use the`/api/v3/query_sql_telemetry` endpoint after executing
a query to retrieve detailed execution statistics.

#### 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://localhost:8181/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.

With the [performance upgrade preview](/influxdb3/enterprise/performance-preview/) enabled
(`--use-pacha-tree` flag), queries automatically merge results from Parquet and`.pt` files (hybrid query mode). Use the`/api/v3/query_sql_telemetry` endpoint after executing
a query to retrieve detailed execution statistics.

#### 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://localhost:8181/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.

GET`/query`

### Execute InfluxQL query (v1-compatible)

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

This endpoint is compatible with InfluxDB 1.x client libraries and third-party integrations such as Grafana.
Use query parameters to specify the database and the InfluxQL query.

#### Related

* [Use the InfluxDB v1 HTTP query API and InfluxQL to query data](/influxdb3/enterprise/query-data/execute-queries/influxdb-v1-api/)

#### Parameters

##### Query parameters

`chunked`boolean

If true, the response is divided into chunks of size `chunk_size`.

`chunk_size`integer

The number of records that will go into a chunk.
This parameter is only used if `chunked=true`.

Default:`10000`

`db`string \<InfluxQL\>

The database to query. If not provided, the InfluxQL query string must specify the database.

`pretty`boolean

If true, the JSON response is formatted in a human-readable format.

`q`requiredstring

The InfluxQL query string.

`epoch`string

Formats timestamps as [unix (epoch) timestamps](/influxdb3/enterprise/reference/glossary/#unix-timestamp) with the specified precision
instead of [RFC3339 timestamps](/influxdb3/enterprise/reference/glossary/#rfc3339-timestamp) with nanosecond precision.

`u`string

Username for v1 compatibility authentication.
When using Basic authentication or query string authentication, InfluxDB 3 ignores this parameter but allows any arbitrary string for compatibility with InfluxDB 1.x clients.

`p`string

Password for v1 compatibility authentication.
For query string authentication, pass a database token with write permissions as this parameter.
InfluxDB 3 checks that the `p` value is an authorized token.

`rp`string

Retention policy name. Honored but discouraged. InfluxDB 3 doesn’t use retention policies.

##### Header parameters

`Accept`string

The content type that the client can understand.

If `text/csv` is specified, the `Content-type` response header is `application/csv` and the response is formatted as CSV.

Returns an error if the format is invalid or non-UTF8.

Allowed values:`application/json`, `application/csv`, `text/csv`

Default:`application/json`

`Authorization`string

Authorization header for token-based authentication.
Supported schemes:

* `Bearer AUTH_TOKEN` - OAuth bearer token scheme
* `Token AUTH_TOKEN` - InfluxDB v2 token scheme
* `Basic <base64-encoded USERNAME:AUTH_TOKEN>` - Basic authentication (username is ignored)

Example request[Ask AI about this](#)

```sh
curl --request GET \
  "https://localhost:8181/query?q=Q" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### 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`/query`

### Execute InfluxQL query (v1-compatible)

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

#### Related

* [Use the InfluxDB v1 HTTP query API and InfluxQL to query data](/influxdb3/enterprise/query-data/execute-queries/influxdb-v1-api/)

#### Parameters

##### Header parameters

`Accept`string

The content type that the client can understand.

If `text/csv` is specified, the `Content-type` response header is `application/csv` and the response is formatted as CSV.

Returns an error if the format is invalid or non-UTF8.

Allowed values:`application/json`, `application/csv`, `text/csv`

Default:`application/json`

#### Request body

Content-Type:`application/json`

`chunk_size`integer

The number of records that will go into a chunk.
This parameter is only used if `chunked=true`.

Default:`10000`

`chunked`boolean

If true, the response is divided into chunks of size `chunk_size`.

`db`string

The database to query. If not provided, the InfluxQL query string must specify the database.

`epoch`string

A unix timestamp precision.

* `h` for hours
* `m` for minutes
* `s` for seconds
* `ms` for milliseconds
* `u` or `µ` for microseconds
* `ns` for nanoseconds

Formats timestamps as [unix (epoch) timestamps](/influxdb3/enterprise/reference/glossary/#unix-timestamp) with the specified precision
instead of [RFC3339 timestamps](/influxdb3/enterprise/reference/glossary/#rfc3339-timestamp) with nanosecond precision.

Allowed:`ns`, `u`, `µ`, `ms`, `s`, `m`, `h`

`pretty`boolean

If true, the JSON response is formatted in a human-readable format.

`q`requiredstring

The InfluxQL query string.

Example request[Ask AI about this](#)

```sh
curl --request POST \
  "https://localhost:8181/query" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: application/json" \
  --data-raw '{
  "chunk_size": 10000,
  "chunked": false,
  "db": "DB",
  "epoch": "ns",
  "pretty": false,
  "q": "Q"
}'
```

#### 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/enterprise/query-data/)
* [InfluxDB 3 API client libraries](/influxdb3/enterprise/reference/client-libraries/v3/)
