Python and InfluxDB

Get Started

Build IoT, analytics, and cloud applications using the Python client library with InfluxDB.

Why use the InfluxDB Python Client Library?

InfluxDB is an API-first time series database for your Python applications. Use the InfluxDB open-source Python API client to write and query data into your applications and even manage your InfluxDB instance from within your app.

Key features

  • Provides API access to all InfluxDB Write and Read functionality, settings, and advanced features
  • Write data in InfluxDB line protocol, point data structure, or as a pandas dataframe
  • Easily configure timeouts, delays, and request retries
  • Batch data to InfluxDB to gain greater efficiency
  • Return InfluxDB data as a Flux Table Structure, string, csv, stream, or dataframe
  • Panda dataframe integration

Get started

Batching Data with the InfluxDB's Python Client Library

Querying Data with InfluxDB's Python Client Library

Using the InfluxDB Python Client Library Administrative APIs



from influxdb_client import InfluxDBClient

url = ''
token = 'my-token'
org = 'my-org'
bucket = 'my-bucket'

with InfluxDBClient(url=url, token=token, org=org) as client:
    query_api = client.query_api()

    tables = query_api.query('from(bucket: "my-bucket") |> range(start: -1d)')

    for table in tables:
        for record in table.records:
            print(str(record["_time"]) + " - " + record.get_measurement()
                  + " " + record.get_field() + "=" + str(record.get_value()))

For more information, please check out the documentation.

Project URL   Documentation   Python client library starter

Related resources