{"id":19284940,"url":"https://github.com/orca-zhang/influxdb-cpp","last_synced_at":"2025-04-07T08:18:58.529Z","repository":{"id":28316859,"uuid":"114100948","full_name":"orca-zhang/influxdb-cpp","owner":"orca-zhang","description":"💜 C++ client for InfluxDB.","archived":false,"fork":false,"pushed_at":"2024-04-09T13:53:44.000Z","size":56,"stargazers_count":151,"open_issues_count":12,"forks_count":114,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-04-13T13:04:25.964Z","etag":null,"topics":["cpp","cross-platform","header-only","influxdb","influxdb-cpp","no-dependencies"],"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/orca-zhang.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,"dei":null}},"created_at":"2017-12-13T09:29:21.000Z","updated_at":"2024-04-14T20:09:25.879Z","dependencies_parsed_at":"2023-11-21T17:00:51.273Z","dependency_job_id":"cf6b61ab-6d33-451c-9a63-b05a42ad1e65","html_url":"https://github.com/orca-zhang/influxdb-cpp","commit_stats":{"total_commits":57,"total_committers":11,"mean_commits":5.181818181818182,"dds":"0.24561403508771928","last_synced_commit":"fa4cb4927877ef64a4e2aae4ef29daf0ac309614"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orca-zhang%2Finfluxdb-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orca-zhang%2Finfluxdb-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orca-zhang%2Finfluxdb-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orca-zhang%2Finfluxdb-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orca-zhang","download_url":"https://codeload.github.com/orca-zhang/influxdb-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299828,"owners_count":20916190,"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","cross-platform","header-only","influxdb","influxdb-cpp","no-dependencies"],"created_at":"2024-11-09T21:40:59.185Z","updated_at":"2025-04-07T08:18:58.495Z","avatar_url":"https://github.com/orca-zhang.png","language":"C++","readme":"# influxdb-cpp\n\nA header-only C++ query \u0026 write client for InfluxDB.\n\n[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/orca-zhang/influxdb-cpp/blob/master/LICENSE) [![Build Status](https://orca-zhang.semaphoreci.com/badges/influxdb-cpp/branches/master.svg?style=shields)](https://orca-zhang.semaphoreci.com/projects/influxdb-cpp)  [![Build status](https://ci.appveyor.com/api/projects/status/gusrrn0mn67q2yaj?svg=true)](https://ci.appveyor.com/project/orca-zhang/influxdb-cpp)\n\n- Support versions:\n  - InfluxDB v0.9 ~ 2.0+\n  - Check yourself while using other versions.\n\n### Why use influxdb-cpp?\n\n- **Exactly-small**:\n  - Less than 300 lines and only 10KB+.\n- **Easy-to-use**:\n  - It's designed to be used without extra studies.\n- **Easy-to-assemble**:\n  - Only a tiny header file needs to be included.\n- **No-dependencies**:\n  - Unless STL and std C libraries.\n\n### Examples\n\n#### Before using\n\n- The very simple thing you should do before using is only:\n\n    ```cpp\n    #include \"influxdb.hpp\"\n    ```\n\n#### Writing example\n\n- You should refer to the [write syntax](https://docs.influxdata.com/influxdb/v1.4/write_protocols/line_protocol_reference/) while writing series(metrics).\n\n    ```\n    measurement[,tag-key=tag-value...] field-key=field-value[,field2-key=field2-value...] [unix-nano-timestamp]\n    ```\n\n\n- You can rapidly start writing serires by according to the following example.\n\n    ```cpp\n    influxdb_cpp::server_info si(\"127.0.0.1\", 8086, \"db\", \"usr\", \"pwd\");\n    influxdb_cpp::builder()\n        .meas(\"foo\")\n        .tag(\"k\", \"v\")\n        .tag(\"x\", \"y\")\n        .field(\"x\", 10)\n        .field(\"y\", 10.3, 2)\n        .field(\"z\", 10.3456)\n        .field(\"b\", !!10)\n        .timestamp(1512722735522840439)\n        .post_http(si);\n    ```\n\n  - **Remarks**: \n    - 3rd parameter `precision` of `field()` is optional for floating point value, and default precision is `2`. \n    - `usr` and `pwd` is optional for authorization.\n\n- The series sent is:\n\n    ```\n    foo,k=v,x=y x=10i,y=10.30,z=10.35,b=t 1512722735522840439\n    ```\n\n- You could change `post_http` to `send_udp` for udp request. And only `host` and `port` is required for udp.\n\n    ```cpp\n    influxdb_cpp::builder()\n        .meas(\"foo\")\n        .field(\"x\", 10)\n        .send_udp(\"127.0.0.1\", 8091);\n    ```\n\n- Bulk/batch/multiple insert also supports:\n\n    ```cpp\n    influxdb_cpp::builder()\n        .meas(\"foo\")  // series 1\n        .field(\"x\", 10)\n\n        .meas(\"bar\")  // series 2\n        .field(\"y\", 10.3)\n        .send_udp(\"127.0.0.1\", 8091);\n    ```\n\n- The series sent are:\n\n    ```\n    foo x=10i\n    bar y=10.30\n    ```\n\n#### Query example\n\n- And you can query series by according to the following example.\n\n  ```cpp\n  influxdb_cpp::server_info si(\"127.0.0.1\", 8086, \"db\", \"usr\", \"pwd\");\n\n  string resp;\n  influxdb_cpp::query(resp, \"select * from t\", si);\n  ```\n\n- You can use [xpjson](https://github.com/ez8-co/xpjson) to parse the result refer to [issue #3](https://github.com/orca-zhang/influxdb-cpp/issues/3).\n\n### **Remarks for Windows**\n\n- You should **init socket environment by yourself** under Windows.\n  - FYR: [MSDN doc for `WSAStartup`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms742213(v=vs.85).aspx)\n\n### **Remarks for Special Characters in Password**\n\n- You should do URL encode first.\n\n  ``` c++\n  string encoded_pwd;\n  influxdb_cpp::url_encode(encoded_pwd, pwd);\n  ```\n \n### Return code cheat-sheet\n\n|Functions|Code|Description|\n|-|-|-|\n|`send_udp` `post_http`|0|success|\n|`send_udp` `post_http`|-1|convert host address to network order error|\n|`send_udp` `post_http`|-2|create socket error|\n|`send_udp` `post_http`|-3|`sendto` / `connect` failed|\n|`post_http`|-6|send buffer error|\n|`post_http`|-7|expect a character but read no more|\n|`post_http`|-8|unexpected characters while parsing chunk length|\n|`post_http`|-9|unexpected characters while parsing new line|\n|`post_http`|-10|unexpected null character|\n|`post_http`|-11|unexpected end|\n\n### TODO\n\n- Add more test cases.\n- Supports DSN initializatin for server_info.\n- Do not need to connect every time.\n\n### Misc\n\n- Please feel free to use influxdb-cpp.\n- Looking forward to your suggestions.\n- If your project is using influxdb-cpp, you can show your project or company here by creating a issue or let me know.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forca-zhang%2Finfluxdb-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forca-zhang%2Finfluxdb-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forca-zhang%2Finfluxdb-cpp/lists"}