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

# Orderbook

> Order book snapshots for a Polymarket token. Check liquidity depth and spread on sport markets before placing trades.

**Platform:** Polymarket\
**Endpoint:** `POST /v2/semantic/retrieve/parameterized`\
**Authentication:** Bearer token

## Example Request

```bash cURL theme={null}
curl --request POST \
  --url https://narrative.agent.heisenberg.so/api/v2/semantic/retrieve/parameterized \
  --header 'Authorization: Bearer YOUR_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "agent_id": 572,
  "params": {
    "token_id": "69435545313357346912686520645149775930858973121193492847015767460308803044235",
    "start_time": "1769902905868",
    "end_time": "1770034843377"
  },
  "pagination": {
    "limit": 10,
    "offset": 0
  },
  "formatter_config": {
    "format_type": "raw"
  }
}'
```

```python Python theme={null}
import requests

response = requests.post(
    "https://narrative.agent.heisenberg.so/api/v2/semantic/retrieve/parameterized",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    json={
    "agent_id": 572,
    "params": {
        "token_id": "69435545313357346912686520645149775930858973121193492847015767460308803044235",
        "start_time": "1769902905868",
        "end_time": "1770034843377"
    },
    "pagination": {
        "limit": 10,
        "offset": 0
    },
    "formatter_config": {
        "format_type": "raw"
    }
}
)

print(response.json())
```

```javascript JavaScript theme={null}
const response = await fetch("https://narrative.agent.heisenberg.so/api/v2/semantic/retrieve/parameterized", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
  "agent_id": 572,
  "params": {
    "token_id": "69435545313357346912686520645149775930858973121193492847015767460308803044235",
    "start_time": "1769902905868",
    "end_time": "1770034843377"
  },
  "pagination": {
    "limit": 10,
    "offset": 0
  },
  "formatter_config": {
    "format_type": "raw"
  }
})
});

const data = await response.json();
```

## Available filters

**token\_id** `String` *required*

Token ID of the market outcome to retrieve orderbook snapshots for.

**start\_time** `String`

Return snapshots at or after this Unix timestamp in milliseconds (as a string).

**end\_time** `String`

Return snapshots at or before this Unix timestamp in milliseconds (as a string).

## Example Response

```json theme={null}
{
  "timestamp": "",
  "params": {
    "token_id": "69435545313357346912686520645149775930858973121193492847015767460308803044235",
    "start_time": "1769902905868",
    "end_time": "1770034843377"
  },
  "pagination": {
    "limit": 50,
    "offset": 0,
    "has_more": false
  },
  "data": {
    "results": [
      {
        "token_id": "69435545313357346912686520645149775930858973121193492847015767460308803044235",
        "timestamp": "2026-04-10T18:00:00Z",
        "best_bid": "0.5750",
        "best_ask": "0.5850",
        "spread": "0.0100",
        "bid_depth": "125400.30",
        "ask_depth": "98200.15"
      }
    ]
  }
}
```

## Response Fields

| Field | Type | Description |
| - | - | - |
| `token_id` | String | Token ID |
| `timestamp` | String (ISO 8601) | Snapshot time |
| `best_bid` | String (Decimal) | Highest bid price |
| `best_ask` | String (Decimal) | Lowest ask price |
| `spread` | String (Decimal) | Bid-ask spread |
| `bid_depth` | String (Decimal) | Total bid side liquidity (USD) |
| `ask_depth` | String (Decimal) | Total ask side liquidity (USD) |

## Notes

> [!TIP]
>
> Wide spreads indicate illiquid markets — beware of slippage.

> [!TIP]
>
> Compare bid/ask depth to assess which side has more support.

> [!TIP]
>
> Track spread over time to detect liquidity drying up before game start


## OpenAPI

````yaml /api-reference/polymarket-orderbook.openapi.json POST /api/v2/semantic/retrieve/parameterized
openapi: 3.1.0
info:
  title: Falcon API — Orderbook
  version: 1.0.0
servers:
  - url: https://narrative.agent.heisenberg.so
    description: Production
security:
  - bearerAuth: []
paths:
  /api/v2/semantic/retrieve/parameterized:
    post:
      tags:
        - Polymarket
      summary: Orderbook
      description: Order book snapshots for a Polymarket token.
      operationId: polymarketOrderbook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PolymarketOrderbookRequest'
            examples:
              default:
                summary: Orderbook snapshots for a token
                value:
                  agent_id: 572
                  params:
                    token_id: >-
                      69435545313357346912686520645149775930858973121193492847015767460308803044235
                    start_time: '1769902905868'
                    end_time: '1770034843377'
                  pagination:
                    limit: 10
                    offset: 0
                  formatter_config:
                    format_type: raw
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolymarketOrderbookResponse'
        '400':
          description: Bad request — check params
        '401':
          description: Unauthorized — check your Bearer token
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl --request POST \
              --url https://narrative.agent.heisenberg.so/api/v2/semantic/retrieve/parameterized \
              --header 'Authorization: Bearer YOUR_TOKEN' \
              --header 'Content-Type: application/json' \
              --data '{
              "agent_id": 572,
              "params": {
                "token_id": "69435545313357346912686520645149775930858973121193492847015767460308803044235",
                "start_time": "1769902905868",
                "end_time": "1770034843377"
              },
              "pagination": { "limit": 10, "offset": 0 },
              "formatter_config": { "format_type": "raw" }
            }'
        - lang: python
          label: Python
          source: |-
            import requests

            response = requests.post(
                "https://narrative.agent.heisenberg.so/api/v2/semantic/retrieve/parameterized",
                headers={"Authorization": "Bearer YOUR_TOKEN"},
                json={
                    "agent_id": 572,
                    "params": {
                        "token_id": "69435545313357346912686520645149775930858973121193492847015767460308803044235",
                        "start_time": "1769902905868",
                        "end_time": "1770034843377",
                    },
                    "pagination": {"limit": 10, "offset": 0},
                    "formatter_config": {"format_type": "raw"},
                },
            )

            print(response.json())
        - lang: javascript
          label: JavaScript
          source: |-
            const response = await fetch(
              "https://narrative.agent.heisenberg.so/api/v2/semantic/retrieve/parameterized",
              {
                method: "POST",
                headers: {
                  Authorization: "Bearer YOUR_TOKEN",
                  "Content-Type": "application/json",
                },
                body: JSON.stringify({
                  agent_id: 572,
                  params: {
                    token_id: "69435545313357346912686520645149775930858973121193492847015767460308803044235",
                    start_time: "1769902905868",
                    end_time: "1770034843377",
                  },
                  pagination: { limit: 10, offset: 0 },
                  formatter_config: { format_type: "raw" },
                }),
              }
            );

            const data = await response.json();
components:
  schemas:
    PolymarketOrderbookRequest:
      type: object
      required:
        - params
      properties:
        agent_id:
          type: integer
          enum:
            - 572
          default: 572
          x-default: 572
          description: Orderbook agent ID.
        params:
          $ref: '#/components/schemas/PolymarketOrderbookParams'
        pagination:
          $ref: '#/components/schemas/PolymarketOrderbookPagination'
        formatter_config:
          $ref: '#/components/schemas/PolymarketOrderbookFormatterConfig'
    PolymarketOrderbookResponse:
      type: object
      readOnly: true
      properties:
        timestamp:
          type: string
          readOnly: true
        params:
          $ref: '#/components/schemas/PolymarketOrderbookResponseParams'
        pagination:
          type: object
          readOnly: true
          properties:
            limit:
              type: integer
              readOnly: true
            offset:
              type: integer
              readOnly: true
            has_more:
              type: boolean
              readOnly: true
        data:
          type: object
          readOnly: true
          properties:
            results:
              type: array
              readOnly: true
              items:
                $ref: '#/components/schemas/PolymarketOrderbookRecord'
        request_id:
          type: string
          readOnly: true
    PolymarketOrderbookParams:
      type: object
      description: Filter parameters. All values must be strings.
      additionalProperties: false
      required:
        - token_id
      properties:
        token_id:
          type: string
          description: Token ID of the market outcome.
        start_time:
          type: string
          description: >-
            Return snapshots at or after this Unix timestamp in milliseconds, as
            a string.
        end_time:
          type: string
          description: >-
            Return snapshots at or before this Unix timestamp in milliseconds,
            as a string.
    PolymarketOrderbookPagination:
      type: object
      properties:
        limit:
          type: integer
          minimum: 1
          maximum: 200
          default: 10
          description: Maximum number of records returned per request.
        offset:
          type: integer
          minimum: 0
          default: 0
          description: Number of records to skip before returning results.
    PolymarketOrderbookFormatterConfig:
      type: object
      properties:
        format_type:
          type: string
          enum:
            - raw
          default: raw
          description: Output format. Use "raw" for structured JSON.
    PolymarketOrderbookResponseParams:
      type: object
      readOnly: true
      properties:
        token_id:
          type: string
          readOnly: true
        start_time:
          type: string
          readOnly: true
        end_time:
          type: string
          readOnly: true
    PolymarketOrderbookRecord:
      type: object
      readOnly: true
      properties:
        token_id:
          type: string
          readOnly: true
          description: Token ID
        timestamp:
          type: string
          readOnly: true
          description: Snapshot time (ISO 8601)
        best_bid:
          type: string
          readOnly: true
          description: Highest bid price
        best_ask:
          type: string
          readOnly: true
          description: Lowest ask price
        spread:
          type: string
          readOnly: true
          description: Bid-ask spread
        bid_depth:
          type: string
          readOnly: true
          description: Total bid side liquidity (USD)
        ask_depth:
          type: string
          readOnly: true
          description: Total ask side liquidity (USD)
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Your Falcon API key from the dashboard

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.