SDK Native C
Overview
The 9ProxySDK (Native C) provides a native C interface (with C linkage, usable from C/C++/Go via exported functions) for managing residential proxy sessions, port forwarding, authentication, and automatic rotation/renewal.
Error and memory conventions:
Return codes: 0 = success; non-zero = error (unless noted otherwise).
Get last error: SDKGetLastError() → char*; you must free the returned buffer with FreeBuf().
Any string/byte buffer returned by the SDK must be released with FreeBuf().
Typical Flow
Start -> Run SDK -> Set setting(api/ports) -> Restore data -> [close application] -> SafeExit()
Example Implementation
// example
const char* host = "https://g-api-dev.9proxy.com/sdk/v1";
// Run the SDK loop. Call RunAsync/Run before any proxy or config APIs so the command processor is active.
RunAsync(); // or call Run, but run it on a separate thread to avoid blocking the main thread
// Enable debug logging
EnableDebug();
// Set the path where the SDK stores its data
SetSaveDataPath("/var/tmp/save");
// Configure the API host
SetAPIHost((char*)host);
// Set a default query parameter (e.g., API key)
SetQuery("api-key", "677e2c4517f247bc89dd66a4");
// Start the WebSocket communication channel (see the WebSocket/event documentation for details)
StartComunicate(1, 8881, "abcd1234");
// Update IP format + port range
UpdateIpFormatAndPorts("127.0.0.1:%d", 60000, 60003);
// After all settings are applied, restore previously saved data to keep existing forwards
RestoreData();
// If you want to try binding a specific port:
// int rc = QuickCreateAtPort(60000, "request_id", "1");
// printf("Binding Result: %d\n", rc);
sleep(1);
StopComunicate();
SafeExit();
return 0;
Last updated
Was this helpful?