{"id":13529412,"url":"https://github.com/d-led/influxdb-cpp-rest","last_synced_at":"2025-04-14T04:15:18.844Z","repository":{"id":46927000,"uuid":"72242525","full_name":"d-led/influxdb-cpp-rest","owner":"d-led","description":"Simple C++ InfluxDB client via MS C++ REST SDK + RxCpp for batching (Windows/OSX/Linux) + a C wrapper","archived":false,"fork":false,"pushed_at":"2023-06-01T08:56:13.000Z","size":2912,"stargazers_count":45,"open_issues_count":4,"forks_count":27,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T04:15:10.995Z","etag":null,"topics":["batching","c","client","cpp","cross-platform","influxdb","rxcpp","time-series"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d-led.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-10-28T21:14:05.000Z","updated_at":"2024-11-25T06:03:17.000Z","dependencies_parsed_at":"2024-01-23T16:10:49.417Z","dependency_job_id":"22f4ae2e-4e61-4177-9f55-5cfd8d66325e","html_url":"https://github.com/d-led/influxdb-cpp-rest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-led%2Finfluxdb-cpp-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-led%2Finfluxdb-cpp-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-led%2Finfluxdb-cpp-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-led%2Finfluxdb-cpp-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d-led","download_url":"https://codeload.github.com/d-led/influxdb-cpp-rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819408,"owners_count":21166477,"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":["batching","c","client","cpp","cross-platform","influxdb","rxcpp","time-series"],"created_at":"2024-08-01T07:00:36.076Z","updated_at":"2025-04-14T04:15:18.825Z","avatar_url":"https://github.com/d-led.png","language":"Makefile","readme":"# influxdb-cpp-rest\n\nStatus: archive as the build \u0026 dependenies are out of date\n\n[![Build status](https://ci.appveyor.com/api/projects/status/68w68vq3nai4794g/branch/master?svg=true)](https://ci.appveyor.com/project/d-led/influxdb-cpp-rest/branch/master) [![Build Status](https://travis-ci.org/d-led/influxdb-cpp-rest.svg?branch=master)](https://travis-ci.org/d-led/influxdb-cpp-rest)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fd-led%2Finfluxdb-cpp-rest.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fd-led%2Finfluxdb-cpp-rest?ref=badge_shield)\n\nA naive C++(14) [InfluxDB](https://www.influxdata.com/time-series-platform/influxdb/) client via [C++ REST SDK](https://github.com/Microsoft/cpprestsdk) + a C wrapper of the asynchronous API as a shared library.\n\nSee [the demo source](src/demo/main.cpp) for the current api example.\n\nThe unbatched aprroach (and without connection reuse) may not be sufficient in some situations, as without batching, about 200 lines/sec can be inserted.\n\nA batching api leans towards thousands inserts per second. Behind the scenes, the API uses [RxCpp](https://github.com/Reactive-Extensions/RxCpp) and [cppformat](https://github.com/fmtlib/fmt).\n\n## Status\n\n- Build and test ok on Win10/Ubuntu64/OSX.\n- Feel free to contribute, as the progress is rather sporadic due to lack of spare time.\n- tested with InfluxDB v1.2.4, v1.7.5, v1.7.6\n\n## Synchronous insertion\n\n```cpp\ninfluxdb::api::simple_db simpledb(\"http://localhost:8086\", \"my_db\");\ndb.insert(\n\tline(\"log\", key_value_pairs(\"my_tag\", 42L), key_value_pairs(\"value\", \"hello world!\")));\n```\n\n## Asynchronous insertion\n\nThe asynchronous API inserts the points on an active object with automatic batching, thus increasing throughput.\n\n```cpp\ninfluxdb::async_api::simple_db asyncdb(\"http://localhost:8086\", \"my_db\");\n\nfor (int i = 0; i \u003c 123456; i++) {\n  asyncdb.insert(\n    line(\n      \"my_measurements\",\n      key_value_pairs(\"my_count\", i % MAX_VALUES_PER_TAG),\n      key_value_pairs(\"value\", \"hi!\")\n    ));\n}\n```\n\n## C API\n\nsee [async_c_test.cpp](src/test-shared/async_c_test.cpp) and the related headers.\n\n## Timestamps\n\nTimestamps can be added as the last parameter to the `line` constructor, and only need to return\na serializable value on `TTimestamp::now()`. There is a default `std::chrono`-based implementation:\n\n```cpp\n    line(\n      \"my_measurements\",\n      key_value_pairs(\"my_count\", i % MAX_VALUES_PER_TAG),\n      key_value_pairs(\"value\", \"hi!\"),\n      default_timestamp()\n//    ^^^^^^^^^^^^^^^^^^^\n    )\n```\n\n`MAX_VALUES_PER_TAG` for demo purposes here, as there [is such a maximum](https://docs.influxdata.com/influxdb/v1.4/administration/config#max-values-per-tag-100000) and it has to be observed by the clients.\n\n## Multiple lines in synchronous API\n\nAdd lines using the `()` operator on the line:\n\n```cpp\n  line\n    (\"multiple\", key_value_pairs(\"v1\", 1), key_value_pairs())\n    (\"multiple\", key_value_pairs(\"v2\", 2), key_value_pairs())\n```\n\n## Query\n\n```cpp\ninfluxdb::raw::db_utf8 raw_db(\"http://localhost:8086\", \"my_db\");\nauto query = std::string(\"select count(*) from my_db..my_measurements\");\nauto json_response = raw_db.get(query);\n```\n\n\u0026darr;\n\n```\n{\"results\":[{\"series\":[{\"name\":\"asynctest\",\"columns\":[\"time\",\"count_value\"],\"values\":[[\"...Z\",123456]]}]}]}\n```\n\n## Authentication\n\nBasic authentication can be used with all API variants\n\n```cpp\ninfluxdb::raw::db_utf8 raw_db(\"http://localhost:8086\", \"my_db\");\nraw_db.with_authentication(username, password);\nauto query = ...\n```\n\n## Error Handling\n\n- Synchronous C++ API will throw exceptions on HTTP errors\n- Asynchronous APIs will drop inserts on HTTP errors and print to `stderr`\n- C api tries to catch CPP exceptions and\n  - print exceptions to `stderr`\n  - return non-zero `int` or `nullptr` where sensible\n- Open issue: [#18](https://github.com/d-led/influxdb-cpp-rest/issues/18)\n\n## Build \u0026 Test\n\nThe library should be easy to build, given `RxCpp` and `cpprestsdk` can be found. The Visual Studio 2015 solution is self-contained. A locally running, authentication-free instance of InfluxDB is required to run the test.\n\n### Dependencies on Linux and OS X\n\ncpprestsdk needs to be built and available, which in turn has platform-specific transient dependencies.\n\nThe easiest way to install it on MacOS X and Linux turned out to be via [Homebrew](https://brew.sh) and [Linuxbrew](https://linuxbrew.sh) respectively.\n\nOnce the install `brew install cpprestsdk` succeeds, build: `make -C build/\u003cplatform\u003e/gmake config=release_x64` and run the test.\n\nIf the build fails due to failed dependencies, check [premake5.lua](premake5.lua) for the build config, and regenerate makefiles if necessary via `premake/premake5\u003cos-specific\u003e gmake`\n\n## Thanks to\n\n- @kirkshoop for indispensable help with [RxCpp](https://github.com/Reactive-Extensions/RxCpp)\n- @nikkov for pointing out the missing essential features\n- @promgamer, @garaemon for the identifiers PRs\n\n\n## License\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fd-led%2Finfluxdb-cpp-rest.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fd-led%2Finfluxdb-cpp-rest?ref=badge_large)\n","funding_links":[],"categories":["Client libraries"],"sub_categories":["Unofficial"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-led%2Finfluxdb-cpp-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd-led%2Finfluxdb-cpp-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-led%2Finfluxdb-cpp-rest/lists"}