---
title: InfluxDB 1.x compatibility API
description: The InfluxDB v2 API includes InfluxDB 1.x compatibility endpoints that work with InfluxDB 1.x client libraries and third-party integrations like Grafana and others.
url: https://docs.influxdata.com/influxdb/cloud/api-guide/influxdb-1x/
estimated_tokens: 10761
product: InfluxDB Cloud (TSM)
version: cloud
---

# InfluxDB 1.x compatibility API

The InfluxDB v2 API includes InfluxDB 1.x compatibility endpoints that work with InfluxDB 1.x client libraries and third-party integrations like [Grafana](https://grafana.com) and others.

[View full v1 compatibility API documentation](/influxdb/cloud/api/v1-compatibility/)

## Authentication

InfluxDB 1.x compatibility endpoints require all query and write requests to be authenticated with an [API token](/influxdb/cloud/admin/tokens/) or v1-compatible credentials.

#### Authenticate with an API token or 1.x-compatible credentials

You can’t use an InfluxDB 2.x username and password to authenticate with the InfluxDB 1.x compatibility API.

-   [Authenticate with the Token scheme](#authenticate-with-the-token-scheme)
-   [Authenticate with a 1.x username and password scheme](#authenticate-with-a-username-and-password-scheme)
-   [Troubleshoot authentication issues](#troubleshoot-authentication-issues)

### Authenticate with the Token scheme

Token authentication requires the following credential:

-   **token**: InfluxDB [API token](/influxdb/cloud/admin/tokens/)

Use the `Authorization` header with the `Token` scheme to provide your token to InfluxDB. The `Token` scheme is the word `Token`, a space, and your token (all case-sensitive).

#### Syntax

```http
Authorization: Token INFLUX_API_TOKEN
```

#### Example

<!-- Tabbed content: Select one of the following options -->

**curl:**

```sh
#######################################
# Use a token in the Authorization header
# to query the InfluxDB 1.x compatibility API.
#
# Replace INFLUX_API_TOKEN with your InfluxDB API token.
#######################################

curl --get "http://localhost:8086" \
  --header "Authorization: Token INFLUX_API_TOKEN" \
  --header 'Content-type: application/json' \
  --data-urlencode "db=mydb" \
  --data-urlencode "q=SELECT * FROM cpu_usage"
```

**Node.js:**

```js
/**
  * Use the Token authentication scheme
  * to query the InfluxDB 1.x compatibility API.
  *
  * Replace INFLUX_API_TOKEN with your InfluxDB API token.
  */

const https = require('https');
const querystring = require('querystring');

function queryWithToken() {
  const queryparams = {
      db: 'mydb',
      q: 'SELECT * FROM cpu_usage',
  };

  const options = {
    host: 'localhost:8086',
    path: "/query?" + querystring.stringify(queryparams),
    headers: {
      'Authorization': 'Token INFLUX_API_TOKEN',
      'Content-type': 'application/json'
    },
  };

  const request = https.get(options, (response) => {
    let rawData = '';
    response.on('data', () => {
      response.on('data', (chunk) => { rawData += chunk; });
    })
    response.on('end', () => {
      console.log(rawData);
    })
  });

  request.end();
}
```

<!-- End tabbed content -->

### Authenticate with a username and password scheme

Use the following authentication schemes with clients that support the InfluxDB 1.x convention of `username` and `password` (that don’t support the `Authorization: Token` scheme):

-   [Basic authentication](#basic-authentication)
-   [Query string authentication](#query-string-authentication)

#### Manage credentials

-   **username**: InfluxDB Cloud username (Use the email address you signed up with as your username–for example, `exampleuser@influxdata.com`.)
-   **password**: InfluxDB Cloud [API token](/influxdb/cloud/admin/tokens/)

#### Basic authentication

Use the `Authorization` header with the `Basic` scheme to provide username and password credentials to InfluxDB.

Most HTTP clients provide a **Basic authentication** option that accepts the `<username>:<password>` syntax and encodes the credentials before sending the request.

##### Syntax

```http
Authorization: Basic exampleuser@influxdata.com:INFLUX_API_TOKEN
```

##### Example

<!-- Tabbed content: Select one of the following options -->

**curl:**

```sh
#######################################
# Use an InfluxDB 1.x compatible username
# and password with Basic Authentication
# to query the InfluxDB 1.x compatibility API
#######################################
# Use default retention policy
#######################################
# Use the --user option with `--user INFLUX_USERNAME:INFLUX_API_TOKEN` syntax
# or the `--user INFLUX_USERNAME` interactive syntax to ensure your credentials are
# encoded in the header.
#######################################

curl --get "http://localhost:8086/query" \
  --user "exampleuser@influxdata.com":"INFLUX_API_TOKEN" \
  --data-urlencode "db=mydb" \
  --data-urlencode "q=SELECT * FROM cpu_usage"
```

**Node.js:**

```js
/**
  * Use an InfluxDB Cloud username and token
  * with Basic Authentication
  * to query the InfluxDB 1.x compatibility API
  */

const https = require('https');
const querystring = require('querystring');

function queryWithUsername() {
  const queryparams = {
      db: 'mydb',
      q: 'SELECT * FROM cpu_usage',
  };

  const options = {
    host: 'localhost:8086',
    path: '/query?' + querystring.stringify(queryparams),
    auth: 'exampleuser@influxdata.com:INFLUX_API_TOKEN',
    headers: {
      'Content-type': 'application/json'
    },
  };

  const request = https.get(options, (response) => {
    let rawData = '';
    response.on('data', () => {
      response.on('data', (chunk) => { rawData += chunk; });
    })
    response.on('end', () => {
      console.log(rawData);
    })
  });

  request.end();
}
```

<!-- End tabbed content -->

Replace the following:

-   `   exampleuser@influxdata.com   `: the email address that you signed up with
-   `   INFLUX_API_TOKEN   `: your [InfluxDB API token](/influxdb/cloud/reference/glossary/#token)

#### Query string authentication

Use InfluxDB 1.x API parameters to provide credentials through the query string.

##### Consider when using query string parameters

-   URL-encode query parameters that may contain whitespace or other special characters.
-   Be aware of the [risks](https://owasp.org/www-community/vulnerabilities/Information_exposure_through_query_strings_in_url) when exposing sensitive data through URLs.

##### Syntax

```http
/query/?u=INFLUX_USERNAME&p=INFLUX_API_TOKEN
/write/?u=INFLUX_USERNAME&p=INFLUX_API_TOKEN
```

##### Example

<!-- Tabbed content: Select one of the following options -->

**curl:**

```sh
#######################################
# Use an InfluxDB 1.x compatible username
# and password with Basic Authentication
# to query the InfluxDB 1.x compatibility API
#######################################
# Use default retention policy
#######################################
# Use the --user option with `--user INFLUX_USERNAME:INFLUX_API_TOKEN` syntax
# or the `--user INFLUX_USERNAME` interactive syntax to ensure your credentials are
# encoded in the header.
#######################################

curl --get "http://localhost:8086/query" \
  --user "exampleuser@influxdata.com":"INFLUX_API_TOKEN" \
  --data-urlencode "db=mydb" \
  --data-urlencode "q=SELECT * FROM cpu_usage"
```

**Node.js:**

```js
/**
  * Use an InfluxDB Cloud username and token
  * with Basic Authentication
  * to query the InfluxDB 1.x compatibility API
  */

const https = require('https');
const querystring = require('querystring');

function queryWithUsername() {
  const queryparams = {
      db: 'mydb',
      q: 'SELECT * FROM cpu_usage',
  };

  const options = {
    host: 'localhost:8086',
    path: '/query?' + querystring.stringify(queryparams),
    auth: 'exampleuser@influxdata.com:INFLUX_API_TOKEN',
    headers: {
      'Content-type': 'application/json'
    },
  };

  const request = https.get(options, (response) => {
    let rawData = '';
    response.on('data', () => {
      response.on('data', (chunk) => { rawData += chunk; });
    })
    response.on('end', () => {
      console.log(rawData);
    })
  });

  request.end();
}
```

<!-- End tabbed content -->

Replace the following:

-   `   exampleuser@influxdata.com   `: the email address that you signed up with
-   `   INFLUX_API_TOKEN   `: your [InfluxDB API token](/influxdb/cloud/reference/glossary/#token)

### Troubleshoot authentication issues

#### Unauthorized when using the initial username and password

You can’t use the InfluxDB 2.x username and password to authenticate with the InfluxDB 1.x compatibility API. For example, given the following Docker Compose configuration:

```yaml
# Docker compose example
  influx2:
    image: influxdb:2.4.0
    volumes:
      - ./dev/influxdb2:/var/lib/influxdb2
    ports:
      - "8086:8086"
    environment:
      DOCKER_INFLUXDB_INIT_USERNAME: dev
      DOCKER_INFLUXDB_INIT_PASSWORD: 12345678
      DOCKER_INFLUXDB_INIT_ORG: com.some
      DOCKER_INFLUXDB_INIT_BUCKET: m2_dev
      DOCKER_INFLUXDB_INIT_MODE: setup
```

The following query using the v1 `/query` endpoint and v2 initial username and password returns an `unauthorized` error:

```bash
# Using the initial username and password
curl --get "http://localhost:8086/query" \
    --data-urlencode "u=dev" \
    --data-urlencode "p=12345678" \
    --data-urlencode "db=m2_dev" \
    --data-urlencode "q=SELECT * FROM default"
```

Instead, [authenticate with a token](#authenticate-with-the-token-scheme) or a [1.x username and password scheme](#authenticate-with-a-username-and-password-scheme).

## InfluxQL support

The compatibility API supports InfluxQL, with the following caveats:

-   The `INTO` clause (for example, `SELECT ... INTO ...`) is not supported.
-   With the exception of [`DELETE`](/influxdb/v1/query_language/manage-database/#delete-series-with-delete) and [`DROP MEASUREMENT`](/influxdb/v1/query_language/manage-database/#delete-measurements-with-drop-measurement) queries, which are still allowed, InfluxQL database management commands are not supported.

## Compatibility endpoints

### [/query](/influxdb/cloud/api-guide/influxdb-1x/query/)

The `/query` 1.x compatibility endpoint queries InfluxDB Cloud using **InfluxQL**.

GET https://cloud2.influxdata.com/query

[Read more](/influxdb/cloud/api-guide/influxdb-1x/query/)

### [/write](/influxdb/cloud/api-guide/influxdb-1x/write/)

The `/write` 1.x compatibility endpoint writes data to InfluxDB Cloud using patterns from the InfluxDB 1.x `/write` API endpoint.

POST https://cloud2.influxdata.com/write

[Read more](/influxdb/cloud/api-guide/influxdb-1x/write/)

### [Database and retention policy mapping](/influxdb/cloud/api-guide/influxdb-1x/dbrp/)

The database and retention policy (DBRP) mapping service maps InfluxDB 1.x database and retention policy combinations to InfluxDB Cloud buckets.

#### Related

-   [Query data with InfluxQL](/influxdb/cloud/query-data/influxql/)

[influxql](/influxdb/cloud/tags/influxql/) [query](/influxdb/cloud/tags/query/) [write](/influxdb/cloud/tags/write/)
