InfluxDB client libraries
InfluxDB client libraries are language-specific packages that integrate with the InfluxDB 2.0 API and support both InfluxDB 1.8+ and InfluxDB 2.0.
Note: We recommend using the new client libraries on this page to leverage the new read (via Flux) and write APIs and prepare for conversion to InfluxDB 2.0 and InfluxDB Cloud. For more information, see InfluxDB 2.0 API compatibility endpoints. Client libraries for InfluxDB 1.7 and earlier may continue to work, but are not maintained by InfluxData.
Client libraries
Functionality varies between client libraries. Refer to client libraries on GitHub for specifics regarding each client library.
Arduino
- InfluxDB Arduino Client
- Contributed by Tobias Schürg (tobiasschuerg)
C
- influxdb-client-csharp
- Maintained by InfluxData
Go
- influxdb-client-go
- Maintained by InfluxData
Java
- influxdb-client-java
- Maintained by InfluxData
JavaScript
- influxdb-javascript
- Maintained by InfluxData
PHP
- influxdb-client-php
- Maintained by InfluxData
Python
- influxdb-client-python
- Maintained by InfluxData
Ruby
- influxdb-client-ruby
- Maintained by InfluxData
Install and use a client library
To install and use the Python client library, follow the instructions below. To install and use other client libraries, refer to the client library documentation for detail.
Install and use the Python client library
Install the Python client library.
pip install influxdb-client
Ensure that InfluxDB is running. If running InfluxDB locally, visit http://localhost:8086. (If using InfluxDB Cloud, visit the URL of your InfluxDB Cloud UI.)
In your program, import the client library and use it to write data to InfluxDB. For example:
import influxdb_client
from influxdb_client.client.write_api import SYNCHRONOUS
Define your database and token variables, and create a client and writer object. The InfluxDBClient object takes 2 parameters:
url
andtoken
database = "<my-db>"
token = "<my-token>"
client = influxdb_client.InfluxDBClient(
url="http://localhost:8086",
token=token,
Note: The database (and retention policy, if applicable) are converted to a bucket data store compatible with InfluxDB 2.0.
Instantiate a writer object using the client object and the write_api method. Use the
write_api
method to configure the writer object.client = influxdb_client.InfluxDBClient(url=url, token=token)
write_api = client.write_api(write_options=SYNCHRONOUS)
Create a point object and write it to InfluxDB using the write method of the API writer object. The write method requires three parameters: database, (optional) retention policy, and record.
p = influxdb_client.Point("my_measurement").tag("location", "Prague").field("temperature", 25.3)
write_api.write(database:rp, record=p)