Simple C++ InfluxDB client via MS C++ REST SDK + RxCpp for batching (Windows/OSX/Linux) + a C wrapper
Makefile C++ Lua C Shell Ruby Batchfile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Build status Build Status FOSSA Status

A naive C++(14) InfluxDB client via C++ REST SDK + a C wrapper of the asynchronous API as a shared library.

See the demo source for the current api example.

The unbatched aprroach (and without connection reuse) may not be sufficient in some situations, as without batching, about 200 lines/sec can be inserted.

A batching api leans towards thousands inserts per second. Behind the scenes, the API uses RxCpp and cppformat.


Build and test ok on Win10/Ubuntu64/OSX.

Feel free to contribute, as the progress is rather sporadic due to lack of spare time.

Synchronous insertion

influxdb::api::simple_db simpledb("http://localhost:8086", "my_db");
	line("log", key_value_pairs("my_tag", 42L), key_value_pairs("value", "hello world!")));

Asynchronous insertion

The asynchronous API inserts the points on an active object with automatic batching, thus increasing throughput.

influxdb::async_api::simple_db asyncdb("http://localhost:8086", "my_db");

for (int i = 0; i < 123456; i++) {
      key_value_pairs("my_count", i % MAX_VALUES_PER_TAG),
      key_value_pairs("value", "hi!")


see async_c_test.cpp and the related headers.


Timestamps can be added as the last parameter to the line constructor, and only need to return a serializable value on TTimestamp::now(). There is a default std::chrono-based implementation:

      key_value_pairs("my_count", i % MAX_VALUES_PER_TAG),
      key_value_pairs("value", "hi!"),
//    ^^^^^^^^^^^^^^^^^^^

MAX_VALUES_PER_TAG for demo purposes here, as there is such a maximum and it has to be observed by the clients.

Multiple lines in synchronous API

Add lines using the () operator on the line:

    ("multiple", key_value_pairs("v1", 1), key_value_pairs())
    ("multiple", key_value_pairs("v2", 2), key_value_pairs())


influxdb::raw::db_utf8 raw_db("http://localhost:8086", "my_db");
auto query = std::string("select count(*) from my_db..my_measurements";
auto json_response = raw_db.get(query);



Basic authentication can be used with all API variants

influxdb::raw::db_utf8 raw_db("http://localhost:8086", "my_db");
raw_db.with_authentication(username, password);
auto query = ...

Build & Test

The 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.

Dependencies on Linux and OS X

cpprestsdk needs to be built and available, which in turn has platform-specific transient dependencies.

The easiest way to install it on MacOS X and Linux turned out to be via Homebrew and Linuxbrew respectively.

Once the install brew install cpprestsdk succeeds, build: make -C build/<platform>/gmake config=release_x64 and run the test.

If the build fails due to failed dependencies, check premake5.lua for the build config, and regenerate makefiles if necessary via premake/premake5<os-specific> gmake

Thanks to

  • @kirkshoop for indispensable help with RxCpp
  • @nikkov for pointing out the missing essential features
  • @promgamer for the identifiers PR


FOSSA Status