InfluxDB Cloud Dedicated Docs Submit API issue

InfluxDB Cloud Dedicated API Service (InfluxDB v3.0)

License: MIT

The InfluxDB HTTP API provides a programmatic interface for interacting with InfluxDB.

Quick start

See the Get Started tutorial to get up and running authenticating with tokens, writing to databases, and querying data.

InfluxDB API client libraries and Flight clients are available to integrate InfluxDB APIs with your application.

API compatibility

Write data

InfluxDB Cloud Dedicated provides the following HTTP API endpoints for writing data:

  • Recommended: /api/v2/write endpoint for new write workloads or for bringing existing InfluxDB v2 write workloads to v3.
  • /write endpoint for bringing existing InfluxDB v1 write workloads to v3.

Both endpoints accept the same line protocol format and process data in the same way.

Query data

InfluxDB Cloud Dedicated provides the following protocols for executing a query:

InfluxDB v2 compatibility

The HTTP API /api/v2/write endpoint works with the Bearer and Token authentication schemes and existing InfluxDB 2.x tools and code for writing data.

See how to use the InfluxDB v2 API with InfluxDB Cloud Dedicated.

InfluxDB v1 compatibility

The HTTP API /write endpoint and /query endpoint work with InfluxDB 1.x username/password authentication schemes and existing InfluxDB 1.x tools and code.

See how to use the InfluxDB v1 API with InfluxDB Cloud Dedicated.

Authentication

Use one of the following schemes to authenticate to the InfluxDB API:

BasicAuthentication

Basic authentication scheme

Use the Authorization header with the Basic scheme to authenticate v1 API /write and /query requests. When authenticating requests, InfluxDB Cloud Dedicated checks that the password part of the decoded credential is an authorized database token. InfluxDB Cloud Dedicated ignores the username part of the decoded credential.

Syntax

Authorization: Basic <base64-encoded [USERNAME]:DATABASE_TOKEN>

Replace the following:

  • [USERNAME]: an optional string value (ignored by InfluxDB Cloud Dedicated).
  • DATABASE_TOKEN: a database token.
  • Encode the [USERNAME]:DATABASE_TOKEN credential using base64 encoding, and then append the encoded string to the Authorization: Basic header.

Example

The following example shows how to use cURL with the Basic authentication scheme and a database token:

#######################################
# Use Basic authentication with a database token
# to query the InfluxDB v1 API
#######################################
# Use the --user option with `--user username:DATABASE_TOKEN` syntax
#######################################

curl --get "http://cluster-id.influxdb.io/query" \
  --user "":"DATABASE_TOKEN" \
  --data-urlencode "db=DATABASE_NAME" \
  --data-urlencode "q=SELECT * FROM MEASUREMENT"

Replace the following:

  • DATABASE_NAME: your InfluxDB Cloud Dedicated database
  • DATABASE_TOKEN: a database token with sufficient permissions to the database
Security Scheme Type HTTP
HTTP Authorization Scheme basic

QuerystringAuthentication

Use the Querystring authentication scheme with InfluxDB 1.x API parameters to provide credentials through the query string.

Query string authentication

In the URL, pass the p query parameter to authenticate /write and /query requests. When authenticating requests, InfluxDB Cloud Dedicated checks that p (password) is an authorized database token and ignores the u (username) parameter.

Syntax

https://cluster-id.influxdb.io/query/?[u=any]&p=DATABASE_TOKEN
https://cluster-id.influxdb.io/write/?[u=any]&p=DATABASE_TOKEN

Example

The following example shows how to use cURL with query string authentication and a database token.

#######################################
# Use an InfluxDB 1.x compatible username and password
# to query the InfluxDB v1 API
#######################################
# Use authentication query parameters:
#   ?p=DATABASE_TOKEN
#######################################

curl --get "https://cluster-id.influxdb.io/query" \
  --data-urlencode "p=DATABASE_TOKEN" \
  --data-urlencode "db=DATABASE_NAME" \
  --data-urlencode "q=SELECT * FROM MEASUREMENT"

Replace the following:

  • DATABASE_NAME: your InfluxDB Cloud Dedicated database
  • DATABASE_TOKEN: a database token with sufficient permissions to the database
Security Scheme Type API Key
Query parameter name: u=&p=

BearerAuthentication

Use the OAuth Bearer authentication scheme to authenticate to the InfluxDB API.

In your API requests, send an Authorization header. For the header value, provide the word Bearer followed by a space and a database token.

Syntax

Authorization: Bearer INFLUX_TOKEN

Example

########################################################
# Use the Bearer token authentication scheme with /api/v2/write
# to write data.
########################################################

curl --post "https://cluster-id.influxdb.io/api/v2/write?bucket=DATABASE_NAME&precision=s" \
  --header "Authorization: Bearer DATABASE_TOKEN" \
  --data-binary 'home,room=kitchen temp=72 1463683075'

For examples and more information, see the following:

Security Scheme Type HTTP
HTTP Authorization Scheme bearer
Bearer format "JWT"

TokenAuthentication

Use the Token authentication scheme to authenticate to the InfluxDB API.

In your API requests, send an Authorization header. For the header value, provide the word Token followed by a space and a database token. The word Token is case-sensitive.

Syntax

Authorization: Token INFLUX_API_TOKEN

Example

########################################################
# Use the Token authentication scheme with /api/v2/write
# to write data.
########################################################

curl --post "https://cluster-id.influxdb.io/api/v2/write?bucket=DATABASE_NAME&precision=s" \
  --header "Authorization: Token DATABASE_TOKEN" \
  --data-binary 'home,room=kitchen temp=72 1463683075'
Security Scheme Type API Key
Header parameter name: Authorization

Headers

InfluxDB HTTP API endpoints use standard HTTP request and response headers. The following table shows common headers used by many InfluxDB API endpoints. Some endpoints may use other headers that perform functions more specific to those endpoints--for example, the POST /api/v2/write endpoint accepts the Content-Encoding header to indicate the compression applied to line protocol in the request body.

Header Value type Description
Accept string The content type that the client can understand.
Authorization string The authorization scheme and credential.
Content-Length integer The size of the entity-body, in bytes, sent to the database.
Content-Type string The format of the data in the request body.

Response codes

InfluxDB HTTP API endpoints use standard HTTP status codes for success and failure responses. The response body may include additional details. For details about a specific operation's response, see Responses and Response Samples for that operation.

API operations may return the following HTTP status codes:

 Code  Status Description
200 Success
204 Success. No content InfluxDB doesn't return data for the request. For example, a successful write request returns 204 status code, acknowledging that data is written and queryable.
400 Bad request InfluxDB can't parse the request due to an incorrect parameter or bad syntax. If line protocol in the request body is malformed. The response body contains the first malformed line and indicates what was expected. For partial writes, the number of points written and the number of points rejected are also included.
401 Unauthorized May indicate one of the following:
  • Authorization: Token header is missing or malformed
  • API token value is missing from the header
  • API token doesn't have permission. For more information about token types and permissions, see Manage tokens
404 Not found Requested resource was not found. message in the response body provides details about the requested resource.
405 Method not allowed The API path doesn't support the HTTP method used in the request--for example, you send a POST request to an endpoint that only allows GET.
413 Request entity too large Request payload exceeds the size limit.
422 Unprocessable entity Request data is invalid. code and message in the response body provide details about the problem.
429 Too many requests API token is temporarily over the request quota. The Retry-After header describes when to try the request again.
500 Internal server error
503 Service unavailable Server is temporarily unavailable to process the request. The Retry-After header describes when to try the request again.

System information endpoints

Ping

Get the status of the instance

Retrieves the status and InfluxDB version of the instance.

Use this endpoint to monitor uptime for the InfluxDB instance. The response returns a HTTP 204 status code to inform you the instance is available.

This endpoint doesn't require authentication.

Authorizations:
None

Responses

Get the status of the instance

Returns the status and InfluxDB version of the instance.

Use this endpoint to monitor uptime for the InfluxDB instance. The response returns a HTTP 204 status code to inform you the instance is available.

This endpoint doesn't require authentication.

Authorizations:
None

Responses

Query

Query data stored in a database.

  • HTTP clients can query the v1 /query endpoint using InfluxQL and retrieve data in CSV or JSON format.
  • The /api/v2/query endpoint can't query InfluxDB Cloud Dedicated.
  • Flight + gRPC clients can query using SQL or InfluxQL and retrieve data in Arrow format.

Query using the InfluxDB v1 API

Queries InfluxDB using InfluxQL with InfluxDB v1 request and response formats.

query Parameters
db
required
string

The database to query data from.

epoch
string
Enum: "ns" "u" "µ" "ms" "s" "m" "h"

A unix timestamp precision. Formats timestamps as unix (epoch) timestamps the specified precision instead of RFC3339 timestamps with nanosecond precision.

p
string

The InfluxDB 1.x password to authenticate the request.

q
required
string

The InfluxQL query to execute. To execute multiple queries, delimit queries with a semicolon (;).

rp
string

The retention policy to query data from. For more information, see InfluxQL DBRP naming convention.

u
string

The InfluxDB 1.x username to authenticate the request.

header Parameters
Accept
string
Default: application/json
Enum: "application/json" "application/csv" "text/csv" "application/x-msgpack"

Media type that the client can understand.

Note: With application/csv, query results include unix timestamps instead of RFC3339 timestamps.

Accept-Encoding
string
Default: identity
Enum: "gzip" "identity"

The content encoding (usually a compression algorithm) that the client can understand.

Content-Type
string
Value: "application/json"
Zap-Trace-Span
string
Example: baggage,[object Object],span_id,1,trace_id,1

OpenTracing span context

Responses

Response samples

Content type
No sample

Write

Write time series data to databases using InfluxDB v1 or v2 endpoints.

Write data

Writes data to a database.

Use this endpoint to send data in line protocol format to InfluxDB.

InfluxDB does the following when you send a write request:

  1. Validates the request
  2. If successful, attempts to ingest the data; error otherwise.
  3. If successful, responds with success (HTTP 204 status code), acknowledging that the data is written and queryable; error otherwise.

To ensure that InfluxDB Cloud handles writes in the order you request them, wait for a success response (HTTP 2xx status code) before you send the next request.

query Parameters
bucket
required
string

A database name or ID. InfluxDB writes all points in the batch to the specified database.

org
required
string

Ignored. An organization name or ID.

InfluxDB ignores this parameter; authorizes the request using the specified database token and writes data to the specified cluster database.

orgID
string

Ignored. An organization ID.

InfluxDB ignores this parameter; authorizes the request using the specified database token and writes data to the specified cluster database.

precision
string (WritePrecision)
Enum: "ms" "s" "us" "ns"

The precision for unix timestamps in the line protocol batch.

header Parameters
Accept
string
Default: application/json
Value: "application/json"

The content type that the client can understand. Writes only return a response body if they fail--for example, due to a formatting problem or quota limit.

InfluxDB Cloud

  • Returns only application/json for format and limit errors.
  • Returns only text/html for some quota limit errors.
Content-Encoding
string
Default: identity
Enum: "gzip" "identity"

The compression applied to the line protocol in the request payload. To send a gzip payload, pass Content-Encoding: gzip header.

Content-Length
integer

The size of the entity-body, in bytes, sent to InfluxDB. If the length is greater than the max body configuration option, the server responds with status code 413.

Content-Type
string
Default: text/plain; charset=utf-8
Enum: "text/plain" "text/plain; charset=utf-8"

The format of the data in the request body. To send a line protocol payload, pass Content-Type: text/plain; charset=utf-8.

Zap-Trace-Span
string
Example: baggage,[object Object],span_id,1,trace_id,1

OpenTracing span context

Request Body schema: text/plain

In the request body, provide data in line protocol format.

To send compressed data, do the following:

  1. Use gzip to compress the line protocol data.
  2. In your request, send the compressed data and the Content-Encoding: gzip header.
string <byte>

Responses

Request samples

Content type
text/plain
airSensors,sensor_id=TLM0201 temperature=73.97038159354763,humidity=35.23103248356096,co=0.48445310567793615 1630424257000000000
airSensors,sensor_id=TLM0202 temperature=75.30007505999716,humidity=35.651929918691714,co=0.5141876544505826 1630424257000000000

Response samples

Content type
application/json
{
  • "code": "invalid",
  • "message": "failed to parse line protocol: error writing line 2: Unable to insert iox::column_type::field::integer type into column temp with type iox::column_type::field::string"
}

Write data using the InfluxDB v1 API

Writes data to a database.

Use this InfluxDB v1-compatible endpoint to send data in line protocol format to InfluxDB using v1 API parameters and authorization.

InfluxDB does the following when you send a write request:

  1. Validates the request
  2. If successful, attempts to ingest the data; error otherwise.
  3. If successful, responds with success (HTTP 204 status code), acknowledging that the data is written and queryable; error otherwise.

To ensure that InfluxDB handles writes in the order you request them, wait for a success response (HTTP 2xx status code) before you send the next request.

query Parameters
db
required
string

database to write to. If none exists, InfluxDB creates a database with a default 3-day retention policy.

p
string

The InfluxDB 1.x password to authenticate the request.

precision
string

Write precision.

rp
string

Retention policy name.

u
string

The InfluxDB 1.x username to authenticate the request.

header Parameters
Content-Encoding
string
Default: identity
Enum: "gzip" "identity"

When present, its value indicates to the database that compression is applied to the line protocol body.

Zap-Trace-Span
string
Example: baggage,[object Object],span_id,1,trace_id,1

OpenTracing span context

Request Body schema: text/plain

Line protocol body

string

Responses

Response samples

Content type
application/json
{
  • "code": "internal error",
  • "err": "string",
  • "line": 0,
  • "message": "string",
  • "op": "string"
}