2.1 KiB
| title | weight | description | menu | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Write data with the InfluxDB API | 206 | Use the `/api/v2/write` InfluxDB API endpoint to write data to InfluxDB. |
|
Write data to InfluxDB using an HTTP request to the InfluxDB API /api/v2/write endpoint.
Use the POST request method and include the following in your request:
| Requirement | Include by |
|---|---|
| Organization | Use the org query parameter in your request URL. |
| Bucket | Use the bucket query parameter in your request URL. |
| Timestamp precision | Use the precisionquery parameter in your request URL. Default is ns. |
| API token | Use the Authorization: Token YOUR_API_TOKEN header. |
| Line protocol | Pass as plain text in your request body. |
Send a write request
The URL in the examples depends on the version and location of your InfluxDB {{< current-version >}} instance. Customize URLs in examples
{{< code-tabs-wrapper >}} {{% code-tabs %}} cURL Node.js {{% /code-tabs %}} {{% code-tab-content %}}
{{< get-shared-text "api/v2.0/write/write.sh" >}}
{{% /code-tab-content %}} {{% code-tab-content %}}
{{< get-shared-text "api/v2.0/write/write.mjs" >}}
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
{{% note %}}
Use gzip compression with the InfluxDB API
When using the InfluxDB API /api/v2/write endpoint to write data, compress the data with gzip and set the Content-Encoding
header to gzip.
Compression reduces network bandwidth, but increases server-side load.
{{% get-shared-text "api/v2.0/write/write-compress.sh" %}}
{{% /note %}}
For information about InfluxDB API response codes, see InfluxDB API Write documentation.