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

# Order history

> Returns the raw mt5rest history payload for the given date range.
Closed positions are returned as a list of `Deal` entries inside
`data.internalDeals` — each deal is one execution leg (entry or
exit), linked to its position via `positionTicket`.

To reconstruct full closed trades, pair In/Out deals by
`positionTicket` client-side, or call
`GET /accounts/{id}/positions/{ticket}/fills` for a single position
to fetch both legs in one call.




## OpenAPI

````yaml /openapi-spec/easierprop.yaml get /api/accounts/{id}/orders/history
openapi: 3.0.3
info:
  title: Easier Prop REST API
  version: 2.1.0
  description: >
    MT5 Trading Infrastructure API. Manage multiple broker accounts, execute
    trades, stream market data, and administer API keys, usage snapshots, and
    billing terms.


    **Client API** endpoints live under `/api` and require an `X-API-Key`
    header.

    **Admin API** endpoints live under `/admin` and accept either a JWT
    `Authorization: Bearer <jwt>` (obtained via `/admin/login`) or the same
    `X-API-Key` header used by client endpoints.


    Admin user provisioning is read-only via REST: `GET /admin/admins` lists
    admins, but creation, update, and deletion are performed out-of-band (DB /
    ops tooling). Bootstrap a brand-new deployment with `POST /admin/seed` while
    no superadmin exists.
servers:
  - url: https://api.easierprop.com
    description: Production
security: []
tags:
  - name: Admin
    description: Authentication, API key management, and admin user CRUD
  - name: Accounts
    description: Register and manage MT5 broker accounts
  - name: Sessions
    description: Control broker connections
  - name: Trading
    description: Place, modify, and close orders
  - name: Account Info
    description: Balance, equity, margin, and statistics
  - name: Market Data
    description: Symbols, quotes, OHLC history, and trade sessions
  - name: Expert Advisors
    description: Upload, run, stop, and monitor MQL5 Expert Advisors on your accounts
  - name: Enhanced
    description: >-
      Portfolio, risk, performance, copy-trade, hedge, breakeven, close-all, lot
      calculator, and position details
  - name: Extended
    description: >-
      Change password, server timezone, symbol sessions, closed positions,
      mails, tick value, equity stats, and more
paths:
  /api/accounts/{id}/orders/history:
    parameters:
      - $ref: '#/components/parameters/accountId'
      - name: from
        in: query
        required: true
        schema:
          type: string
        description: |
          Start datetime in `YYYY-MM-DDTHH:mm:ss` (broker timezone).
          ISO-8601 inputs from `Date.toISOString()` (with trailing `.SSSZ`)
          are accepted — the gateway normalizes them. Malformed values
          return `400 INVALID_REQUEST` instead of an empty result.
        example: '2026-01-01T00:00:00'
      - name: to
        in: query
        required: true
        schema:
          type: string
        description: >-
          End datetime (`YYYY-MM-DDTHH:mm:ss`). Same normalization rules as
          `from`.
        example: '2026-04-01T23:59:59'
    get:
      tags:
        - Trading
      summary: Order history
      description: |
        Returns the raw mt5rest history payload for the given date range.
        Closed positions are returned as a list of `Deal` entries inside
        `data.internalDeals` — each deal is one execution leg (entry or
        exit), linked to its position via `positionTicket`.

        To reconstruct full closed trades, pair In/Out deals by
        `positionTicket` client-side, or call
        `GET /accounts/{id}/positions/{ticket}/fills` for a single position
        to fetch both legs in one call.
      operationId: orderHistory
      responses:
        '200':
          description: Order history payload
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/OrderHistoryResult'
        '400':
          description: Invalid date format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyHeader: []
components:
  parameters:
    accountId:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Account ID
  schemas:
    OrderHistoryResult:
      type: object
      description: |
        Raw mt5rest history payload. Closed positions are not pre-paired —
        `internalDeals` contains one entry per execution leg (entry/exit).
        Pair by `positionTicket` to reconstruct trades, or call
        `/positions/{ticket}/fills` for a specific position.
      properties:
        action:
          type: integer
          description: mt5rest action code (informational; typically 0).
          example: 0
        internalDeals:
          type: array
          items:
            $ref: '#/components/schemas/Deal'
    Error:
      type: object
      properties:
        ok:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
              example: ACCOUNT_NOT_FOUND
            message:
              type: string
              example: Account not found
    Deal:
      type: object
      description: |
        A single execution leg as recorded by MT5. Each closed position is
        represented by an "In" deal (opening) and an "Out" deal (closing),
        linked by `positionTicket`. Pair them client-side to reconstruct
        the full trade, or use `/positions/{ticket}/fills` to fetch both
        legs for a known position in one call.
      properties:
        ticket:
          type: integer
          format: int64
          example: 12345678
        positionTicket:
          type: integer
          format: int64
          description: >-
            Ticket of the position this deal belongs to. Use this to pair In/Out
            deals.
          example: 87654321
        type:
          type: string
          description: >-
            Deal direction. `DealBuy` and `DealSell` are the live legs;
            `DealBalance` is a balance op.
          enum:
            - DealBuy
            - DealSell
            - DealBalance
            - DealCredit
            - DealCorrection
            - DealBonus
            - DealCharge
          example: DealBuy
        entry:
          type: string
          description: Whether this deal opened, closed, or modified a position.
          enum:
            - DealEntryIn
            - DealEntryOut
            - DealEntryInOut
            - DealEntryOutBy
          example: DealEntryIn
        symbol:
          type: string
          example: EURUSD
        lots:
          type: number
          example: 0.01
        openPrice:
          type: number
          description: Execution price of this deal.
          example: 1.08542
        profit:
          type: number
          example: 3.2
        swap:
          type: number
          example: 0
        commission:
          type: number
          example: -0.07
        fee:
          type: number
          example: 0
        comment:
          type: string
          example: ''
        time:
          type: string
          description: Deal execution time in `YYYY-MM-DDTHH:mm:ss` (broker timezone).
          example: '2026-04-01T12:00:00'
        timestampUTC:
          type: integer
          format: int64
          example: 1711972800
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        Client API key (prefixed with `sk_`). On `/api/*` endpoints the key
        is scoped to its own MT5 accounts. On `/admin/*` endpoints the key
        identifies its **owning admin** and grants access to all of that
        admin's keys — so any of your `sk_` works to manage any of your
        other keys (cross-admin operations are rejected as `400 Key not
        found`).

````