ParallaxDevelopers

Quickstart

Your first read and order against the live Parallax API with the TypeScript SDK, in about ten minutes.

This gets you from zero to a placed order using @parallax/sdk-ts. Every step is real — there is no sandbox yet (it's planned), so orders.create mutates the live exchange.

1. Install

pnpm add @parallax/sdk-ts

2. Create a client

Today auth is a WorkOS human session token (machine credentials are planned). The token getter is mechanism-agnostic, so the same code carries a machine token when that lands.

import { createParallaxClient } from "@parallax/sdk-ts";

const client = createParallaxClient({
  baseUrl: "https://api.parallax.markets/v1",
  getToken: () => mySession.accessToken, // a WorkOS AuthKit session token
});

No headless credential yet? See the interim auth recipe for hitting the read endpoints with a session bearer.

3. Read a market and its pool

const meta = await client.meta.get(); // PAR, price scale, currencies — never hardcode these
const { data: markets } = await client.markets.list({ phase: "Open", limit: 5 });
const pool = await client.markets.pool(markets[0].market_id);
// `pool.indicative_price` is the IEP — indicative, Open-only, NON-binding. The uniform price is fixed at CLEAR.

4. Place an order

The leg you fund is your side — there is no buy/sell field. demand_amount is minor-unit money; derive it from a major amount with the helper rather than hardcoding the scale.

import { majorToMinor } from "@parallax/sdk-ts";

const order = await client.orders.create({
  market_id: markets[0].market_id,
  leg_id: markets[0] /* a leg id from markets.get(...) */ && "YES",
  demand_amount: majorToMinor("100"), // "1000000" at PAR=10000
  limit_price: 60, // optional max uniform clearing price (0..100); omit to take any
  client_order_id: "my-oms-ref-001", // your own audit handle, echoed back verbatim
});
// order.order_id is the real on-ledger DemandOrder id; order.as_of_offset pins ledger time.

POST /orders is a real, money-bearing write on the live exchange. The SDK auto-supplies an Idempotency-Key; a missing key elsewhere returns an undocumented 400 (a known quirk — see Reliability).

5. Read-your-writes

There is no server-side as_of parameter, so consistency is best-effort client polling: thread the write's as_of_offset into the next read.

import { readYourWrites } from "@parallax/sdk-ts";

const freshPool = await readYourWrites(order, () => client.markets.pool(markets[0].market_id));

Next

On this page