Skip to content

C / C++

The C ABI hub. A single wickra_xray.h header + prebuilt library links from C, C++, or any C-capable language. Drive an x-ray with the JSON command protocol.

bash
# prebuilt wickra_xray.h + library per platform:
# github.com/wickra-lib/wickra-xray/releases
c
#include "wickra_xray.h"

const char *spec = "{\"dataset_ref\":\"m\",\"symbol\":\"BTCUSDT\","
                   "\"panels\":[{\"kind\":\"footprint\",\"price_bin\":1.0,\"bucket_ms\":60000}]}";

WickraXray *xray = wickra_xray_new(spec);

// length-out protocol: call with NULL to size, then fill the buffer.
wickra_xray_command(xray, load_cmd, NULL, 0);   // { "cmd":"load", "dataset": ... }

int len = wickra_xray_command(xray, "{\"cmd\":\"frame\"}", NULL, 0);
char *frame = malloc((size_t)len + 1);
wickra_xray_command(xray, "{\"cmd\":\"frame\"}", frame, (size_t)len + 1);   // JSON frame

printf("%s\n", frame);
free(frame);
wickra_xray_free(xray);

The header is generated by cbindgen and is the same ABI the C#, Go, Java and R bindings link against.

More