TypeScript client
The typed client lives in this repository. It is not published to npm yet; an npm release will follow.
npm install for it today. For an agent or a script outside this repository, use plain fetch, as below. Everything here runs with a test key.Plain fetch
Node 20 or later, no dependencies. Every route is on the API reference; the OpenAPI document at /api/v2/openapi.json has every field.
const BASE = "https://usetomahawk.xyz/api/v2";
export async function renko(method, path, body) {
const res = await fetch(BASE + path, {
method,
headers: { Authorization: "Bearer " + process.env.RENKO_API_KEY, "content-type": "application/json" },
body: body ? JSON.stringify(body) : undefined,
});
const json = await res.json();
if (!json.ok) throw Object.assign(new Error(json.error.message), { code: json.error.code });
return json.data;
}
// retry only network errors and 5xx, and always with the same clientId
const markets = await renko("GET", "/markets");
const intent = { symbol: "BTC", side: "buy", type: "market", notional: "20", mode: "paper" };
const { orders } = await renko("POST", "/orders", { intent, clientId: crypto.randomUUID() });
console.log(markets.length, orders[0].mode, orders[0].status);The client in packages/sdk
packages/sdk (@renko/sdk) wraps the typed REST and realtime clients and adds placeOrder (preview, refuse a blocked order, place with a generated clientId, retry transient failures with the same id), waitForOrder, stream helpers and Solana buy and sell. Inside a checkout, build it once and import the built file:
pnpm -C <repo>/packages/sdk build// a script inside a checkout of this repository, after the build above
import { createRenko } from "<repo>/packages/sdk/dist/index.js"; // as a file:// URL on Windows
const renko = createRenko({ apiKey: process.env.RENKO_API_KEY });
const placed = await renko.placeOrder({ symbol: "BTC", side: "buy", type: "limit", size: "0.001", price: "50000", tif: "post_only" });
console.log(placed.mode, placed.primary.status); // paper open
await renko.rest.cancelOrder(placed.primary.id);
renko.close();The package README lists every option and helper. Solana helpers default to 300 bps of slippage while a new key allows 100, so pass slippageBps: 100 or raise the key's cap. Errors carry the server's code in .code; see Safety.