content/shared/influxdb-v2/api-guide/influxdb-1x/_index.md
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.
<a class="btn" href="/influxdb/version/api/v1-compatibility/">View full v1 compatibility API documentation</a>
InfluxDB 1.x compatibility endpoints require all query and write requests to be authenticated with an API token or v1-compatible credentials.
[!Important]
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.
Token authentication requires the following credential:
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).
Authorization: Token INFLUX_API_TOKEN
{{< code-tabs-wrapper >}} {{% code-tabs %}} curl Node.js {{% /code-tabs %}} {{% code-tab-content %}}
<!--pytest.mark.skip-->{{% get-shared-text "api/v1-compat/auth/oss/token-auth.sh" %}}
{{% /code-tab-content %}} {{% code-tab-content %}}
{{% get-shared-text "api/v1-compat/auth/oss/token-auth.js" %}}
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
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):
{{% show-in "v2" %}}
Username and password schemes require the following credentials:
{{% note %}}
If you have set a password for the v1-compatible username, provide the v1-compatible password. If you haven't set a password for the v1-compatible username, provide the InfluxDB authentication token as the password. {{% /note %}}
For more information, see how to create and manage v1-compatible authorizations when manually upgrading from InfluxDB v1 to v2.
{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}
[email protected].){{% /show-in %}}
Use the Authorization header with the Basic scheme to provide username and
password credentials to InfluxDB.
{{% api/v1-compat/basic-auth-syntax %}}
{{% show-in "v2" %}}
Authorization: Basic INFLUX_USERNAME:INFLUX_PASSWORD_OR_TOKEN
{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}
Authorization: Basic [email protected]:INFLUX_API_TOKEN
{{% /show-in %}}
{{% code-placeholders "INFLUX_(USERNAME|PASSWORD_OR_TOKEN|API_TOKEN)|[email protected]" %}}
{{% show-in "v2" %}}
{{< code-tabs-wrapper >}} {{% code-tabs %}} curl Node.js {{% /code-tabs %}} {{% code-tab-content %}}
<!--pytest.mark.skip-->{{% get-shared-text "api/v1-compat/auth/oss/basic-auth.sh" %}}
{{% /code-tab-content %}} {{% code-tab-content %}}
{{% get-shared-text "api/v1-compat/auth/oss/basic-auth.js" %}}
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}
{{< code-tabs-wrapper >}} {{% code-tabs %}} curl Node.js {{% /code-tabs %}} {{% code-tab-content %}}
<!--pytest.mark.skip-->{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.sh" %}}
{{% /code-tab-content %}}
{{% code-tab-content %}}
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.js" %}}
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
Replace the following:
[email protected]{{% /code-placeholder-key %}}: the email address that you signed up withINFLUX_API_TOKEN{{% /code-placeholder-key %}}: your InfluxDB API token{{% /show-in %}}
Use InfluxDB 1.x API parameters to provide credentials through the query string.
{{% note %}}
{{% show-in "v2" %}}
/query/?u=INFLUX_USERNAME&p=INFLUX_PASSWORD_OR_TOKEN
/write/?u=INFLUX_USERNAME&p=INFLUX_PASSWORD_OR_TOKEN
{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}
/query/?u=INFLUX_USERNAME&p=INFLUX_API_TOKEN
/write/?u=INFLUX_USERNAME&p=INFLUX_API_TOKEN
{{% /show-in %}}
{{% show-in "v2" %}} {{< code-tabs-wrapper >}} {{% code-tabs %}} curl Node.js {{% /code-tabs %}} {{% code-tab-content %}}
<!--pytest.mark.skip-->{{< get-shared-text "api/v1-compat/auth/oss/querystring-auth.sh" >}}
{{% /code-tab-content %}} {{% code-tab-content %}}
{{< get-shared-text "api/v1-compat/auth/oss/querystring-auth.js" >}}
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
Replace the following:
INFLUX_USERNAME{{% /code-placeholder-key %}}: InfluxDB 1.x usernameINFLUX_PASSWORD_OR_TOKEN{{% /code-placeholder-key %}}: InfluxDB 1.x password or InfluxDB API token{{% /show-in %}}
{{% show-in "cloud,cloud-serverless" %}}
{{< code-tabs-wrapper >}} {{% code-tabs %}} curl Node.js {{% /code-tabs %}} {{% code-tab-content %}}
<!--pytest.mark.skip-->{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.sh" %}}
{{% /code-tab-content %}}
{{% code-tab-content %}}
{{% get-shared-text "api/v1-compat/auth/cloud/basic-auth.js" %}}
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
{{% /code-placeholders %}}
Replace the following:
[email protected]{{% /code-placeholder-key %}}: the email address that you signed up withINFLUX_API_TOKEN{{% /code-placeholder-key %}}: your InfluxDB API token{{% /show-in %}}
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:
# 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:
# 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 or a 1.x username and password scheme.
The compatibility API supports InfluxQL, with the following caveats:
INTO clause (for example, SELECT ... INTO ...) is not supported.DELETE and
DROP MEASUREMENT queries, which are still allowed,
InfluxQL database management commands are not supported.{{< children readmore=true >}}