Documentation

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 and others.

View full v1 compatibility API documentation

Authentication

InfluxDB 1.x compatibility endpoints require all query and write requests to be authenticated with an API token or 1.x-compatible credentials.

Authenticate with the Token scheme

Token authentication requires the following credential:

Use the Authorization header with the Token scheme to provide your token to InfluxDB.

Syntax

Authorization: Token INFLUX_API_TOKEN

Example

#######################################
# 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"
/**
  * 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();
}

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):

Manage credentials

Username and password schemes require the following credentials:

  • username: 1.x username (this is separate from the UI login username)
  • password: 1.x password or InfluxDB API token.

Password or Token

If you have set a password for the 1.x-compatible username, provide the 1.x-compatible password. If you haven’t set a password for the 1.x-compatible username, provide the InfluxDB authentication token as the password.

For information about creating and managing 1.x-compatible authorizations, see:

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
Authorization: Basic INFLUX_USERNAME:INFLUX_PASSWORD_OR_TOKEN
Example
#######################################
# Use Basic authentication with an
# InfluxDB 1.x compatible username and password
# to query the InfluxDB 1.x compatibility API.
#
# Replace INFLUX_USERNAME with your 1.x-compatible username.
# Replace INFLUX_PASSWORD_OR_TOKEN with your InfluxDB API token
# or 1.x-compatible password.
#######################################
# Use the default retention policy.
#######################################
# Use the --user option with `--user <username>:<password>` syntax
# or the `--user <username>` interactive syntax to ensure your credentials are
# encoded in the header.
#######################################

curl --get "http://localhost:8086/query" \
  --user "INFLUX_USERNAME":"INFLUX_PASSWORD_OR_TOKEN" \
  --data-urlencode "db=mydb" \
  --data-urlencode "q=SELECT * FROM cpu_usage"
/**
  * Use Basic authentication with an
  * InfluxDB 1.x compatible username and password
  * to query the InfluxDB 1.x compatibility API.

  * Replace INFLUX_USERNAME with your 1.x-compatible username.
  * Replace INFLUX_PASSWORD_OR_TOKEN with your InfluxDB API token
  * or 1.x-compatible password.
  * Use the default retention policy.
  */

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: 'INFLUX_USERNAME:INFLUX_PASSWORD_OR_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();
}

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 when exposing sensitive data through URLs.
Syntax
 /query/?u=INFLUX_USERNAME&p=INFLUX_PASSWORD_OR_TOKEN
 /write/?u=INFLUX_USERNAME&p=INFLUX_PASSWORD_OR_TOKEN
Example
#######################################
# Use querystring authentication with an
# InfluxDB 1.x compatible username and password
# to query the InfluxDB 1.x compatibility API.
#
# Replace INFLUX_USERNAME with your 1.x-compatible username.
# Replace INFLUX_PASSWORD_OR_TOKEN with your InfluxDB API token
# or 1.x-compatible password.
#
# Use the default retention policy.
#######################################

curl --get "http://localhost:8086/query" \
  --data-urlencode "u=INFLUX_USERNAME" \
  --data-urlencode "p=INFLUX_PASSWORD_OR_TOKEN" \
  --data-urlencode "db=mydb" \
  --data-urlencode "q=SELECT * FROM cpu_usage"
/**
  * Use querystring authentication with an
  * InfluxDB 1.x compatible username and password
  * to query the InfluxDB 1.x compatibility API.
  *
  * Replace INFLUX_USERNAME with your 1.x-compatible username.
  * Replace INFLUX_PASSWORD_OR_TOKEN with your InfluxDB API token
  * or 1.x-compatible password.
  *
  * Use the default retention policy.
  */

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

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

  const options = {
    host: 'localhost:8086',
    path: "/query?" + querystring.stringify(queryparams)
  };

  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();
}

Replace the following:

InfluxQL support

The compatibility API supports InfluxQL, with the following caveats:

  • The INTO clause (e.g. SELECT ... INTO ...) is not supported.
  • With the exception of DELETE and DROP MEASUREMENT queries, which are still allowed, InfluxQL database management commands are not supported.

Compatibility endpoints


Was this page helpful?

Thank you for your feedback!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: