{"id":9375,"library":"types-influxdb-client","title":"Typing Stubs for InfluxDB Client","description":"types-influxdb-client is a PEP 561 type stub package providing static type annotations for the `influxdb-client` library. It enables type-checking tools like Mypy, Pyright, and PyCharm to perform static analysis on code using `influxdb-client`. This particular version (`1.45.0.20241221`) targets `influxdb-client==1.45.*`. It is part of the actively maintained Typeshed project, which generally releases updates frequently.","status":"active","version":"1.45.0.20241221","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","influxdb","typeshed","type checking","mypy"],"install":[{"cmd":"pip install types-influxdb-client","lang":"bash","label":"Install package"},{"cmd":"pip install influxdb-client","lang":"bash","label":"Install peer dependency"}],"dependencies":[{"reason":"This package provides type stubs for the `influxdb-client` library itself; it is a peer dependency.","package":"influxdb-client","optional":false},{"reason":"Requires `urllib3>=2` since `types-influxdb-client` v1.37.0.1. Older `urllib3<2` requires `types-influxdb-client<1.37.0.1`.","package":"urllib3","optional":false}],"imports":[{"symbol":"InfluxDBClient","correct":"from influxdb_client import InfluxDBClient"},{"symbol":"Point","correct":"from influxdb_client import Point"},{"symbol":"SYNCHRONOUS","correct":"from influxdb_client.client.write_api import SYNCHRONOUS"}],"quickstart":{"code":"import os\nfrom influxdb_client import InfluxDBClient, Point\nfrom influxdb_client.client.write_api import SYNCHRONOUS\n\n# Configuration (use environment variables or replace with actual values)\nINFLUXDB_URL = os.environ.get('INFLUXDB_URL', 'http://localhost:8086')\nINFLUXDB_TOKEN = os.environ.get('INFLUXDB_TOKEN', 'my-super-secret-token')\nINFLUXDB_ORG = os.environ.get('INFLUXDB_ORG', 'my-org')\nINFLUXDB_BUCKET = os.environ.get('INFLUXDB_BUCKET', 'my-bucket')\n\ndef write_and_query_data() -> None:\n    try:\n        with InfluxDBClient(url=INFLUXDB_URL, token=INFLUXDB_TOKEN, org=INFLUXDB_ORG) as client:\n            write_api = client.write_api(write_options=SYNCHRONOUS)\n\n            p = Point(\"my_measurement\").tag(\"location\", \"Prague\").field(\"temperature\", 25.3)\n            write_api.write(bucket=INFLUXDB_BUCKET, record=p)\n            print(f\"Successfully wrote point: {p.to_line_protocol()}\")\n\n            query_api = client.query_api()\n            tables = query_api.query(f'from(bucket:\"{INFLUXDB_BUCKET}\") |> range(start: -1h)')\n\n            print(\"\\nQuery Results:\")\n            for table in tables:\n                for record in table.records:\n                    print(f\"  {record.get_measurement()}: {record.get_field()}={record.get_value()} @ {record.get_time()}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    write_and_query_data()","lang":"python","description":"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."},"warnings":[{"fix":"If `influxdb-client>=1.46.0` is installed, uninstall this stub package: `pip uninstall types-influxdb-client`.","message":"The `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.","severity":"breaking","affected_versions":"types-influxdb-client (all versions) used with influxdb-client>=1.46.0"},{"fix":"Always 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.*`).","message":"This 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.","severity":"gotcha","affected_versions":"All versions of types-influxdb-client when runtime library version is mismatched."},{"fix":"Ensure `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'`).","message":"This 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.","severity":"gotcha","affected_versions":"types-influxdb-client>=1.37.0.1 with urllib3<2"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the `influxdb-client` library is installed in your environment: `pip install influxdb-client`.","cause":"This error often occurs when the `types-influxdb-client` package is installed, but the actual `influxdb-client` runtime library is missing or is installed in a way that the type checker cannot find it.","error":"error: Module 'influxdb_client' has no attribute 'InfluxDBClient' [attr-defined]"},{"fix":"First, verify that `influxdb-client<1.46.0` is installed OR that `types-influxdb-client` is *not* installed. If the issue persists and versions are aligned, check for `Any` types masking the true issue or report a bug to the `typeshed` project.","cause":"This Mypy error, despite appearing to match types, can indicate a version mismatch between the `influxdb-client` library and its corresponding type stubs, or a more subtle type incompatibility (e.g., Literal types). It can also occur if both `influxdb-client` and `types-influxdb-client` are installed and their internal types conflict.","error":"error: Argument 'bucket' to 'write' of 'WriteApi' has incompatible type \"str\"; expected \"str\" [arg-type] (note: 'bucket' is a named argument)"},{"fix":"Ensure your `types-influxdb-client` version accurately reflects your installed `influxdb-client` version. For `influxdb-client>=1.46.0`, uninstall `types-influxdb-client` completely. If using an older `influxdb-client` version, downgrade `types-influxdb-client` to match.","cause":"This `attr-defined` error typically suggests that the version of `influxdb-client` in use does not have the `query_api` method, or the type stubs incorrectly declare its presence/absence for your specific client version. This is common when the stub version doesn't align with the runtime library version.","error":"error: Cannot access member \"query_api\" for type \"InfluxDBClient\" [attr-defined]"}]}