Build
TypeScript SDK
@meridian/sdk — a typed fetch client generated from the same schemas the API validates against. Zero dependencies beyond zod.
Install
terminal
npm install @meridian/sdkInitialize
client.ts
import { MeridianClient } from "@meridian/sdk";
const client = new MeridianClient({
apiKey: process.env.MERIDIAN_API_KEY!,
baseUrl: process.env.MERIDIAN_API_URL, // defaults to https://api.meridian.trade
timeout: 30_000, // ms, default
});Runtime-validated, both directions
Every request and response is validated against the shared Zod schema at runtime. A response that fails validation throws a typed MeridianValidationError with field-level detail instead of returning malformed data silently.Namespaces
| Namespace | Methods |
|---|---|
| client.markets | search(), get(id), orderbook(tokenId) |
| client.orders | intent(params), submitSigned(params), cancel(id) |
| client.portfolio | orders(), fills(), positions(), summary() |
| client.agents | create(params), kill(id), submitCredentials(id, params) |
| client.policies | get(), update(params), resetBreaker(agentId) |
| client.billing | usage() |
Example: search, then place an order
example.ts
const markets = await client.markets.search({ query: "BTC" });
const market = markets[0];
const { risk_decision, payload } = await client.orders.intent({
market_id: market.id,
token_id: market.token_ids[0],
side: "buy",
type: "limit",
size_usdc: 100,
price: 0.55,
});
if (!risk_decision.approved) {
throw new Error(risk_decision.failures.map((f) => f.code).join(", "));
}Retry behavior
GET requests retry automatically — up to 3 times with exponential backoff — on network errors or 5xx responses. Non-idempotent requests (POST, PUT, DELETE) are never retried automatically, since retrying an order submission could double-submit.
Distribution
Published as both ESM and CJS builds via tsup, so it works from Node, Bun, Deno (via npm specifier), and bundlers without configuration. See API reference for the underlying endpoints each method calls.