> ## Documentation Index
> Fetch the complete documentation index at: https://pmxt-sync-hosted-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch OHLCV

> Fetch historical OHLCV (candlestick) price data for a specific market outcome.

<Info>
  **Hosted and self-hosted data depth** — Hosted `api.pmxt.dev` calls require a PMXT API key. If you omit the key, SDK calls route through your local `pmxt-core` process and use venue-native APIs. `fetchOHLCV` returns normalized `PriceCandle` rows for venues whose implementation supports `fetchOHLCV`; history length, volume, and rate limits remain venue-specific. Check [Feature Support & Compliance](https://github.com/pmxt-dev/pmxt/blob/main/core/COMPLIANCE.md) for the current matrix. [Get your API key](https://pmxt.dev/dashboard).
</Info>

## Use cases

### Get hourly candles for a market

<CodeGroup>
  ```python Python theme={null}
  import pmxt

  # Hosted route: include pmxt_api_key. Omit it for self-hosted/local pmxt-core.
  api = pmxt.Polymarket(pmxt_api_key="YOUR_PMXT_API_KEY")
  market = api.fetch_market(slug="will-alexandria-ocasio-cortez-win-the-2028-us-presidential-election")

  candles = api.fetch_ohlcv(market.yes, resolution="1h", limit=100)
  for c in candles:
      print(f"{c.open:.2f}  {c.high:.2f}  {c.low:.2f}  {c.close:.2f}  V:{c.volume}")
  ```

  ```javascript JavaScript theme={null}
  import { Polymarket } from "pmxtjs";

  // Hosted route: include pmxtApiKey. Omit it for self-hosted/local pmxt-core.
  const api = new Polymarket({ pmxtApiKey: "YOUR_PMXT_API_KEY" });
  const market = await api.fetchMarket({ slug: "will-alexandria-ocasio-cortez-win-the-2028-us-presidential-election" });

  const candles = await api.fetchOHLCV(market.yes, { resolution: "1h", limit: 100 });
  candles.forEach((c) => console.log(`${c.open}  ${c.high}  ${c.low}  ${c.close}  V:${c.volume}`));
  ```

  ```bash curl theme={null}
  # First get the outcome ID from a market, then pass it as the outcomeId parameter
  curl "https://api.pmxt.dev/api/polymarket/fetchOHLCV?outcomeId=YOUR_OUTCOME_ID&resolution=1h&limit=100" \
    -H "Authorization: Bearer $PMXT_API_KEY"
  ```
</CodeGroup>


## OpenAPI

````yaml GET /api/{exchange}/fetchOHLCV
openapi: 3.0.0
info:
  title: PMXT Hosted API
  description: >-
    One API for supported prediction markets. Hosted catalog search in under
    10ms, a unified schema for supported venues, and venue-native trading where
    venues expose writes.
  version: 2.51.4
servers:
  - url: https://api.pmxt.dev
    description: Hosted PMXT (production)
security: []
tags:
  - name: Hosted
    description: >-
      Requires a PMXT API key. These endpoints use the cross-venue catalog and
      have no local equivalent.
  - name: Local Only
    description: >-
      Executed locally by the SDK against the venue. Never proxied through PMXT
      servers.
  - name: Data Feeds
    description: >-
      Auxiliary price and oracle data feeds (Binance, Chainlink).
      CCXT-compatible method names and response shapes.
paths:
  /api/{exchange}/fetchOHLCV:
    get:
      summary: Fetch OHLCV
      description: >-
        Fetch historical OHLCV (candlestick) price data for a specific market
        outcome.
      operationId: fetchOHLCV
      parameters:
        - $ref: '#/components/parameters/ExchangeParam'
        - in: query
          name: outcomeId
          required: true
          schema:
            type: string
        - in: query
          name: resolution
          required: false
          schema:
            type: string
          description: Required for candle aggregation
        - in: query
          name: start
          required: false
          schema:
            type: string
            format: date-time
          description: Start of the time range
        - in: query
          name: end
          required: false
          schema:
            type: string
            format: date-time
          description: End of the time range
        - in: query
          name: limit
          required: false
          schema:
            type: number
          description: Maximum number of results to return
      responses:
        '200':
          description: Fetch OHLCV response
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/BaseResponse'
                  - type: object
                    properties:
                      data:
                        type: array
                        items:
                          $ref: '#/components/schemas/PriceCandle'
      security: []
      x-codeSamples:
        - lang: python
          label: Polymarket
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Polymarket(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Limitless
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Limitless(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Kalshi
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Kalshi(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: KalshiDemo
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.KalshiDemo(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Probable
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Probable(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Baozi
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Baozi(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Myriad
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Myriad(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Opinion
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Opinion(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Metaculus
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Metaculus(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Smarkets
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Smarkets(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: PolymarketUS
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.PolymarketUS(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Hyperliquid
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Hyperliquid(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: GeminiTitan
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.GeminiTitan(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: SuiBets
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.SuiBets(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Rain
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Rain(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: python
          label: Hunch
          source: |-
            import pmxt
            from datetime import datetime, timezone

            # API key optional — enables faster catalog-backed lookups
            exchange = pmxt.Hunch(
                pmxt_api_key="YOUR_PMXT_API_KEY",
            )
            result = exchange.fetch_ohlcv(
                "67890",
                resolution="1h",
                start=datetime(2026, 1, 1, tzinfo=timezone.utc),
                end=datetime(2026, 1, 31, tzinfo=timezone.utc),
                limit=10,
            )
        - lang: javascript
          label: Polymarket
          source: |-
            import { Polymarket } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Polymarket({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Limitless
          source: |-
            import { Limitless } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Limitless({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Kalshi
          source: |-
            import { Kalshi } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Kalshi({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: KalshiDemo
          source: |-
            import { KalshiDemo } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new KalshiDemo({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Probable
          source: |-
            import { Probable } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Probable({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Baozi
          source: |-
            import { Baozi } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Baozi({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Myriad
          source: |-
            import { Myriad } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Myriad({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Opinion
          source: |-
            import { Opinion } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Opinion({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Metaculus
          source: |-
            import { Metaculus } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Metaculus({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Smarkets
          source: |-
            import { Smarkets } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Smarkets({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: PolymarketUS
          source: |-
            import { PolymarketUS } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new PolymarketUS({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Hyperliquid
          source: |-
            import { Hyperliquid } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Hyperliquid({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: GeminiTitan
          source: |-
            import { GeminiTitan } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new GeminiTitan({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: SuiBets
          source: |-
            import { SuiBets } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new SuiBets({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Rain
          source: |-
            import { Rain } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Rain({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
        - lang: javascript
          label: Hunch
          source: |-
            import { Hunch } from "pmxtjs";

            // API key optional — enables faster catalog-backed lookups
            const exchange = new Hunch({
              pmxtApiKey: "YOUR_PMXT_API_KEY",
            });
            const result = await exchange.fetchOHLCV(
              "67890",
              {
                resolution: "1h",
                start: new Date("2026-01-01T00:00:00Z"),
                end: new Date("2026-01-31T00:00:00Z"),
                limit: 10,
              },
            );
components:
  parameters:
    ExchangeParam:
      in: path
      name: exchange
      schema:
        type: string
        enum:
          - polymarket
          - kalshi
          - kalshi-demo
          - limitless
          - probable
          - baozi
          - myriad
          - opinion
          - metaculus
          - smarkets
          - polymarket_us
          - gemini-titan
          - hyperliquid
          - suibets
          - rain
          - hunch
          - router
      required: true
      description: The prediction market exchange to target.
  schemas:
    BaseResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        error:
          $ref: '#/components/schemas/ErrorDetail'
    PriceCandle:
      type: object
      properties:
        timestamp:
          type: number
          description: Unix timestamp in milliseconds marking the start of the candle.
        open:
          type: number
          description: Opening price for the interval (probability between 0.0 and 1.0).
        high:
          type: number
          description: Highest price during the interval (probability between 0.0 and 1.0).
        low:
          type: number
          description: Lowest price during the interval (probability between 0.0 and 1.0).
        close:
          type: number
          description: Closing price for the interval (probability between 0.0 and 1.0).
        volume:
          type: number
          description: Trading volume during the interval.
      required:
        - timestamp
        - open
        - high
        - low
        - close
    ErrorDetail:
      type: object
      description: >-
        Structured error envelope returned inside `BaseResponse.error` and
        `ErrorResponse.error`. Hosted-mode endpoints populate `code`,
        `retryable`, and optionally `exchange` / `detail`; legacy local-mode
        endpoints may still return only `message`.
      properties:
        message:
          type: string
          description: Human-readable error message.
        code:
          type: string
          description: >-
            Stable machine-readable error code. Hosted-mode errors use the
            `HostedTradingError` family (e.g. `INSUFFICIENT_ESCROW_BALANCE`,
            `BUILT_ORDER_EXPIRED`); pre-hosted local errors use the legacy
            family (e.g. `BAD_REQUEST`, `NOT_FOUND`).
          enum:
            - HOSTED_TRADING_ERROR
            - INSUFFICIENT_ESCROW_BALANCE
            - ORDER_SIZE_TOO_SMALL
            - INVALID_API_KEY
            - OUTCOME_NOT_FOUND
            - CATALOG_UNAVAILABLE
            - BUILT_ORDER_EXPIRED
            - INVALID_SIGNATURE
            - NO_LIQUIDITY
            - MISSING_WALLET_ADDRESS
            - BAD_REQUEST
            - AUTHENTICATION_ERROR
            - PERMISSION_DENIED
            - NOT_FOUND
            - ORDER_NOT_FOUND
            - MARKET_NOT_FOUND
            - EVENT_NOT_FOUND
            - RATE_LIMIT_EXCEEDED
            - INVALID_ORDER
            - INSUFFICIENT_FUNDS
            - VALIDATION_ERROR
            - NETWORK_ERROR
            - EXCHANGE_NOT_AVAILABLE
            - NOT_SUPPORTED
        retryable:
          type: boolean
          description: >-
            Hint for clients: when `true`, the same request may succeed on retry
            (e.g. transient network or rate-limit conditions); when `false`, the
            caller should not retry without modifying the request.
        exchange:
          type: string
          nullable: true
          description: >-
            Venue the error originated from, when known (e.g. 'polymarket',
            'kalshi').
        detail:
          type: object
          additionalProperties: {}
          nullable: true
          description: >-
            Free-form hosted-mode detail blob. Shape depends on `code` — e.g.
            for `INSUFFICIENT_ESCROW_BALANCE` it may include `{ requested,
            available }`; for `ORDER_SIZE_TOO_SMALL` it may include `{ min }`;
            for `BUILT_ORDER_EXPIRED` it may include `{ expiry }`.

````