Background
influxdb3-python still uses a legacy OpenAPI-style HTTP stack for write requests:
WriteApi -> WriteService -> ApiClient -> RESTClientObject -> Configuration
This stack was inherited from the InfluxDB v2 client and is now heavier than needed for the InfluxDB 3 client. Sign-in/sign-out services have already been removed, but write requests still depend on the generated-style ApiClient and WriteService layers.
Goal
Introduce a small internal _RestClient for HTTP-based endpoints and route writes through it directly, while preserving the current public write API behavior.
Scope
- Add an internal
_RestClient
Suggested location:
influxdb_client_3/write_client/_sync/rest_client.py
Responsibilities:
- Build request URLs from base host, endpoint path, and query params.
- Add default headers:
- Send HTTP requests using
urllib3.
- Support existing write HTTP options:
verify_ssl
ssl_ca_cert
cert_file
cert_key_file
cert_key_password
ssl_context
proxy
proxy_headers
connection_pool_maxsize
- request timeout in milliseconds
- gzip via
enable_gzip and gzip_threshold
- Raise the existing
ApiException or compatible error type for non-2xx responses.
- Route write requests through
_RestClient
Refactor WriteApi._post_write(...) so it no longer calls WriteService.post_write(...).
Preserve current endpoint behavior:
use_v2_api=True
- endpoint:
/api/v2/write
- query params:
org, bucket, precision
use_v2_api=False
- endpoint:
/api/v3/write_lp
- query params:
org, db, precision
- optional:
no_sync=true
- optional:
accept_partial=false
Preserve current validation:
use_v2_api=True with no_sync=True raises:
ValueError("invalid write options: no_sync cannot be used with use_v2_api")
Preserve current error translation:
405 on /api/v2/write suggests use_v2_api=False
405 on /api/v3/write_lp suggests use_v2_api=True
- partial write responses are translated to
InfluxDBPartialWriteError
Acceptance criteria
- Write requests work through both
/api/v2/write and /api/v3/write_lp.
accept_partial, no_sync, and use_v2_api keep their current behavior.
- gzip, timeout, proxy, and TLS options still work.
- Runtime write path no longer depends on
WriteService, ApiClient, or RESTClientObject.
- Existing high-level public APIs remain compatible:
InfluxDBClient3
WriteOptions
client.write(...)
client.flush()
client.close()
- Tests that currently cover
WriteService/ApiClient are replaced or updated to cover _RestClient and the new write path directly.
Background
influxdb3-pythonstill uses a legacy OpenAPI-style HTTP stack for write requests:WriteApi -> WriteService -> ApiClient -> RESTClientObject -> ConfigurationThis stack was inherited from the InfluxDB v2 client and is now heavier than needed for the InfluxDB 3 client. Sign-in/sign-out services have already been removed, but write requests still depend on the generated-style
ApiClientandWriteServicelayers.Goal
Introduce a small internal
_RestClientfor HTTP-based endpoints and route writes through it directly, while preserving the current public write API behavior.Scope
_RestClientSuggested location:
Responsibilities:
AuthorizationUser-Agenturllib3.verify_sslssl_ca_certcert_filecert_key_filecert_key_passwordssl_contextproxyproxy_headersconnection_pool_maxsizeenable_gzipandgzip_thresholdApiExceptionor compatible error type for non-2xx responses._RestClientRefactor
WriteApi._post_write(...)so it no longer callsWriteService.post_write(...).Preserve current endpoint behavior:
use_v2_api=True/api/v2/writeorg,bucket,precisionuse_v2_api=False/api/v3/write_lporg,db,precisionno_sync=trueaccept_partial=falsePreserve current validation:
use_v2_api=Truewithno_sync=Trueraises:ValueError("invalid write options: no_sync cannot be used with use_v2_api")Preserve current error translation:
405on/api/v2/writesuggestsuse_v2_api=False405on/api/v3/write_lpsuggestsuse_v2_api=TrueInfluxDBPartialWriteErrorAcceptance criteria
/api/v2/writeand/api/v3/write_lp.accept_partial,no_sync, anduse_v2_apikeep their current behavior.WriteService,ApiClient, orRESTClientObject.InfluxDBClient3WriteOptionsclient.write(...)client.flush()client.close()WriteService/ApiClientare replaced or updated to cover_RestClientand the new write path directly.