Skip to content

C++ SDK

The Connix C++ SDK provides a high-performance, modern C++ interface for integrating Connix services into your applications.

  • C++17 or later
  • CMake 3.15 or later
  • Compatible with GCC 8+, Clang 7+, MSVC 2019+
cmake_minimum_required(VERSION 3.15)
include(FetchContent)
FetchContent_Declare(
connix-cpp
GIT_REPOSITORY https://github.com/connix/connix-cpp.git
GIT_TAG v1.0.0
)
FetchContent_MakeAvailable(connix-cpp)
target_link_libraries(your_target PRIVATE connix::sdk)
Terminal window
vcpkg install connix-sdk
Terminal window
git clone https://github.com/connix/connix-cpp.git
cd connix-cpp
mkdir build && cd build
cmake ..
make install
#include <connix/client.hpp>
#include <iostream>
int main() {
try {
// Initialize the client
connix::Client client("your-api-key");
// Make a request
auto result = client.some_method("parameter");
std::cout << "Result: " << result.data << std::endl;
} catch (const connix::Exception& e) {
std::cerr << "Connix error: " << e.what() << std::endl;
return 1;
}
return 0;
}

Configure the SDK with various options:

#include <connix/client.hpp>
#include <chrono>
connix::ClientConfig config;
config.timeout = std::chrono::seconds(30);
config.max_retries = 3;
config.base_url = "https://api.connix.io";
config.headers["Custom-Header"] = "value";
connix::Client client("your-api-key", config);

The SDK supports both synchronous and asynchronous operations:

#include <connix/client.hpp>
#include <future>
connix::Client client("your-api-key");
// Synchronous
auto result = client.some_method("parameter");
// Asynchronous
auto future = client.some_method_async("parameter");
auto result = future.get();
// With callback
client.some_method_async("parameter", [](const connix::Result& result) {
std::cout << "Async result: " << result.data << std::endl;
});

The SDK provides structured exception handling:

#include <connix/exceptions.hpp>
try {
auto result = client.some_method("parameter");
} catch (const connix::ValidationException& e) {
std::cerr << "Validation error: " << e.what() << std::endl;
} catch (const connix::NetworkException& e) {
std::cerr << "Network error: " << e.what() << std::endl;
} catch (const connix::Exception& e) {
std::cerr << "Connix error: " << e.what()
<< " (code: " << e.error_code() << ")" << std::endl;
} catch (const std::exception& e) {
std::cerr << "Other error: " << e.what() << std::endl;
}
Client(const std::string& api_key, const ClientConfig& config = {});
Result some_method(const std::string& param);
std::future<Result> some_method_async(const std::string& param);
void some_method_async(const std::string& param, std::function<void(const Result&)> callback);
struct ClientConfig {
std::chrono::milliseconds timeout{30000};
int max_retries{3};
std::string base_url{"https://api.connix.io"};
std::map<std::string, std::string> headers;
};
struct Result {
std::string id;
std::string data;
std::chrono::system_clock::time_point timestamp;
};

The Connix C++ SDK is thread-safe. You can safely use a single client instance across multiple threads:

#include <thread>
#include <vector>
connix::Client client("your-api-key");
std::vector<std::thread> threads;
for (int i = 0; i < 4; ++i) {
threads.emplace_back([&client, i]() {
auto result = client.some_method("thread-" + std::to_string(i));
std::cout << "Thread " << i << " result: " << result.data << std::endl;
});
}
for (auto& t : threads) {
t.join();
}
#include <connix/client.hpp>
int main() {
connix::Client client("your-api-key");
auto result = client.get_data();
for (const auto& item : result.items) {
std::cout << "Item: " << item.name << std::endl;
}
return 0;
}
#include <connix/client.hpp>
int main() {
connix::ClientConfig config;
config.timeout = std::chrono::seconds(60);
config.max_retries = 5;
connix::Client client("your-api-key", config);
try {
auto result = client.process_large_data("large-dataset");
std::cout << "Processing complete: " << result.status << std::endl;
} catch (const connix::Exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
return 0;
}

Example CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)
project(my_project)
set(CMAKE_CXX_STANDARD 17)
find_package(connix-sdk REQUIRED)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE connix::sdk)

For support and questions, visit our GitHub repository or contact support.