Documentation

InfluxDB client libraries

This page documents an earlier version of InfluxDB OSS. InfluxDB OSS v2 is the latest stable version. See the equivalent InfluxDB v2 documentation: Use InfluxDB client libraries.

InfluxDB v2 client libraries are language-specific packages that integrate with the InfluxDB v2 API and support both InfluxDB 1.8+ and InfluxDB 2.x.

If you’re getting started with InfluxDB v1, we recommend using the InfluxDB v1 client libraries and InfluxQL for InfluxDB v3 compatibility.

For more information about API and client library compatibility, see the InfluxDB v1 API reference.

Client libraries

Functionality varies between client libraries. Refer to client libraries on GitHub for specifics regarding each client library.

Arduino

C#

C++

Go

Java

JavaScript

PHP

Python

Ruby

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

  1. Install the Python client library.

    pip install influxdb-client
    
  2. 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.)

  3. 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
    
  4. Define your database and token variables, and create a client and writer object. The InfluxDBClient object takes 2 parameters: url and token

    database = "<my-db>"
    token = "<my-token>"
    client = influxdb_client.InfluxDBClient(
    url="http://localhost:8086",
    token=token,
    

    The database (and retention policy, if applicable) are converted to a bucket data store compatible with InfluxDB v2.

  5. 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)
    
  6. 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)
    

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 v3 enhancements and InfluxDB Clustered is now generally available

New capabilities, including faster query performance and management tooling advance the InfluxDB v3 product line. InfluxDB Clustered is now generally available.

InfluxDB v3 performance and features

The InfluxDB v3 product line has seen significant enhancements in query performance and has made new management tooling available. These enhancements include an operational dashboard to monitor the health of your InfluxDB cluster, single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management APIs for tokens and databases.

Learn about the new v3 enhancements


InfluxDB Clustered general availability

InfluxDB Clustered is now generally available and gives you the power of InfluxDB v3 in your self-managed stack.

Talk to us about InfluxDB Clustered