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

# Fetch historical settled markets

> Fetch historical (settled) markets, filtered by query type (settlement date or event start date). Optionally filter by event. Pagination is by offset using the selected queryType timestamp (settledAt or eventExpectedStartTime) and id as the primary and secondary offsets. Fetch the initial page without any offsets set, and use returned _next_offset values iteratively until _next_offset is null, or _count is 0.



## OpenAPI

````yaml https://docs.api.monacoprotocol.xyz/api/v1/exchange-openapi-general.json get /markets/historical
openapi: 3.1.0
info:
  title: BetDEX General Integration API
  description: >-
    A RESTful API that allows you to interact with the BetDEX Exchange. Provides
    endpoints for managing Events, Markets, Sessions, Wallets and Orders. To
    interact with the API, a client must have an App Id and an API Key to
    authenticate and create a session.
  version: '0.1'
servers:
  - url: https://sandbox.api.btdx.io/
    description: Sandbox API Server
  - url: https://prod.api.btdx.io/
    description: Production API Server
security: []
tags:
  - name: API Key Management
  - name: App Management
  - name: Currencies
  - name: Event Categories
  - name: Event Groups
  - name: Event Subcategories
  - name: Events
  - name: External Reference Sources
  - name: Heartbeat Management
  - name: Market Prices
  - name: Market Types
  - name: Markets
  - name: Orders
  - name: Participants
  - name: Session Management
  - name: Status
  - name: Trades
  - name: Wallet API Key Management
  - name: Wallets
paths:
  /markets/historical:
    get:
      tags:
        - Markets
      summary: Fetch historical settled markets
      description: >-
        Fetch historical (settled) markets, filtered by query type (settlement
        date or event start date). Optionally filter by event. Pagination is by
        offset using the selected queryType timestamp (settledAt or
        eventExpectedStartTime) and id as the primary and secondary offsets.
        Fetch the initial page without any offsets set, and use returned
        _next_offset values iteratively until _next_offset is null, or _count is
        0.
      operationId: getMarketsHistorical
      parameters:
        - name: authorization
          in: header
          description: Header with the accessToken for the current session
          required: true
          schema:
            type: string
          example: Bearer eyJ0eXAiOiJ...bjV7AtDgA
        - name: queryType
          in: query
          required: true
          schema:
            type: string
            enum:
              - SettledDate
              - EventStartDate
        - name: from
          in: query
          description: beginning of the date range filter (inclusive)
          required: true
          schema:
            type: string
            format: date-time
        - name: to
          in: query
          description: end of the date range filter (inclusive)
          required: true
          schema:
            type: string
            format: date-time
        - name: eventId
          in: query
          description: optional event id to filter results by
          required: false
          schema:
            type: string
        - name: offset
          in: query
          description: Value to offset the current page request by (inclusive)
          schema:
            type: string
            format: date-time
        - name: secondaryOffset
          in: query
          description: >-
            Secondary offset value, i.e., if offset value is non-unique
            (exclusive)
          schema:
            type: integer
            format: int64
        - name: limit
          in: query
          description: Maximum number of elements to retrieve
          schema:
            type: integer
        - name: sort
          in: query
          description: |
            Sorting criteria in the format: asc|desc. "

            Default sort order is ascending.
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/OffsetPageMarketHistoricalResponse'
        '401':
          description: Session invalid
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/OffsetPageMarketHistoricalResponse'
components:
  schemas:
    OffsetPageMarketHistoricalResponse:
      type: object
      properties:
        _meta:
          $ref: '#/components/schemas/OffsetPageMetaInstantLong'
        documents:
          $ref: '#/components/schemas/MarketsHistoricalResponseDocuments'
    OffsetPageMetaInstantLong:
      type: object
      properties:
        _primary_document:
          type: string
          enum:
            - apiKeys
            - apps
            - categories
            - commissionRates
            - currencies
            - depositAddresses
            - depositRequests
            - events
            - eventGroups
            - externalReferences
            - externalReferenceSources
            - heartbeats
            - ids
            - markets
            - marketOutcomes
            - marketPositions
            - marketTypes
            - orders
            - participants
            - prices
            - priceLadders
            - sessions
            - statuses
            - subcategories
            - trades
            - transactions
            - wallets
            - walletMetrics
            - withdrawalRequests
        _count:
          type: integer
          format: int32
        _offset:
          $ref: '#/components/schemas/OffsetRequestInstantLong'
        _next_offset:
          $ref: '#/components/schemas/OffsetRequestInstantLong'
    MarketsHistoricalResponseDocuments:
      type: object
      properties:
        markets:
          type: array
          items:
            $ref: '#/components/schemas/MarketSettled'
        events:
          type: array
          items:
            $ref: '#/components/schemas/EventSummary'
        eventGroups:
          type: array
          items:
            $ref: '#/components/schemas/EventGroupSummary'
        subcategories:
          type: array
          items:
            $ref: '#/components/schemas/SubcategorySummary'
        categories:
          type: array
          items:
            $ref: '#/components/schemas/CategorySummary'
    OffsetRequestInstantLong:
      type: object
      properties:
        offset:
          type: string
          format: date-time
        secondaryOffset:
          type: integer
          format: int64
        limit:
          type: integer
          format: int32
        sort:
          type: string
          enum:
            - ASC
            - DESC
    MarketSettled:
      type: object
      properties:
        id:
          type: string
        ownerAppId:
          type: string
        event:
          $ref: '#/components/schemas/DocumentReference'
        name:
          type: string
        marketType:
          $ref: '#/components/schemas/DocumentReference'
        marketValue:
          type: string
        marketDiscriminator:
          type: string
        currencyId:
          type: string
        inPlayStatus:
          type: string
          enum:
            - NotApplicable
            - PrePlay
            - InPlay
        inPlayDelay:
          type: integer
          format: int32
        crossMatchingEnabled:
          type: boolean
        published:
          type: boolean
        suspended:
          type: boolean
        lockAt:
          type: string
          format: date-time
        settledAt:
          type: string
          format: date-time
        marketLockAction:
          type: string
          enum:
            - None
            - CancelUnmatchedLiquidity
        eventStartAction:
          type: string
          enum:
            - None
            - CancelUnmatchedLiquidity
        status:
          type: string
          enum:
            - Initializing
            - Open
            - Locking
            - Locked
            - Settling
            - Settled
            - Voiding
            - Voided
            - Closed
        marketOutcomes:
          $ref: '#/components/schemas/DocumentReference'
        createdAt:
          type: string
          format: date-time
        modifiedAt:
          type: string
          format: date-time
        eventExpectedStartTime:
          type: string
          format: date-time
    EventSummary:
      type: object
      properties:
        id:
          type: string
        eventGroup:
          $ref: '#/components/schemas/DocumentReference'
        name:
          type: string
        code:
          type: string
        expectedStartTime:
          type: string
          format: date-time
        active:
          type: boolean
    EventGroupSummary:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        subcategory:
          $ref: '#/components/schemas/DocumentReference'
    SubcategorySummary:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        category:
          $ref: '#/components/schemas/DocumentReference'
    CategorySummary:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
    DocumentReference:
      type: object
      properties:
        _ref:
          type: string
        _ids:
          type: array
          items:
            type: string

````