Skip to main content

Overview

The Limitless Exchange Go SDK (limitless-exchange-go-sdk) is a fully typed Go client for interacting with both CLOB and NegRisk prediction markets. It provides:
  • Strongly typed structs for all API requests and responses
  • Automatic venue caching for EIP-712 order signing
  • Built-in retry logic with exponential backoff (using Go generics)
  • WebSocket streaming with auto-reconnect
  • Functional options pattern for flexible configuration
The SDK requires Go 1.22+. All I/O methods accept a context.Context as the first parameter and return error as the last return value, following standard Go conventions.

Installation

go get github.com/limitless-labs-group/limitless-exchange-go-sdk@v1.0.3

Quick Start

1

Initialize the HTTP client

package main

import (
    "context"
    "fmt"

    limitless "github.com/limitless-labs-group/limitless-exchange-go-sdk/limitless"
)

func main() {
    client := limitless.NewHttpClient() // loads LIMITLESS_API_KEY from env
}
2

Fetch active markets

func main() {
    client := limitless.NewHttpClient()
    marketFetcher := limitless.NewMarketFetcher(client)

    ctx := context.Background()
    result, err := marketFetcher.GetActiveMarkets(ctx, &limitless.ActiveMarketsParams{
        Limit: 10,
        Page:  1,
    })
    if err != nil {
        panic(err)
    }

    for _, m := range result.Data {
        fmt.Println(m.Title, m.Slug)
    }
}
3

Check your positions

func main() {
    client := limitless.NewHttpClient()
    portfolio := limitless.NewPortfolioFetcher(client)

    ctx := context.Background()
    positions, err := portfolio.GetPositions(ctx)
    if err != nil {
        panic(err)
    }

    for _, pos := range positions.CLOB {
        fmt.Println(pos.Market.Title)
    }
}

Authentication

The SDK authenticates using an API key passed via the X-API-Key header.
Never hardcode API keys in source code or commit them to version control. Use environment variables or a secrets manager.

Root Client

The recommended entrypoint is the root Client, which composes all domain services (markets, portfolio, orders, API tokens, partner accounts, delegated orders):
client := limitless.NewClient(
    limitless.WithAPIKey("lmts_your_key_here"),
)

// client.Markets, client.Portfolio, client.Pages,
// client.ApiTokens, client.PartnerAccounts, client.DelegatedOrders
For partner integrations using HMAC authentication:
client := limitless.NewClient(
    limitless.WithHMACCredentials(limitless.HMACCredentials{
        TokenID: "your-token-id",
        Secret:  "your-base64-secret",
    }),
)

HttpClient Options

The HttpClient uses the functional options pattern. Pass any combination of options to NewHttpClient() or NewClient():
OptionTypeDefaultDescription
WithBaseURL(url)stringhttps://api.limitless.exchangeAPI base URL
WithAPIKey(key)stringReads LIMITLESS_API_KEY envAPI key for authentication
WithHMACCredentials(creds)HMACCredentialsHMAC credentials for scoped API token auth (see Programmatic API)
WithTimeout(d)time.Duration30sHTTP request timeout
WithMaxIdleConns(n)int50Maximum idle connections in the pool
WithIdleConnTimeout(d)time.Duration60sHow long idle connections remain in the pool
WithTransport(t)http.RoundTripperDefault transportCustom HTTP transport
WithAdditionalHeaders(h)map[string]stringnilExtra headers merged into every request
WithLogger(l)LoggerNoOpLoggerLogger for request/response tracing
client := limitless.NewHttpClient(
    limitless.WithAPIKey("lmts_your_key_here"),
    limitless.WithTimeout(15 * time.Second),
    limitless.WithLogger(limitless.NewConsoleLogger(limitless.LogLevelDebug)),
)

Logging

The SDK provides a pluggable Logger interface with a built-in ConsoleLogger:
logger := limitless.NewConsoleLogger(limitless.LogLevelDebug)
client := limitless.NewHttpClient(limitless.WithLogger(logger))
LevelDescription
LogLevelDebugVerbose output including headers, venue cache operations, and raw payloads
LogLevelInfoGeneral operational messages
LogLevelWarnWarnings about potential issues
LogLevelErrorErrors only
Set LogLevelDebug during development to see request headers, venue cache hits/misses, and full API responses. Switch to LogLevelInfo or LogLevelWarn in production.

Source Code

The SDK is open source. Contributions and issue reports are welcome.

GitHub Repository

Browse the source, report issues, and contribute at github.com/limitless-labs-group/limitless-exchange-go-sdk

Disclaimer

USE AT YOUR OWN RISK. This SDK is provided as-is with no guarantees. You are solely responsible for any trading activity conducted through this software. Limitless Exchange is not available to users in the United States or other restricted jurisdictions. By using this SDK, you confirm compliance with all applicable local laws and regulations.

Next Steps

Markets

Discover markets, fetch orderbooks, and understand venue caching.

Market Pages

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

Trading & Orders

Place GTC and FOK orders, cancel orders, and manage token approvals.

Portfolio & Positions

Track your open positions and trading 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

Subscribe to real-time orderbook and price updates.

Error Handling & Retry

Retry logic, error types, and debugging strategies.