How influxdata/influxdb-client-python works
Purpose and Public Entry Points
This is the Python client library for InfluxDB 2.x and Flux, with InfluxDB 1.8 forward-compatible endpoints. Applications import synchronous InfluxDBClient and data-building types from influxdb_client/__init__.py; the principal client façade is influxdb_client/client/influxdb_client.py. Async applications use influxdb_client/client/influxdb_client_async.py.
Client Construction and Transport Boundary
Client instances hold endpoint, organization, authentication, TLS/mTLS, proxy, gzip, timeout, pooling, and retry configuration. Configuration can be built from arguments, files, or environment through influxdb_client/configuration.py. Synchronous HTTP uses generated-client plumbing in influxdb_client/_sync/api_client.py and influxdb_client/_sync/rest.py; asynchronous transport uses aiohttp-oriented counterparts in influxdb_client/_async/api_client.py and influxdb_client/_async/rest.py. The external boundary is an InfluxDB HTTP API (local, Cloud, or 1.8-compatible server).
API Facades and Generated Management Layer
InfluxDBClient exposes focused facades for writes, Flux queries, deletes, health/ping, and resource management. High-level wrappers include influxdb_client/client/query_api.py, influxdb_client/client/delete_api.py, and management APIs such as influxdb_client/client/bucket_api.py. These call generated endpoint services under influxdb_client/service/, for example influxdb_client/service/buckets_service.py and influxdb_client/service/write_service.py. Request/response schemas are generated domain models in influxdb_client/domain/, e.g. influxdb_client/domain/bucket.py and influxdb_client/domain/query.py.
Write Pipeline
Writes accept line protocol, Point, mappings, dataclasses, named tuples, Pandas DataFrames, lists, and—in batching mode—RxPY observables. influxdb_client/client/write_api.py normalizes records, applies default tags, serializes them to line protocol, batches by destination/precision, and sends write requests. influxdb_client/client/write/point.py is the fluent point model and line-protocol serializer; influxdb_client/client/write/dataframe_serializer.py is the Pandas conversion boundary. Default mode is background batching via RxPY; synchronous mode performs the HTTP request inline. Retry/backoff policy for failed batches is defined in influxdb_client/client/write/retry.py; background failures are reported through callbacks rather than caller exceptions.
Query Pipeline
influxdb_client/client/query_api.py submits Flux queries, optionally parameterized and profiler-enabled, to the query service. It exposes raw text/CSV, iterable records, FluxTable collections, streaming records, and Pandas DataFrames. influxdb_client/client/flux_csv_parser.py parses annotated Flux CSV and materializes table/record structures from influxdb_client/client/flux_table.py; profiler measurements are treated separately from normal results. Streaming permits early consumer termination and explicit closure.
Async Execution Model
The async façade mirrors core query, write, delete, health, and generated management capabilities: influxdb_client/client/influxdb_client_async.py, influxdb_client/client/query_api_async.py, and influxdb_client/client/write_api_async.py. It requires execution inside an asyncio coroutine/event loop and uses aiohttp/aiocsv dependencies. Async writes are awaitable request operations; query APIs support async generators for records and DataFrames.
Operational Boundaries
Authentication supports token, username/password session, and reverse-proxy HTTP Basic patterns. The client supports TLS verification/custom CAs/mTLS, proxy headers, configurable redirects, and optional gzip. Public errors are centralized in influxdb_client/client/exceptions.py; non-batched request failures propagate to the application. Documentation and package APIs are maintained alongside generated source conventions, with source regeneration supported by scripts/generate-sources.sh.
Main entry points: write_service.py Endpoint services · influxdb_client.py InfluxDBClient · write_api.py Write API · influxdb_client_async.py InfluxDBClientAsync
Components 21
Synchronous client
- InfluxDBClient
influxdb_client/client/influxdb_client.py - Write API · Normalizes records, applies tags, batches, and dispatches writes.
influxdb_client/client/write_api.py - Point serializer
influxdb_client/client/write/point.py - DataFrame converter
influxdb_client/client/write/dataframe_serializer.py - Batch retry policy · Reports background batch failures through callbacks.
influxdb_client/client/write/retry.py - Query API
influxdb_client/client/query_api.py - Flux CSV parser · Materializes tables and records and separates profiler output.
influxdb_client/client/flux_csv_parser.py - Flux tables and records
influxdb_client/client/flux_table.py - Delete API
influxdb_client/client/delete_api.py - Management APIs · Buckets and other server resources.
influxdb_client/client/bucket_api.py - Sync HTTP transport
influxdb_client/_sync/api_client.py
Async client
- InfluxDBClientAsync · Requires an asyncio event loop.
influxdb_client/client/influxdb_client_async.py - Async Query API · Provides awaitable and async-generator query results.
influxdb_client/client/query_api_async.py - Async Write API · Dispatches awaitable write requests.
influxdb_client/client/write_api_async.py - Async HTTP transport
influxdb_client/_async/api_client.py
Generated API layer
- Endpoint services · Generated request endpoints for writes, queries, and resources.
influxdb_client/service/write_service.py - Domain models · Generated request and response types.
influxdb_client/domain/bucket.py
Other components
- Public package API
influxdb_client/__init__.py - Client configuration · Builds connection and operational settings from arguments, files, or environment.
influxdb_client/configuration.py - Public exceptions
influxdb_client/client/exceptions.py - InfluxDB HTTP API · InfluxDB 2.x, Cloud, or 1.8-compatible endpoint.
Connections 28
- Public package API → InfluxDBClient: exports
- Public package API → InfluxDBClientAsync: exports
- Client configuration → InfluxDBClient: configures
- Client configuration → InfluxDBClientAsync: configures
- InfluxDBClient → Write API: creates
- InfluxDBClient → Query API: creates
- InfluxDBClient → Delete API: creates
- InfluxDBClient → Management APIs: creates
- Write API → Point serializer: serializes
- Write API → DataFrame converter: converts DataFrames
- Write API → Batch retry policy: retries batches
- Write API → Endpoint services: writes through
- Query API → Endpoint services: submits Flux
- Query API → Flux CSV parser: parses CSV
- Flux CSV parser → Flux tables and records: materializes
- Delete API → Endpoint services: calls
- Management APIs → Endpoint services: calls
- Endpoint services → Domain models: uses schemas
- Endpoint services → Sync HTTP transport: uses
- Sync HTTP transport → InfluxDB HTTP API: HTTP
- InfluxDBClientAsync → Async Query API: creates
- InfluxDBClientAsync → Async Write API: creates
- Async Query API → Endpoint services: submits Flux
- Async Write API → Endpoint services: writes through
- Endpoint services → Async HTTP transport: uses asynchronously
- Async HTTP transport → InfluxDB HTTP API: HTTP
- InfluxDBClient → Public exceptions: raises
- InfluxDBClientAsync → Public exceptions: raises