Install & Compatibility
Where this runs
tested against v1.45.0.20241221 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.774s · 80.6MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.1s · import 0.668s · 21MB
50MB installed
● package 50MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
InfluxDBClient
✓ from influxdb_client_stubs import InfluxDBClient
✗ from influxdb_client_stubs import InfluxDBClient
This quickstart demonstrates basic InfluxDB client usage with type hints. It connects to an InfluxDB instance, writes a data point using a `Point` object, and then queries the data, showcasing how the type stubs aid in correct API usage and provide autocompletion and static checks.
import os
from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS
# Configuration (use environment variables or replace with actual values)
INFLUXDB_URL = os.environ.get('INFLUXDB_URL', 'http://localhost:8086')
INFLUXDB_TOKEN = os.environ.get('INFLUXDB_TOKEN', 'my-super-secret-token')
INFLUXDB_ORG = os.environ.get('INFLUXDB_ORG', 'my-org')
INFLUXDB_BUCKET = os.environ.get('INFLUXDB_BUCKET', 'my-bucket')
def write_and_query_data() -> None:
try:
with InfluxDBClient(url=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG) as client:
write_api = client.write_api(write_options=SYNCHRONOUS)
p = Point("my_measurement").tag("location", "Prague").field("temperature", 25.3)
write_api.write(bucket=INFLUXDB_BUCKET, record=p)
print(f"Successfully wrote point: {p.to_line_protocol()}")
query_api = client.query_api()
tables = query_api.query(f'from(bucket:"{INFLUXDB_BUCKET}") |> range(start: -1h)')
print("\nQuery Results:")
for table in tables:
for record in table.records:
print(f" {record.get_measurement()}: {record.get_field()}={record.get_value()} @ {record.get_time()}")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
write_and_query_data()
Debug
Known issues
breakingThe `influxdb-client` library (runtime package) includes its own type annotations from version `1.46.0` onwards. If you are using `influxdb-client>=1.46.0`, you MUST uninstall `types-influxdb-client` to avoid duplicate type definitions and potential type-checking errors.fixIf `influxdb-client>=1.46.0` is installed, uninstall this stub package: `pip uninstall types-influxdb-client`.
affects: types-influxdb-client (all versions) used with influxdb-client>=1.46.0
gotchaThis specific version of `types-influxdb-client` (`1.45.0.20241221`) is intended to provide accurate annotations for `influxdb-client==1.45.*`. Using it with significantly different versions of `influxdb-client` (e.g., `1.30.x` or `1.49.x`) may lead to incorrect type-checking results due to API mismatches.fixAlways align the `types-influxdb-client` version with the `influxdb-client` version you are using. The stub package's version number (excluding the last part) usually indicates the target `influxdb-client` version (e.g., `1.45.0.x` for `influxdb-client==1.45.*`).
affects: All versions of types-influxdb-client when runtime library version is mismatched.
gotchaThis package, `types-influxdb-client`, requires `urllib3>=2` since its version `1.37.0.1`. If your project environment necessitates `urllib3<2`, you will encounter dependency conflicts or runtime issues.fixEnsure `urllib3>=2` is installed. If `urllib3<2` is strictly required, you must downgrade `types-influxdb-client` to a version `<1.37.0.1` (e.g., `pip install 'types-influxdb-client<1.37.0.1'`).
affects: types-influxdb-client>=1.37.0.1 with urllib3<2
Upgrade
Version history
1.45.0.20241221latest on PyPI · released Dec 21, 2024
Audit
Dependencies
influxdb-clientrequiredThis package provides type stubs for the `influxdb-client` library itself; it is a peer dependency.
urllib3requiredRequires `urllib3>=2` since `types-influxdb-client` v1.37.0.1. Older `urllib3<2` requires `types-influxdb-client<1.37.0.1`.