{"id":20990546,"url":"https://github.com/offa/influxdb-cxx","last_synced_at":"2025-04-05T05:05:08.389Z","repository":{"id":38082246,"uuid":"293851628","full_name":"offa/influxdb-cxx","owner":"offa","description":"InfluxDB C++ client library.","archived":false,"fork":false,"pushed_at":"2025-03-26T16:30:14.000Z","size":498,"stargazers_count":129,"open_issues_count":22,"forks_count":47,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T04:11:17.717Z","etag":null,"topics":["cpp","cpp20","influxdb","influxdb-client","influxdb-cxx"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/offa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-08T15:28:54.000Z","updated_at":"2025-03-26T16:30:16.000Z","dependencies_parsed_at":"2023-09-23T12:36:06.790Z","dependency_job_id":"d08cd01f-6195-46fd-b3a3-3683dcdf1e5d","html_url":"https://github.com/offa/influxdb-cxx","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offa%2Finfluxdb-cxx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offa%2Finfluxdb-cxx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offa%2Finfluxdb-cxx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offa%2Finfluxdb-cxx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/offa","download_url":"https://codeload.github.com/offa/influxdb-cxx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289426,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp20","influxdb","influxdb-client","influxdb-cxx"],"created_at":"2024-11-19T06:34:09.204Z","updated_at":"2025-04-05T05:05:08.370Z","avatar_url":"https://github.com/offa.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# influxdb-cxx\n\n[![ci](https://github.com/offa/influxdb-cxx/actions/workflows/ci.yml/badge.svg)](https://github.com/offa/influxdb-cxx/actions/workflows/ci.yml)\n[![GitHub release](https://img.shields.io/github/release/offa/influxdb-cxx.svg)](https://github.com/offa/influxdb-cxx/releases)\n[![License](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)\n![C++](https://img.shields.io/badge/c++-20-green.svg)\n[![Conan Center](https://img.shields.io/conan/v/influxdb-cxx)](https://conan.io/center/recipes/influxdb-cxx)\n\nInfluxDB C++ client library\n - Batch write\n - Data exploration\n - Supported transports\n   - HTTP/HTTPS\n   - UDP\n   - Unix datagram socket\n   - TCP\n\n*Fork of the unmaintained [awegrzyn/influxdb-cxx](https://github.com/awegrzyn/influxdb-cxx) project.*\n\n## Installation\n\n### Build requirements\n - CMake 3.12+\n - C++20 compiler\n\n### Dependencies\n - [**cpr**](https://github.com/libcpr/cpr) (required)\u003csup\u003ei)\u003c/sup\u003e\n - **boost 1.78+** (optional – see [Transports](#transports))\n\n \u003csup\u003ei)\u003c/sup\u003e *cpr* needs to provide [CMake support](https://github.com/libcpr/cpr#find_package); some systems need to call `ldconfig` after *.so* installation.\n\n\n### Generic\n ```bash\nmkdir build \u0026\u0026 cd build\ncmake ..\nsudo make install\n ```\n\n## Quick start\n\n### Include in CMake project\n\nThe InfluxDB library is exported as target `InfluxData::InfluxDB`.\n\n```cmake\nproject(example)\n\nfind_package(InfluxDB)\n\nadd_executable(example-influx main.cpp)\ntarget_link_libraries(example-influx PRIVATE InfluxData::InfluxDB)\n```\n\nThis target is also provided when the project is included as a subdirectory.\n\n```cmake\nproject(example)\nadd_subdirectory(influxdb-cxx)\nadd_executable(example-influx main.cpp)\ntarget_link_libraries(example-influx PRIVATE InfluxData::InfluxDB)\n```\n\n### Basic write\n\n```cpp\n// Provide complete URI\nauto influxdb = influxdb::InfluxDBFactory::Get(\"http://localhost:8086?db=test\");\ninfluxdb-\u003ewrite(influxdb::Point{\"test\"}\n  .addField(\"value\", 10)\n  .addTag(\"host\", \"localhost\")\n);\n```\n\n### Batch write\n\n```cpp\nauto influxdb = influxdb::InfluxDBFactory::Get(\"http://localhost:8086?db=test\");\n// Write batches of 100 points\ninfluxdb-\u003ebatchOf(100);\n\nfor (;;) {\n  influxdb-\u003ewrite(influxdb::Point{\"test\"}.addField(\"value\", 10));\n}\n```\n\n###### Note:\n\nWhen batch write is enabled, call `flushBatch()` to flush pending batches.\nThis is of particular importance to ensure all points are written prior to destruction.\n\n```cpp\nauto influxdb = influxdb::InfluxDBFactory::Get(\"http://localhost:8086?db=test\");\ninfluxdb-\u003ebatchOf(3);\ninfluxdb-\u003ewrite(influxdb::Point{\"test\"}.addField(\"value\", 1));\ninfluxdb-\u003ewrite(influxdb::Point{\"test\"}.addField(\"value\", 2));\n\n// Flush batches, both points are written\ninfluxdb-\u003eflushBatch();\n```\n\n\n### Query\n\n```cpp\n// Available over HTTP only\nauto influxdb = influxdb::InfluxDBFactory::Get(\"http://localhost:8086?db=test\");\n/// Pass an IFQL to get list of points\nstd::vector\u003cinfluxdb::Point\u003e points = influxdb-\u003equery(\"SELECT * FROM test\");\n```\n\n### Execute cmd\n\n```cpp\nauto influxdb = influxdb::InfluxDBFactory::Get(\"http://localhost:8086?db=test\");\n\n// Execute a command and receive it's response\nconst auto response = influxdb-\u003eexecute(\"SHOW DATABASES\");\n```\n\n## Transports\n\nSupported transports:\n\n| Name        | Dependency  | URI protocol   | Sample URI                            |\n| ----------- |:-----------:|:--------------:| -------------------------------------:|\n| HTTP        | cpr\u003csup\u003ei)\u003c/sup\u003e | `http`/`https` | `http://localhost:8086?db=\u003cdb\u003e`  |\n| TCP         | boost       | `tcp`          | `tcp://localhost:8094`                |\n| UDP         | boost       | `udp`          | `udp://localhost:8094`                |\n| Unix socket | boost       | `unix`         | `unix:///tmp/telegraf.sock`           |\n\n\u003csup\u003ei)\u003c/sup\u003e boost is needed to support queries.\n\n### Configuration by URI\n\nAn underlying transport is configurable by passing an URI. `[protocol]` determines the actual transport type:\n\n```cpp\nauto influxdb = influxdb::InfluxDBFactory::Get(\"http://localhost:8086?db=test\");\n```\n\nURI Format:\n\n```\n[protocol]://[username:password@]host:port[?db=database]\n\n# Auth token:\n[protocol]://[token@]host:port[?db=database]\n```\n\n### Additional transport configuration *(HTTP only)*\n\nThe HTTP transport supports additional configurations beyond the limited URI parameters:\n\n```cpp\nauto influxdb = InfluxDBBuilder::http(\"http://localhost:8086?db=test\")\n                    .setTimeout(std::chrono::seconds{20})\n                    .setAuthToken(\"\u003ctoken\u003e\")\n                    .connect();\n```\n\n\n## InfluxDB v2.x compatibility\n\nThe support for InfluxDB v2.x is limited at the moment. It's possible to use the v1.x compatibility backend though.\n\nPlease visit [*InfluxDB 1.x compatibility API* docs](https://docs.influxdata.com/influxdb/v2.6/reference/api/influxdb-1x/) for more information.\n\nTo create a v1.x compatible user (as described [here](https://docs.influxdata.com/influxdb/v2.6/reference/cli/influx/v1/auth/)):\n\n```sh\ninflux v1 auth create --read-bucket ${BUCKET_ID} --write-bucket ${BUCKET_ID} --username ${USERNAME} --password ${PASSWORD}\n```\n\n\n## Thread safety\n\nThis library is not thread-safe. Using it in a multi-threaded environment without proper synchronization mechanisms may lead to unexpected behavior and data corruption.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foffa%2Finfluxdb-cxx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foffa%2Finfluxdb-cxx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foffa%2Finfluxdb-cxx/lists"}