Skip to main content

Overview

The Limitless Exchange TypeScript SDK provides a type-safe client for interacting with both CLOB and NegRisk prediction markets. It handles authentication, EIP-712 order signing, market data fetching, portfolio tracking, and real-time WebSocket streaming out of the box.
Source code and issue tracker are available on GitHub.

Installation

npm install @limitless-exchange/sdk

Quick Start

1

Configure environment variables

Create a .env file in your project root (and add it to .gitignore):
LIMITLESS_API_KEY=lmts_your_api_key_here
PRIVATE_KEY=0xYourPrivateKeyHere
# Partner/programmatic mode (HMAC)
LMTS_TOKEN_ID=your_token_id
LMTS_TOKEN_SECRET=your_base64_secret
The SDK automatically reads LIMITLESS_API_KEY from the environment if no apiKey is passed to the constructor.
2

Initialize the HTTP client

import { HttpClient } from '@limitless-exchange/sdk';

const httpClient = new HttpClient({
  baseURL: 'https://api.limitless.exchange',
});
3

Fetch active markets

import { MarketFetcher } from '@limitless-exchange/sdk';

const marketFetcher = new MarketFetcher(httpClient);

const markets = await marketFetcher.getActiveMarkets({
  limit: 10,
  sortBy: 'newest',
});

for (const market of markets) {
  console.log(market.slug, market.title);
}
4

Authenticate for trading

For operations that require authentication (placing orders, fetching portfolio), supply your API key and wallet:
import { ethers } from 'ethers';

const httpClient = new HttpClient({
  baseURL: 'https://api.limitless.exchange',
  apiKey: process.env.LIMITLESS_API_KEY,
});

const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!);

Environment Variables

VariableRequiredDescription
LIMITLESS_API_KEYLegacy auth onlyDeprecated API key value, auto-loaded by the SDK.
LMTS_TOKEN_IDPartner/programmatic modeScoped token ID used for HMAC request signing.
LMTS_TOKEN_SECRETPartner/programmatic modeBase64 token secret used for HMAC request signing.
PRIVATE_KEYFor order signingEthereum private key used for EIP-712 order signatures. Never commit to version control.

Client constructor

The recommended entrypoint is the root Client class, which composes all domain services (markets, portfolio, orders, API tokens, partner accounts, delegated orders):
import { Client } from '@limitless-exchange/sdk';

const client = new Client({
  baseURL: 'https://api.limitless.exchange',
  apiKey: 'lmts_...',
});
For partner integrations using HMAC authentication:
const client = new Client({
  baseURL: 'https://api.limitless.exchange',
  hmacCredentials: {
    tokenId: process.env.LMTS_TOKEN_ID!,
    secret: process.env.LMTS_TOKEN_SECRET!,
  },
});
With hmacCredentials set, the SDK automatically generates and sends lmts-api-key, lmts-timestamp, and lmts-signature on each request. Do not manually build HMAC headers when using the SDK client.
OptionTypeDefaultDescription
baseURLstringAPI base URL
apiKeystringprocess.env.LIMITLESS_API_KEYLegacy API key authentication
hmacCredentials{ tokenId, secret }HMAC credentials for scoped API token auth (see Programmatic API)
timeoutnumber30000Request timeout in milliseconds
additionalHeadersRecord<string, string>{}Additional headers sent with every request

HttpClient (lower-level)

You can also use HttpClient directly for more control:
import { HttpClient } from '@limitless-exchange/sdk';

const httpClient = new HttpClient({
  baseURL: 'https://api.limitless.exchange',
  apiKey: 'lmts_...',
});

What You Can Build

Markets

Discover markets, fetch orderbooks, and query NegRisk groups.

Market Pages

Browse markets by category with navigation, filters, and pagination.

Trading and Orders

Create GTC and FOK orders, manage approvals, and cancel orders.

Portfolio and Positions

Track CLOB and AMM positions, PnL, and trade history.

API Tokens

Derive, list, and revoke scoped HMAC tokens for partner integrations.

Partner Accounts

Create sub-accounts with server wallets or EOA verification.

Delegated Orders

Place orders on behalf of sub-accounts with server-side signing.

WebSocket Streaming

Real-time orderbook, price, position, and transaction events.

Server Wallet Redemption and Withdrawal

For partner server-wallet sub-accounts, the SDK now provides helper methods for payout settlement and treasury movement (v1.0.6+): Required scopes for apiToken auth: trading for redeem and withdrawal for withdraw. See the full flow and scope guidance in Programmatic API.

Disclaimer

USE AT YOUR OWN RISK. This SDK and the Limitless Exchange protocol are provided as-is with no warranties. You are solely responsible for any funds used or lost. By using this SDK, you acknowledge that prediction markets involve financial risk. The Limitless Exchange is not available to users in the United States or other restricted jurisdictions. Ensure compliance with your local laws before trading.