@skynetx.io/sdk
v0.1.0
Published
Official TypeScript/JavaScript SDK for the SkynetX crypto derivatives & market-data API. Built for AI agents, quant systems, and trading bots.
Downloads
83
Maintainers
Readme
@skynetx.io/sdk
Official TypeScript/JavaScript SDK for the SkynetX crypto derivatives & market-data API. Built for AI agents, quant systems, and trading bots.
- Typed responses for the 20 most-used endpoints (funding rates, OI, liquidations, ETF flows, options, sentiment, on-chain, indicators)
- Automatic retry with exponential backoff on
429+5xx, honorsX-RateLimit-ResetandRetry-After - Works on Node 18+, Bun, Deno, Cloudflare Workers, Vercel Edge — anywhere
fetchis available - Zero runtime dependencies
- Escape-hatch
client.request<T>(path)for endpoints not yet wrapped
Install
npm install @skynetx.io/sdk
# or
pnpm add @skynetx.io/sdk
# or
yarn add @skynetx.io/sdkQuickstart
import { SkynetxClient } from "@skynetx.io/sdk";
const cg = new SkynetxClient({ apiKey: process.env.SKYNETX_API_KEY });
const { data } = await cg.fundingRates({ coin: "BTC" });
console.log(data); // [{ coin: "BTC", source: "binance", fundingRate: 0.0001, ... }]Get a key: skynetx.io/dashboard/api-keys — free tier covers most developer workloads.
Response envelope
Every endpoint returns the same shape:
interface ApiEnvelope<T> {
data: T | null;
meta?: { total?: number; limit?: number; offset?: number; [k: string]: unknown };
error?: { code: string; message: string };
}On error, the SDK throws a typed exception — you don't need to check error manually.
Error taxonomy
| Class | When |
| --- | --- |
| AuthError | 401/403 — bad or missing API key |
| RateLimitError | 429 — includes resetAt and retryAfterMs |
| NotFoundError | 404, UNKNOWN_UNDERLYING, UNKNOWN_ASSET |
| BadParamError | 400, BAD_PARAM |
| ServerError | 5xx |
| NetworkError | fetch failure / timeout |
| SkynetxError | base class — catch this to catch everything |
import { SkynetxClient, RateLimitError } from "@skynetx.io/sdk";
try {
const { data } = await cg.fundingRates({ coin: "BTC" });
} catch (err) {
if (err instanceof RateLimitError) {
console.log(`Backoff until ${new Date(err.resetAt ?? 0).toISOString()}`);
}
}Retry policy
Default: 3 retries, 500ms base, exponential with 30% jitter, cap 30s. Server directives (Retry-After, X-RateLimit-Reset) override computed delays.
const cg = new SkynetxClient({
apiKey: process.env.SKYNETX_API_KEY,
retry: { maxRetries: 5, baseMs: 250, maxSleepMs: 60_000, jitter: 0.3 },
});Rate-limit tiers
| Tier | RPM per endpoint | How to upgrade | | --- | --- | --- | | Anonymous | 10 | No key required for public series | | Free | 60 | Sign up at skynetx.io | | Pro | 600 | skynetx.io/pricing | | Agent | 3,000+ | Contact [email protected] |
Exact limits per-endpoint are in the x-rate-limit-rpm field of openapi.json.
Common recipes
Funding-rate arbitrage scanner
const { data } = await cg.fundingHeatmap({ limit: 200 });
const outliers = (data ?? []).filter((row) => Math.abs(row.fundingRate) > 0.001);Liquidation-cascade alert
const { data } = await cg.liquidations({ coin: "BTC", limit: 100 });
const totalShort = (data ?? [])
.filter((l) => l.side === "short")
.reduce((sum, l) => sum + l.amountUsd, 0);
if (totalShort > 50_000_000) notifyTeam("short squeeze brewing");Options max-pain cross-check
const { data: mp } = await cg.optionsMaxPain("BTC");
const { data: price } = await cg.spotPrice("BTC");
const gap = ((mp?.maxPainStrike ?? 0) - (price?.priceUsd ?? 0)) / (price?.priceUsd ?? 1);
console.log(`BTC is ${(gap * 100).toFixed(1)}% from max pain`);Cancel in-flight requests
Every method accepts { signal }:
const ac = new AbortController();
setTimeout(() => ac.abort(), 2000);
await cg.liquidations({ coin: "BTC" }, { signal: ac.signal });Custom fetch / edge runtimes
import { SkynetxClient } from "@skynetx.io/sdk";
// Example: Cloudflare Workers — use globalThis.fetch directly, already bound.
const cg = new SkynetxClient({
apiKey: env.SKYNETX_API_KEY,
fetch: globalThis.fetch,
});Reference
- Full API docs — skynetx.io/docs/api
- OpenAPI spec — skynetx.io/openapi.json
- Issues — github.com/alexcarney460-hue/skynetx/issues
- LLM-optimized docs — skynetx.io/llms.txt
License
MIT © SkynetX
