C++ SDK
Encrypted C++ client for the GoDark API. Headers under godark/.
Requirements: C++20 (GCC ≥ 13 recommended), CMake ≥ 3.25
Status: Beta — clone the public examples repo to get started.
Get the SDK
Clone gdx-cpp-sdk-examples. The repo vendors a prebuilt libgodark.a plus headers under sdk/ so no private package registry is required:
git clone https://github.com/gq-godark/gdx-cpp-sdk-examples.git
cd gdx-cpp-sdk-examples
cp .env.example .env
# set GODARK_API_KEY_ID, GODARK_API_SECRET, GODARK_PASSPHRASE
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
./build/examples/quickstart
You can also point an LLM / coding agent at the cloned repo and ask it to build a strategy using your credentials in .env. See the repo README for system dependencies, examples, and packaging details.
Public Conan/vcpkg packages are not yet available; until then this repo is the supported distribution.
Quickstart
Set credentials, then place a limit order over encrypted WebSocket (GodarkClient). Subscribe to orders before placing so book confirmation can wait on private updates. Limit prices must stay near the oracle or the venue rejects — see Error Codes.
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <thread>
#include <godark/godark.hpp>
int main() {
godark::ClientConfig config;
config.api_key_id = std::getenv("GODARK_API_KEY_ID");
config.api_secret = std::getenv("GODARK_API_SECRET");
config.passphrase = std::getenv("GODARK_PASSPHRASE");
config.environment = godark::Environment::Testnet;
if (const char* edge = std::getenv("GODARK_EDGE_URL"); edge && edge[0] != '\0') {
config.base_url = edge;
}
godark::GodarkClient client(config);
client.connect();
client.subscribe({"orders"});
const std::string symbol = "BTC-USDC-PERP";
auto ack = client.place_order(
symbol,
godark::Side::SELL,
godark::OrderType::LIMIT,
0.01,
68000.0); // within ~10% of oracle
std::cout << "placed " << ack.order_id << "\n";
std::this_thread::sleep_for(std::chrono::milliseconds(500));
auto cancel = client.cancel_order(ack.order_id, symbol);
std::cout << "cancelled " << cancel.order_id << "\n";
client.disconnect();
return 0;
}
See WebSocket Trading and Place Order for request fields.
Clients
| Type | Header | Description |
|---|---|---|
GodarkClient | godark/client.hpp | WebSocket trading + order/position streams on /ws/v1 |
MarketDataClient | godark/market_data.hpp | External venue feeds on /ws/gomarket |
Configure via ClientConfig: api_key_id, api_secret, passphrase, environment, optional base_url. GodarkRestClient may still be exported for residual HTTP helpers; encrypted order place / cancel / modify is WebSocket-only.
GodarkClient methods
| Method | Docs reference |
|---|---|
connect() / disconnect() | Authentication, Encryption |
subscribe(...) | WebSocket Trading |
place_order(...) | Place Order, WebSocket Trading |
cancel_order(...) | Cancel Order |
modify_order(...) | Modify Order |
mass_quote(...) | Mass Quote |
batch_cancel(...) | Cancel Order |
on_order_update | Orders Channel |
on_position_update | Positions Channel |
Types and errors
Headers under godark/: Environment, Side, OrderType, TimeInForce, OrderStatus, OrderAck, OrderUpdate, PositionUpdate. Errors: AuthenticationError, SessionError, OrderError, EncryptionError, TimeoutError, ConnectionError.
Environment variables: OS GODARK_*, then OS GDX_*, then .env GODARK_*, then .env GDX_*. The process environment always wins over .env. Quickstart snippets use the canonical GODARK_* names.
Bundled examples
Runnable samples in the examples repo: quickstart (connect → subscribe → place → cancel) and full_trader_example (modify, mass quote, batch cancel) — ./build/examples/quickstart, ./build/examples/full_trader_example.