SDKs

Typed SDKs

First-class TypeScript and Python clients. The MCP server and every example are built on them. Same resources, same shapes, in both languages.

TypeScript — @venym/sdk

bash
pnpm add @venym/sdk   # or npm i / yarn add

Zero runtime dependencies (native fetch, Node ≥ 20 or any modern browser). Config resolves from arguments, then the VENYM_API_KEY / VENYM_BASE_URL env vars.

typescript
import { VenymClient } from "@venym/sdk";

const venym = new VenymClient({ apiKey: process.env.VENYM_API_KEY });

// View data (no key needed)
const book = await venym.markets.getOrderbook("BTC");
const candles = await venym.charts.getCandles("BTC", { interval: "1h", limit: 200 });
const routing = await venym.routing.getRecommendation("BTC", { side: "BUY" });

// Stream (async generator; stop with break or an AbortSignal)
const ac = new AbortController();
for await (const ev of venym.streams.trades("BTC", { signal: ac.signal })) {
  console.log(ev.event, ev.data); // event: "trade"
}

// Trade (needs an agent key)
const order = await venym.orders.place(
  { symbol: "BTC", side: "BUY", type: "MARKET", quantity: "0.01" },
  { idempotencyKey: crypto.randomUUID() },
);

// Pair trade
const pair = await venym.pairs.open({ longSymbol: "ETH", shortSymbol: "BTC", notionalUsd: 500, leverage: 3 });
await venym.pairs.close(pair.id!);

// Cross-chain swap: quote → prepare (sign yourself) or execute (headless)
const quote = await venym.swaps.quote({ fromChain: 42161, toChain: 8453, fromToken: "0x0...", toToken: "0x833...", fromAmount: "1000000000000000" });
const prepared = await venym.swaps.prepare({ quoteId: quote.bestQuote?.quoteId });

Errors

Every failure throws a typed error you can narrow: VenymAuthError (401/403), VenymRateLimitError (429, carries retryAfterMs), VenymAPIError, VenymTimeoutError, VenymNetworkError.

Python — venym

bash
pip install venym

Sync and async clients (built on httpx), pydantic models, and SSE streaming.

python
from venym import VenymClient

venym = VenymClient(api_key=os.environ["VENYM_API_KEY"])

# View data
book = venym.markets.get_orderbook("BTC")
candles = venym.charts.get_candles("BTC", timeframe="1h", limit=200)
routing = venym.routing.get_recommendation("BTC", side="BUY")

# Stream
for ev in venym.streams.trades("BTC"):
    print(ev.event, ev.data)  # event: "trade"
    break

# Trade
order = venym.orders.place(symbol="BTC", side="BUY", type="MARKET", quantity="0.01")

# Pair trade + swap
pair = venym.pairs.open(long_symbol="ETH", short_symbol="BTC", notional_usd=500, leverage=3)
quote = venym.swaps.quote(from_chain=42161, to_chain=8453, from_token="0x0...", to_token="0x833...", from_amount="100...")
python
# async
import asyncio
from venym import AsyncVenymClient

async def main():
    async with AsyncVenymClient() as v:
        print(await v.markets.get_tickers())
        async for ev in v.streams.candles("BTC", interval="1m"):
            print(ev.data); break

asyncio.run(main())
Prefer no code? The same capabilities are available as MCP tools inside your agent harness. SDK resources: markets, trades, charts, routing, streams, orders, positions, pairs, swaps.

Parity