Documentation

/write 1.x compatibility API

The /write 1.x compatibility endpoint writes data to InfluxDB Cloud and InfluxDB OSS 2.7 using patterns from the InfluxDB 1.x /write API endpoint. Use the POST request method to write line protocol to the /write endpoint.

POST http://localhost:8086/write
  • Copy
  • Fill window

Authentication

Use one of the following authentication methods:

  • token authentication
  • basic authentication with username and password
  • query string authentication with username and password

For more information, see Authentication.

Request body

Include your line protocol in the request body. Binary encode the line protocol to prevent unintended formatting. The examples below use the curl --data-binary flag to binary encode the line protocol.

Query string parameters

u

(Optional) The 1.x username to authenticate the request. See query string authentication.

p

(Optional) The 1.x password to authenticate the request. See query string authentication.

db

(Required) The database to write data to. This is mapped to an InfluxDB bucket. See Database and retention policy mapping.

rp

The retention policy to write data to. This is mapped to an InfluxDB bucket. See Database and retention policy mapping.

precision

The precision of Unix timestamps in the line protocol. Default is nanosconds (ns). The following precisions are available:

  • ns - nanoseconds
  • u or µ - microseconds
  • ms - milliseconds
  • s - seconds
  • m - minutes
  • h - hours

Write examples

Write data using basic authentication
curl --request POST http://localhost:8086/write?db=
DATABASE_NAME
\
--user "
USERNAME
:
PASSWORD_OR_TOKEN
"
\
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
  • Copy
  • Fill window
Write data using token authentication
curl --request POST http://localhost:8086/write?db=
DATABASE_NAME
\
--header "Authorization: Token
API_TOKEN
"
\
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
  • Copy
  • Fill window
Write data to a non-default retention policy
curl --request POST "http://localhost:8086/write?db=
DATABASE_NAME
&rp=RETENTION_POLICY"
\
--header "Authorization: Token
API_TOKEN
"
\
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
  • Copy
  • Fill window
Write multiple lines of line protocol
curl --request POST http://localhost:8086/write?db=
DATABASE_NAME
\
--header "Authorization: Token
API_TOKEN
"
\
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000 measurement,host=host2 field1=14i,field2=12.7 1577836800000000000 measurement,host=host3 field1=5i,field2=6.8 1577836800000000000"
  • Copy
  • Fill window
Write data with millisecond Unix timestamps
curl --request POST "http://localhost:8086/write?db=
DATABASE_NAME
&precision=ms"
\
--header "Authorization: Token
API_TOKEN
"
\
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000"
  • Copy
  • Fill window
Use curl to write data from a file
curl --request POST http://localhost:8086/write?db=
DATABASE_NAME
\
--header "Authorization: Token
API_TOKEN
"
\
--data-binary @path/to/line-protocol.txt
  • Copy
  • Fill window

Replace the following:


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: