@parlayx/sdk
Official TypeScript client for the ParlayX public API, a single trading interface over aggregated prediction markets.
Documentation
Full guides, authentication, and API reference live at docs.parlayx.com.
Install
npm install @parlayx/sdk
Requires Node.js 20 or newer. Requests are signed with Ed25519 via node:crypto,
so the client does not run in browsers or edge runtimes.
Usage
Requests are signed with your Ed25519 key. Pass the key id and the private key
seed; the client signs every request for you.
import { createClient } from "@parlayx/sdk";
const client = createClient({
keyId: process.env.PARLAYX_KEY_ID!,
privateKeyHex: process.env.PARLAYX_PRIVATE_KEY_HEX!,
});
const { podId } = await client.whoami();
const { competitions } = await client.listCompetitions({ sport: "spt_baseball" });
const { events } = await client.listEvents({ competitionId: competitions[0].id });
const { orderId } = await client.kalshi.submitOrder({
ticker: "KXMLBGAME-26SEP01-NYY",
side: "BID",
count: "10",
price: "0.45",
timeInForce: { type: "GTC" },
});
Venue methods live under client.polymarket and client.kalshi.
Connections
Create one client when your process starts and reuse it.
On Node you can also have it hold the connection to the API open between
requests, so one sent after a few seconds of quiet does not pay for a new TLS
handshake:
import { createClient } from "@parlayx/sdk";
const client = createClient({
keyId: process.env.PARLAYX_KEY_ID!,
privateKeyHex: process.env.PARLAYX_PRIVATE_KEY_HEX!,
keepAliveConnections: true,
});
Leave it off if your process configures its own transport with
setGlobalDispatcher, a proxy or custom TLS. The option sends through a
connection pool of its own, which would bypass that. Set keepAliveTimeout on
your own agent instead.
An idle connection does not hold your process open, so a script exits when it is
done either way. To release the sockets deliberately at shutdown:
import { closeKeepAlive } from "@parlayx/sdk";
await closeKeepAlive();
Supplying your own fetch replaces the one that holds the connection. To keep
both, compose it:
import { createClient, keepAliveFetch } from "@parlayx/sdk";
const inner = (await keepAliveFetch()) ?? globalThis.fetch;
const client = createClient({
keyId: process.env.PARLAYX_KEY_ID!,
privateKeyHex: process.env.PARLAYX_PRIVATE_KEY_HEX!,
fetch: (input, init) => inner(input, init),
});
License
MIT. See LICENSE.