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. The Token scheme is the word Token, a space, and your token (all case-sensitive).

Syntax

Authorization: Token INFLUX_API_TOKEN
  • Copy
  • Fill window

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"
  • Copy
  • Fill window
/**
  * 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: 'undefined',
    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();
}
  • Copy
  • Fill window

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: InfluxDB Cloud username (Use the email address you signed up with as your username–for example, 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 exampleuser@influxdata.com:INFLUX_API_TOKEN
  • Copy
  • Fill window
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 
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"
  • Copy
  • Fill window
/**
  * 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: 'undefined',
    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(); }
  • Copy
  • Fill window

Replace the following:

  • exampleuser@influxdata.com
    : the email address that you signed up with
  • INFLUX_API_TOKEN
    : your InfluxDB API 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 when exposing sensitive data through URLs.
Syntax
/query/?u=
INFLUX_USERNAME
&p=
INFLUX_API_TOKEN
/write/?u=
INFLUX_USERNAME
&p=
INFLUX_API_TOKEN
  • Copy
  • Fill window
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 
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"
  • Copy
  • Fill window
/**
  * 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: 'undefined',
    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(); }
  • Copy
  • Fill window

Replace the following:

  • exampleuser@influxdata.com
    : the email address that you signed up with
  • INFLUX_API_TOKEN
    : your InfluxDB API token
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 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!


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.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out:

InfluxDB Cloud powered by TSM