Documentation

InfluxDB 1.x compatibility API

The InfluxDB v2 API includes InfluxDB 1.x compatibility /write and /query 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 Cloud requires all query and write requests to be authenticated using InfluxDB API tokens.

Use InfluxDB API tokens with the following authentication schemes:

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 <token>
Example
#######################################
# Use a token in the Authorization header
# to query the InfluxDB 1.x compatibility API
#######################################

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

/**
  * Use a token in the Authorization header
  * to query the InfluxDB 1.x compatibility API
  */

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 YourAuthToken',
      '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 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: InfluxDB Cloud username (Use the email address you signed up with as your username, e.g. exampleuser@influxdata.com.)
  • password: InfluxDB Cloud API token

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 <username>:<password>
Example
#######################################
# 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 <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 "OneDotXUsername":"yourPasswordOrToken" \
  --data-urlencode "db=mydb" \
  --data-urlencode "q=SELECT * FROM cpu_usage"

/**
  * 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:YourAuthToken',
    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 username and password 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=<username>&p=<password>
 /write/?u=<username>&p=<password>
Example
#######################################
# Use an InfluxDB 1.x compatible username and password
# to query the InfluxDB 1.x compatibility API
#######################################
# Use authentication query parameters:
#   ?u=<username>&p=<password>
# Use default retention policy.
#######################################

curl --get "http://localhost:8086/query" \
  --data-urlencode "u=OneDotXUsername" \
  --data-urlencode "p=yourPasswordOrToken" \
  --data-urlencode "db=mydb" \
  --data-urlencode "q=SELECT * FROM cpu_usage"

/**
  * Use an InfluxDB 1.x compatible username and password
  * to query the InfluxDB 1.x compatibility API
  *
  * Use authentication query parameters:
  *   ?u=<username>&p=<password>
  *
  * Use default retention policy.
  */

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

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

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

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


Select your region

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.