> ## Documentation Index
> Fetch the complete documentation index at: https://docs.limitless.exchange/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Historical Prices

> Retrieve newest-first historical YES-price data for an exact market slug or all visible children of a group slug. Interval values are lookback presets, not custom date bounds.

<Note>
  Historical price data is **scoped to each market's lifespan**. Each market on
  Limitless is a distinct instance with a fixed start and end time, so this
  endpoint clips the selected lookback to market creation and the earlier of the
  market deadline or the current time.

  Short-lived markets (for example, hourly or 15-minute crypto markets) therefore
  return only a small window of history, typically no longer than the market's
  duration itself. To reconstruct a longer time series for a recurring product,
  query across the multiple markets that made up that period (each with its own
  slug).
</Note>

## Slug and response variants

Slug resolution checks for an exact market first, including a standalone CLOB market, an AMM market, or one child of a multi-outcome group. An exact market returns one object with `title`, `marketStatus`, and `prices`.

If no exact market matches, a visible group slug returns an array containing one object per visible child. Each series reports the group's status as `marketStatus`; child order is not guaranteed. A hidden group is treated as missing, while an exact hidden market slug is still resolved.

Every price point is `{ price, timestamp }`. `price` is a JSON number and `timestamp` is a decimal Unix epoch-millisecond string, such as `"1736944200000"`. Points within each series are newest first. A resolved CLOB series with retained history starts with its final payout price, timestamped one second after the newest retained point.

## Lookback presets

`interval` selects a lookback preset, not merely the spacing between points. It defaults to `1d`. The API does not accept custom `from` or `to` bounds.

| Preset |     Requested lookback | Normal live bucket | Bucket limit |
| ------ | ---------------------: | -----------------: | -----------: |
| `5m`   |              5 minutes |           1 minute |            5 |
| `1h`   |                 1 hour |           1 minute |           60 |
| `6h`   |                6 hours |          5 minutes |           72 |
| `1d`   |                  1 day |         15 minutes |           96 |
| `1w`   |                 1 week |         30 minutes |          336 |
| `1m`   |    30 days (one month) |            4 hours |          180 |
| `all`  | Entire market lifespan |           12 hours |        1,000 |

For a young live market, the service may use a finer preset so the returned series fits the market's age. Resolved CLOB markets use the finest retained bucket available for their lifespan. A live CLOB series may add its latest event after applying the bucket limit, and a resolved CLOB series may add its final payout point. These choices do not change the requested lookback boundary.

## Empty data and freshness

* A CLOB market with no retained price events returns `prices: []`.
* AMM buckets without trades use a `0.5` fallback, so an AMM no-data response contains synthesized points rather than an empty series.
* A visible group with no visible children returns `[]`.

Successful live responses are cacheable for 15 seconds for standalone CLOB, 30 seconds for NegRisk children and groups, and 60 seconds for AMM. Resolved responses are cacheable for 12 hours with a 30-minute stale-while-revalidate window. These HTTP cache boundaries do not guarantee data freshness; no freshness bound is promised.

## Errors

| Status | Meaning                                                                                                                                          |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `404`  | Neither an exact market nor a visible group has the slug. The response message is `No entity found`.                                             |
| `500`  | A historical-price or interval lookup failed unexpectedly. Unsupported interval values are not currently validated into a stable `400` contract. |


## OpenAPI

````yaml GET /markets/{slug}/historical-price
openapi: 3.0.0
info:
  title: Limitless Exchange API
  description: >-

    # Limitless Exchange Trading API


    *Production-ready API for prediction market trading, portfolio management,
    and market data*


    > 🎯 **Quick Navigation**: [Authentication](#tag/authentication) |
    [Markets](#tag/markets) | [Trading](#tag/trading) |
    [Portfolio](#tag/portfolio)


    ---
      


    ## 🚀 Quick Start


    Choose your preferred programming language for complete end-to-end
    implementation:


    ### Overview


    The Limitless Exchange API offers both REST and WebSocket integration:


    **REST API (Trading)**:

    1. **🔐 Authentication**: Use API key for all programmatic access

    2. **📊 Fetch Market Data**: Get market info including venue contract
    addresses (once per market)

    3. **📋 Order Creation**: Build and sign orders using EIP-712 structured
    data

    4. **🚀 Order Submission**: Submit signed orders and receive confirmations


    **WebSocket API (Real-Time Data)**:

    1. **🔌 Connection**: Connect to `/markets` namespace for real-time updates

    2. **📊 Subscriptions**: Subscribe to market prices and position changes

    3. **📡 Events**: Handle live market data and transaction updates


    ### 🔐 Authentication for API Users


    > **⚠️ DEPRECATION NOTICE**: Cookie-based session authentication is
    deprecated and will be removed within weeks. Please migrate to API keys
    immediately.


    | Method | Header | Status |

    |--------|--------|--------|

    | **API Key** | `X-API-Key: lmts_...` | ✅ Required for programmatic access |

    | Cookie Session | `Cookie: limitless_session=...` | ⚠️ Deprecated (removal
    imminent) |


    **Getting an API Key**


    API keys can only be created via the Limitless Exchange UI:

    1. Log in to [limitless.exchange](https://limitless.exchange) using your
    wallet

    2. Click your profile menu (top right)

    3. Select "Api keys"

    4. Generate a new key


    **Using Your API Key**


    Include in all requests via the `X-API-Key` header:


    ```bash

    # REST API

    curl -H "X-API-Key: lmts_your_key_here"
    https://api.limitless.exchange/markets


    # WebSocket - pass X-API-Key header during connection handshake

    ```


    ### Migration from Cookie to API Key


    If you're currently using cookie-based authentication, migrate by:


    1. **Generate an API key** via the UI (profile menu → Api keys)

    2. **Replace cookie header** with API key header:


    ```diff

    # Before (deprecated)

    - Cookie: limitless_session=your_session_token


    # After

    + X-API-Key: lmts_your_key_here

    ```


    3. **Remove session management code** - no more login flow or cookie
    handling needed


    ### Important: Venue System for CLOB Markets


    CLOB markets use a **venue system** where each market is associated with
    specific contract addresses. Before placing orders:


    1. **Fetch market data once**: `GET /markets/:slug` returns venue
    information

    2. **Use venue.exchange**: This is the `verifyingContract` for EIP-712 order
    signing

    3. **Cache the venue**: Venue data is static per market - fetch once and
    reuse


    **Sample venue response:**

    ```json

    {
      "venue": {
        "exchange": "0xA1b2C3...",
        "adapter": "0xD4e5F6..."
      }
    }

    ```


    ### Required Approvals


    Before trading, set up token approvals based on order type:


    | Order Type | Market Type | Approve To |

    |------------|-------------|------------|

    | BUY | All CLOB | USDC → `venue.exchange` |

    | SELL | Simple CLOB | CT → `venue.exchange` |

    | SELL | NegRisk/Grouped | CT → `venue.exchange` AND `venue.adapter` |


    ### Checksummed Addresses


    All addresses must use **checksummed format** (EIP-55 mixed-case):

    - Authentication: `x-account` header

    - Orders: `maker` and `signer` fields

    - Example: `0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed`


    ### Implementation Guides


    **[🐍 Python Quick Start](#description/-python-quick-start)**

    - REST API: eth-account, requests, and web3.py libraries

    - WebSocket: python-socketio, asyncio integration


    **[☕ Java Quick Start](#description/-java-quick-start)**  

    - REST API: Web3j, OkHttp3, and Jackson libraries


    **[📦 Node.js/TypeScript Quick
    Start](#description/-nodejs-typescript-quick-start)**

    - REST API: viem, ethers, and cross-fetch libraries

    - WebSocket: socket.io-client for real-time trading

    - Full TypeScript support with end-to-end examples


    **[🔌 WebSocket Integration](#description/-websocket-integration)**

    - Real-time market data and position updates

    - Production-ready Python client with authentication


    ---
      


    ## 🐍 Python Quick Start


    Complete end-to-end Python implementation for Limitless Exchange API
    integration.
      


    ### 🐍 Python E2E Order Creation Guide


    Complete Python implementation guide is being loaded from external
    documentation...


    **Guide Contents:**

    - 🔐 Complete authentication flow with eth-account

    - 📋 Order construction with Web3.py calculations

    - ✍️ EIP-712 structured data signing

    - 🚀 Order submission with requests library

    - ⚠️ Comprehensive error handling

    - 🛠️ Production deployment considerations


    *For the complete Python guide, ensure the file is available at
    docs/scripts-samples/python-e2e-order-creation.md*
        


    ## ☕ Java Quick Start


    Complete end-to-end Java implementation for Limitless Exchange API
    integration.
      


    ### ☕ Java E2E Order Creation Guide


    Complete Java enterprise implementation guide is being loaded from external
    documentation...


    **Guide Contents:**

    - 🔐 Complete authentication flow with Web3j

    - 📋 Order construction with BigInteger precision

    - ✍️ EIP-712 structured data signing

    - 🚀 Order submission with OkHttp3

    - ⚠️ Enterprise error handling patterns

    - 🏗️ Production Maven project structure


    *For the complete Java guide, ensure the file is available at
    docs/scripts-samples/java-e2e-order-creation.md*
        


    ## 📦 Node.js/TypeScript Quick Start


    Complete end-to-end Node.js/TypeScript implementation for trading and
    WebSocket subscriptions.
      


    ### 📦 Node.js/TypeScript Trading & WebSocket Guide


    Complete Node.js/TypeScript implementation guide is being loaded from
    external documentation...


    **Guide Contents:**

    - 🔐 **Authentication**: Wallet-based auth with ethers and viem

    - 📋 **Order Creation**: EIP-712 signing with viem WalletClient

    - 🚀 **Order Submission**: REST API integration with cross-fetch

    - 🔌 **WebSocket Subscriptions**: socket.io-client for real-time updates

    - 📊 **Market Data**: AMM prices and CLOB orderbook subscriptions

    - ⚠️ **Type Safety**: Full TypeScript support with proper types

    - 🛠️ **Production Ready**: Complete end-to-end working example


    **Key Features:**

    - **Combined Subscriptions**: Subscribe to both AMM and CLOB markets
    simultaneously

    - **Authentication Flow**: Complete wallet-based authentication with session
    management

    - **Trading Integration**: Place orders and receive real-time updates

    - **TypeScript First**: Type-safe implementation with proper interfaces


    *For the complete Node.js guide, ensure the file is available at
    docs/scripts-samples/node-socket-trading-and-subscribe.md*
        


    ## 🔌 WebSocket Integration


    Real-time market data and position updates using WebSocket connections.
      


    ### 🔌 WebSocket Real-Time Integration Guide


    Complete WebSocket implementation guide is being loaded from external
    documentation...


    **Guide Contents:**

    - 🔌 **WebSocket Connection**: python-socketio client with async support

    - 🔐 **Authentication**: JWT session cookie integration

    - 📊 **Market Subscriptions**: Real-time price updates and position changes

    - ⚡ **Event Handling**: Comprehensive event processing patterns

    - 🔄 **Auto-Reconnection**: Production-ready reconnection logic

    - 🛠️ **Error Recovery**: Robust error handling and fallback strategies


    **Key Features:**

    - **Public Mode**: Market price updates without authentication

    - **Authenticated Mode**: Full access to positions and transactions

    - **Multi-Market Support**: Subscribe to multiple markets simultaneously

    - **Production Ready**: Tested patterns for production deployment


    *For the complete WebSocket guide, ensure the file is available at
    docs/scripts-samples/python-socket-subscribe.md*
        
  version: '1.0'
  contact:
    name: API Support
    url: https://limitless.exchange
    email: hey@limitless.network
servers:
  - url: https://api.limitless.exchange
    description: Production API
security: []
tags:
  - name: Authentication
    description: User authentication and session management
  - name: Markets
    description: Browse, search, and analyze prediction markets
  - name: Market Navigation
    description: Navigation tree, market pages, and property filters
  - name: Trading
    description: Create, manage, and cancel orders
  - name: Portfolio
    description: Position tracking, trade history, and performance
  - name: Feed
    description: Public trading activity feeds
paths:
  /markets/{slug}/historical-price:
    get:
      tags:
        - Trading
      summary: Get Historical Prices
      description: >-
        Retrieve newest-first historical YES-price data for an exact market slug
        or all visible children of a group slug. Interval values are lookback
        presets, not custom date bounds.
      operationId: MarketOrderbookController_getHistoricalPrice
      parameters:
        - name: interval
          required: false
          in: query
          description: Lookback preset. `1m` means one month (30 days). Defaults to `1d`.
          schema:
            type: string
            default: 1d
            example: 1d
            enum:
              - 5m
              - 1h
              - 6h
              - 1d
              - 1w
              - 1m
              - all
        - name: slug
          required: true
          in: path
          description: Market slug identifier
          schema:
            example: presidential-election-2024
      responses:
        '200':
          description: >-
            One series for an exact market slug, or an array of visible child
            series for a group slug
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/HistoricalPriceSeries'
                  - type: array
                    description: >-
                      Visible child series for a group slug. Every series
                      reports the group status; child ordering is not
                      guaranteed.
                    items:
                      $ref: '#/components/schemas/HistoricalPriceSeries'
        '404':
          description: Neither an exact market nor a visible group has the slug
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NestErrorResponse'
        '500':
          description: Historical price lookup failed unexpectedly
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessageResponse'
components:
  schemas:
    HistoricalPriceSeries:
      type: object
      properties:
        title:
          type: string
          example: Will the event happen?
        prices:
          description: Newest-first YES prices.
          type: array
          items:
            $ref: '#/components/schemas/HistoricalPricePoint'
        marketStatus:
          type: string
          enum:
            - CREATED
            - DRAFTED
            - FUNDED
            - LOCKED
            - RESOLVED
          description: >-
            Exact market status for a single response, or group status for every
            series in a group response.
          example: FUNDED
      additionalProperties: false
      required:
        - title
        - prices
        - marketStatus
    NestErrorResponse:
      type: object
      properties:
        message:
          type: string
        error:
          type: string
        statusCode:
          type: integer
      additionalProperties: false
      required:
        - message
        - error
        - statusCode
    ErrorMessageResponse:
      type: object
      properties:
        message:
          type: string
      additionalProperties: false
      required:
        - message
    HistoricalPricePoint:
      type: object
      properties:
        price:
          type: number
          example: 0.75
        timestamp:
          type: string
          pattern: ^[0-9]+$
          description: Unix epoch milliseconds encoded as a decimal string.
          example: '1736944200000'
      additionalProperties: false
      required:
        - price
        - timestamp

````