@toomanycooks/sdk
v0.5.0
Published
TypeScript SDK for the Too Many Cooks funding rates API. Shared between the MCP server, CLI, and any third-party integration.
Downloads
858
Maintainers
Readme
@toomanycooks/sdk
TypeScript SDK for the Too Many Cooks funding rates API.
Used internally by @toomanycooks/mcp-server and @toomanycooks/cli. Also stable as a public SDK for any third-party integration.
The dashboard lives at
toomanycooks.app; the API itself is hosted atapi.antoine-legrand.dev. The SDK targets the API host by default — override withTMC_API_BASE_URLif you need to point elsewhere.
Install
npm install @toomanycooks/sdkQuick start
import { TmcApiClient } from "@toomanycooks/sdk";
// Reads TMC_API_KEY from env automatically.
const client = new TmcApiClient();
const exchanges = await client.listExchanges();
const strategies = await client.findStrategies({ count: 10, periodDays: 7 });
console.log(strategies);Error handling
import { TmcApiClient, TmcAuthError, TmcQuotaError } from "@toomanycooks/sdk";
try {
await client.findStrategies({ count: 50 });
} catch (err) {
if (err instanceof TmcAuthError) {
// 401 — bad/revoked key
} else if (err instanceof TmcQuotaError) {
console.log(`Quota hit, resets at ${new Date(err.resetAt! * 1000)}`);
}
}API
| Method | What it returns |
|---|---|
| whoami() | Current key tier + quota |
| getPlans() | Public plan catalog (quotas, prices, limits) |
| listExchanges() | All supported DEX exchanges |
| getMarkets(exchange) | Latest funding rates for one exchange |
| getMarket(exchange, ticker) | Latest funding rate for one ticker on one exchange |
| getExchangeStatus(exchange) | Data-freshness signal for an exchange |
| getHistory(exchange, tickers, periodDays) | Historical funding-rate series |
| getAllMarkets(params) | Aggregated snapshot across exchanges (single call) |
| getMarketExtremes(params) | Top-N highest/lowest funding rates |
| listTickers(params) | Which tickers exist and on which exchanges |
| getTickerMarkets(ticker, params?) | Cross-exchange snapshot for one ticker + suggested arb |
| getTickersMarkets(tickers, params?) | Batch cross-exchange snapshot for many tickers (one call) |
| findStrategies(params) | Top delta-neutral arb opportunities |
| findStrategyForTicker(ticker, params?) | Best long/short pair for one ticker |
| simulateStrategy(params) | Project PnL for a delta-neutral pair |
| findSpotStrategies(params) | Spot-arbitrage (perp/spot) strategies |
| simulateSpotStrategy(params) | Project PnL for a spot/perp pair |
| getExecutionCostHistory(params) | Historical execution cost for one exchange/ticker (DB-backed) |
| getStrategyExecutionCostHistory(params) | Round-trip execution-cost history for a pair (DB-backed) |
| getFundingSpikes(params) | Cross-exchange z-score outliers |
| getStats() | Platform-level summary metrics |
| compareTickerAcrossExchanges(ticker, opts?) | Same ticker across exchanges, sorted by APR (1 call) |
See TypeScript types for the full schema.
Options
const client = new TmcApiClient({
apiKey: "...", // or TMC_API_KEY env
baseUrl: "https://...", // or TMC_API_BASE_URL env (https-only off-localhost)
timeoutMs: 30_000, // per-request timeout, 0 disables
userAgent: "my-app/1.0", // appended to "toomanycooks-sdk/<version>"
});
// All methods accept an optional final `RequestOptions` with an AbortSignal.
const ac = new AbortController();
setTimeout(() => ac.abort(), 5_000);
await client.findStrategies({ count: 10 }, { signal: ac.signal });compareTickerAcrossExchanges is a single server call (quota cost: 1) — it delegates to the getTickerMarkets endpoint and filters client-side. An optional exchanges list narrows the result:
await client.compareTickerAcrossExchanges("BTC", {
exchanges: ["hyperliquid", "lighter"],
});To compare several tickers at once, use the batch endpoint (also one call):
const rows = await client.getTickersMarkets(["BTC", "ETH", "SOL"]);License
MIT.
