---
title: Query data (v1-compatible)
description: Query data in InfluxDB OSS v2 using InfluxQL via the v1-compatible /query endpoint.
url: https://docs.influxdata.com/influxdb/v2/api/query-data-v1-compatible/
estimated_tokens: 6990
product: InfluxDB OSS v2
version: v2
---

[Download InfluxDB API Spec](/openapi/influxdb-oss-v2-api.yml)

Query data in InfluxDB OSS v2 using InfluxQL via the v1-compatible `/query` endpoint.

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.

#### Parameters

##### Query parameters

`u` string

The InfluxDB 1.x username to authenticate the request. If you provide an API token as the password, `u` is required, but can be any value.

`p` string

The InfluxDB 1.x password to authenticate the request.

`db` required string

The database to query data from. This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket). For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/).

`rp` string

The retention policy to query data from. This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket). For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/).

`epoch` string

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

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

`q` required string

The InfluxQL query to execute. To execute multiple queries, delimit queries with a semicolon (`;`).

##### Header parameters

`Zap-Trace-Span` string

OpenTracing span context

`Accept` string

Allowed values: `application/json` , `application/csv` , `text/csv` , `application/x-msgpack`

Default: `application/json`

`Accept-Encoding` string

The content encoding (usually a compression algorithm) that the client can understand.

Allowed values: `gzip` , `identity`

Default: `identity`

`Content-Type` string

Allowed values: `application/json`

Example request [Ask AI about this](#)

```sh
curl --request GET \
  "http://localhost:8086/query?db=DB&q=Q" \
  --header "Authorization: Bearer INFLUX_TOKEN"
```

#### Responses

200 Query results

`results` object\[\]

A resultset object that contains the `statement_id` and the `series` array.

Except for `statement_id`, all properties are optional and omitted if empty. If a property is not present, it is assumed to be `null`.

`error` string

`partial` boolean

True if the resultset is not complete–the response data is chunked; otherwise, false or omitted.

`series` object\[\]

An array of series objects–the results of the query. A series of rows shares the same group key returned from the execution of a statement.

If a property is not present, it is assumed to be `null`.

`columns` string\[\]

An array of column names

`name` string

The name of the series

`partial` boolean

True if the series is not complete–the response data is chunked; otherwise, false or omitted.

`tags` object

A map of tag key-value pairs. If a tag key is not present, it is assumed to be `null`.

`values` array\[\]

An array of rows, where each row is an array of values.

`statement_id` integer

An integer that represents the statement’s position in the query. If statement results are buffered in memory, `statement_id` is used to combine statement results.

429

#### InfluxDB Cloud:

-   returns this error if a **read** or **write** request exceeds your plan’s [adjustable service quotas](/influxdb/v2/account-management/limits/#adjustable-service-quotas) or if a **delete** request exceeds the maximum [global limit](/influxdb/v2/account-management/limits/#global-limits)
-   returns `Retry-After` header that describes when to try the write again.

#### InfluxDB OSS v2:

-   doesn’t return this error.

default Error processing query

`code` required string

code is the machine-readable error code.

Allowed: `internal error` , `not implemented` , `not found` , `conflict` , `invalid` , `unprocessable entity` , `empty value` , `unavailable` , `forbidden` , `too many requests` , `unauthorized` , `method not allowed` , `request too large` , `unsupported media type`

`err` string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message` string

Human-readable message.

`op` string

Describes the logical code operation when the error occurred. Useful for debugging.

POST `/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.

#### Parameters

##### Query parameters

`u` string

The InfluxDB 1.x username to authenticate the request. If you provide an API token as the password, `u` is required, but can be any value.

`p` string

The InfluxDB 1.x password to authenticate the request.

`db` required string

The database to query data from. This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket). For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/).

`rp` string

The retention policy to query data from. This is mapped to an InfluxDB [bucket](/influxdb/v2/reference/glossary/#bucket). For more information, see [Database and retention policy mapping](/influxdb/v2/api/influxdb-1x/dbrp/).

`epoch` string

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

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

##### Header parameters

`Zap-Trace-Span` string

OpenTracing span context

`Accept` string

Allowed values: `application/json` , `application/csv` , `text/csv` , `application/x-msgpack`

Default: `application/json`

`Accept-Encoding` string

The content encoding (usually a compression algorithm) that the client can understand.

Allowed values: `gzip` , `identity`

Default: `identity`

`Content-Type` string

Allowed values: `application/json`

#### Request body

InfluxQL query to execute.

Content-Type: `application/json`

Example request [Ask AI about this](#)

```sh
curl --request POST \
  "http://localhost:8086/query?db=DB" \
  --header "Authorization: Bearer INFLUX_TOKEN" \
  --header "Content-Type: text/plain" \
  --data-raw 'measurement,tag=value field=1.0'
```

#### Responses

200 Query results

`results` object\[\]

A resultset object that contains the `statement_id` and the `series` array.

Except for `statement_id`, all properties are optional and omitted if empty. If a property is not present, it is assumed to be `null`.

`error` string

`partial` boolean

True if the resultset is not complete–the response data is chunked; otherwise, false or omitted.

`series` object\[\]

An array of series objects–the results of the query. A series of rows shares the same group key returned from the execution of a statement.

If a property is not present, it is assumed to be `null`.

`columns` string\[\]

An array of column names

`name` string

The name of the series

`partial` boolean

True if the series is not complete–the response data is chunked; otherwise, false or omitted.

`tags` object

A map of tag key-value pairs. If a tag key is not present, it is assumed to be `null`.

`values` array\[\]

An array of rows, where each row is an array of values.

`statement_id` integer

An integer that represents the statement’s position in the query. If statement results are buffered in memory, `statement_id` is used to combine statement results.

429 Token is temporarily over quota. The Retry-After header describes when to try the read again.

default Error processing query

`code` required string

code is the machine-readable error code.

Allowed: `internal error` , `not implemented` , `not found` , `conflict` , `invalid` , `unprocessable entity` , `empty value` , `unavailable` , `forbidden` , `too many requests` , `unauthorized` , `method not allowed` , `request too large` , `unsupported media type`

`err` string

Stack of errors that occurred during processing of the request. Useful for debugging.

`message` string

Human-readable message.

`op` string

Describes the logical code operation when the error occurred. Useful for debugging.
