An idiomatic C++ client library for theCloud IoT API, a service to register and manage IoT (Internet of Things) devices that connect to the Google Cloud Platform.
While this library isGA, please note Google Cloud C++ client libraries donotfollowSemantic Versioning.
Quickstart
The following shows the code that you'll run in thegoogle/cloud/iot/quickstart/directory, which should give you a taste of the Cloud IoT API C++ client library API.
#include "google/cloud/iot/v1/device_manager_client.h"
#include "google/cloud/project.h"
#include <iostream>
int main(int argc, char* argv[]) try {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " project-id location-id\n";
return 1;
}
namespace iot = ::google::cloud::iot_v1;
auto client = iot::DeviceManagerClient(iot::MakeDeviceManagerConnection());
auto const project = google::cloud::Project(argv[1]);
auto const parent = project.FullName() + "/locations/" + argv[2];
for (auto dr : client.ListDeviceRegistries(parent)) {
if (!dr) throw std::move(dr).status();
std::cout << dr->DebugString() << "\n";
}
return 0;
} catch (google::cloud::Status const& status) {
std::cerr << "google::cloud::Status thrown: " << status << "\n";
return 1;
}
Main classes
The main class in this library isiot_v1::DeviceManagerClient. All RPCs are exposed as member functions of this class. Other classes provide helpers, configuration parameters, and infrastructure to mockiot_v1::DeviceManagerClientwhen testing your application.
Retry, Backoff, and Idempotency Policies.
The library automatically retries requests that fail with transient errors, and usesexponential backoffto backoff between retries. Application developers can override the default policies.
More Information
Error Handling- describes how the library reports errors.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis library is a GA (Generally Available) idiomatic C++ client library for the Cloud IoT API, enabling the registration and management of IoT devices on the Google Cloud Platform.\u003c/p\u003e\n"],["\u003cp\u003eThe library does not follow Semantic Versioning, despite being in GA.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eiot_v1::DeviceManagerClient\u003c/code\u003e is the main class, providing member functions for all RPCs, with additional classes for helpers, configuration, and testing mocks.\u003c/p\u003e\n"],["\u003cp\u003eRequests are automatically retried with exponential backoff in case of transient errors, with the option to override these policies.\u003c/p\u003e\n"],["\u003cp\u003eThe library's behavior can be configured using environment variables, and you can override the default endpoint and authentication credentials.\u003c/p\u003e\n"]]],[],null,["Version 2.11.0keyboard_arrow_down\n\n- [2.15.0-rc (latest)](/cpp/docs/reference/iot/latest)\n- [2.14.0](/cpp/docs/reference/iot/2.14.0)\n- [2.13.0](/cpp/docs/reference/iot/2.13.0)\n- [2.12.0](/cpp/docs/reference/iot/2.12.0)\n- [2.11.0](/cpp/docs/reference/iot/2.11.0) \n\nCloud IoT API C++ Client Library\n================================\n\nAn idiomatic C++ client library for the [Cloud IoT API](https://cloud.google.com/iot), a service to register and manage IoT (Internet of Things) devices that connect to the Google Cloud Platform.\n\nWhile this library is **GA** , please note Google Cloud C++ client libraries do **not** follow [Semantic Versioning](https://semver.org/).\n\n### Quickstart\n\nThe following shows the code that you'll run in the `google/cloud/iot/quickstart/` directory, which should give you a taste of the Cloud IoT API C++ client library API. \n\n #include \"google/cloud/iot/v1/device_manager_client.h\"\n #include \"google/cloud/project.h\"\n #include \u003ciostream\u003e\n\n int main(int argc, char* argv[]) try {\n if (argc != 3) {\n std::cerr \u003c\u003c \"Usage: \" \u003c\u003c argv[0] \u003c\u003c \" project-id location-id\\n\";\n return 1;\n }\n\n namespace iot = ::google::cloud::iot_v1;\n auto client = iot::DeviceManagerClient(iot::MakeDeviceManagerConnection());\n\n auto const project = google::cloud::Project(argv[1]);\n auto const parent = project.FullName() + \"/locations/\" + argv[2];\n for (auto dr : client.ListDeviceRegistries(parent)) {\n if (!dr) throw std::move(dr).status();\n std::cout \u003c\u003c dr-\u003eDebugString() \u003c\u003c \"\\n\";\n }\n\n return 0;\n } catch (google::cloud::Status const& status) {\n std::cerr \u003c\u003c \"google::cloud::Status thrown: \" \u003c\u003c status \u003c\u003c \"\\n\";\n return 1;\n }\n\n### Main classes\n\nThe main class in this library is [`iot_v1::DeviceManagerClient`](/cpp/docs/reference/iot/2.11.0/classgoogle_1_1cloud_1_1iot__v1_1_1DeviceManagerClient). All RPCs are exposed as member functions of this class. Other classes provide helpers, configuration parameters, and infrastructure to mock [`iot_v1::DeviceManagerClient`](/cpp/docs/reference/iot/2.11.0/classgoogle_1_1cloud_1_1iot__v1_1_1DeviceManagerClient) when testing your application.\n\n### Retry, Backoff, and Idempotency Policies.\n\nThe library automatically retries requests that fail with transient errors, and uses [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) to backoff between retries. Application developers can override the default policies.\n\n### More Information\n\n- [Error Handling](https://cloud.google.com/cpp/docs/reference/common/latest/common-error-handling.html) - describes how the library reports errors.\n- [How to Override the Default Endpoint](/cpp/docs/reference/iot/2.11.0/iot-override-endpoint) - describes how to override the default endpoint.\n- [How to Override the Authentication Credentials](/cpp/docs/reference/iot/2.11.0/iot-override-authentication) - describes how to change the authentication credentials used by the library.\n- [Environment Variables](/cpp/docs/reference/iot/2.11.0/iot-env) - describes environment variables that can configure the behavior of the library."]]