Skip to main content

Overview

This guide walks you through a complete Python implementation for trading on Limitless Exchange: authentication, fetching market data, building and signing orders with EIP-712, and submitting them via the REST API.

Prerequisites

1

Install dependencies

Install the required packages:
  • eth-account: EIP-712 signing and key management
  • requests: HTTP client for the REST API
  • web3: Address checksumming and utilities
2

Obtain credentials

  • Scoped API Token: Derive a token at limitless.exchange → profile menu → API Tokens → Derive. You get a token ID and a secret (base64-encoded). The secret is shown once — store it securely. See Authentication for the full flow.
  • Private Key: Your wallet’s private key for EIP-712 order signing. Never share or commit it.
Never share your private key. Store it in environment variables or a secure secrets manager. Do not hardcode it in source code or commit it to version control.

Authentication

Authenticated API requests (e.g. submitting orders) are signed with HMAC-SHA256 using your scoped API token. Each request carries three headers — lmts-api-key, lmts-timestamp, and lmts-signature — computed over a canonical message. See Authentication for the full reference.
Your private key is used only for EIP-712 order signing. The scoped API token (token ID + secret) handles request authentication. Both are required for trading. Public market data (browsing markets, orderbooks) needs no authentication.
The signed path must include the query string if present. The timestamp must be within 30 seconds of server time. For GET requests, the body is an empty string.

Fetching Market Data

Use GET /markets/:slug to retrieve market details, including venue addresses and position IDs. Cache this data per market; it is static.
tokens.yes is the YES token ID, tokens.no is the NO token ID. Use the appropriate one based on your order side and outcome.

Building Order Payloads

Orders require specific fields. Key values: USDC uses 6 decimals (1 USDC = 1,000,000 units). Shares are scaled by 1e6.
You pay USDC, receive shares. Use tokens.yes for YES, tokens.no for NO.
Example: BUY 10 YES shares at $0.65 → makerAmount = 6,500,000, takerAmount = 10,000,000

EIP-712 Signing

Sign orders using EIP-712 with the venue’s exchange address as verifyingContract.
See EIP-712 Order Signing for the full type definition and field reference.
All addresses must be checksummed (EIP-55). Use Web3.to_checksum_address().

Submitting Orders

Send the signed order to POST /orders:

Complete Working Example

ownerId is your profile ID. Obtain it from your first authenticated response (e.g. portfolio or auth endpoints) or from the Limitless UI. Set OWNER_ID in your environment.

Troubleshooting

1

401 Unauthorized

  • Verify LMTS_TOKEN_ID and LMTS_TOKEN_SECRET are set and the token is active in the Limitless UI.
  • Ensure lmts-timestamp is within 30 seconds of server time (check your clock).
  • Confirm the signed path matches the request path including any query string, and the signed body is the exact bytes you send.
2

400 Invalid order / signature mismatch

  • Verify verifyingContract is the market’s venue.exchange address.
  • Ensure all addresses are checksummed (EIP-55).
  • Confirm makerAmount and takerAmount use 1e6 scaling for USDC and shares.
3

Insufficient balance or allowance

  • Ensure you have enough USDC on Base for BUY orders.
  • Approve USDC to venue.exchange for BUY; Conditional Tokens to venue.exchange (and venue.adapter for NegRisk SELL) for SELL.
4

Wrong tokenId

Use tokens.yes for YES and tokens.no for NO. Double-check you are trading the correct outcome.

Next Steps

EIP-712 Signing

Full order type definition and field reference.

Venue System

Understanding venue contracts and token approvals.

API Reference

Complete endpoint documentation.

Authentication

Scoped API token setup and HMAC request signing.