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

# Get OHLCV candles

> Returns historical OHLCV candles via `mt5.copy_rates_from_pos()`. Candle `time` is broker server time — the bot normalises to UTC using the detected offset from `/time`. `spread` is in raw points (e.g. 1400 pts × $0.01 = $14.00 for BTCUSD on RoboForex).



## OpenAPI

````yaml https://terminal-api.novosky.tech/roboforex/main/openapi.json get /symbols/{symbol}/rates
openapi: 3.0.3
info:
  description: >-
    Self-hosted HTTP REST API bridging the NOVOSKY trading bot to a MetaTrader 5
    terminal. All bot-to-broker communication goes through this service.
    Authentication is required on all endpoints except `GET /ping`.
  title: MT5 HEADLESS
  version: 1.0.0
servers:
  - url: /
security:
  - bearerAuth: []
tags:
  - description: Health, latency, and error diagnostics
    name: System
  - description: MT5 terminal lifecycle and server time
    name: Terminal
  - description: Broker server time and UTC offset detection
    name: Time
  - description: Live balance, equity, and margin
    name: Account
  - description: Symbol specs, ticks, and OHLCV rates
    name: Symbols
  - description: Open position management
    name: Positions
  - description: Pending order placement and management
    name: Orders
  - description: Closed deals and historical orders
    name: History
paths:
  /symbols/{symbol}/rates:
    get:
      tags:
        - Symbols
      summary: Get OHLCV candles
      description: >-
        Returns historical OHLCV candles via `mt5.copy_rates_from_pos()`. Candle
        `time` is broker server time — the bot normalises to UTC using the
        detected offset from `/time`. `spread` is in raw points (e.g. 1400 pts ×
        $0.01 = $14.00 for BTCUSD on RoboForex).
      operationId: get_rates
      parameters:
        - description: Symbol name
          in: path
          name: symbol
          required: true
          schema:
            example: BTCUSD
            type: string
        - description: 'MT5 timeframe: M1 M5 M15 M30 H1 H4 D1 W1 MN1'
          in: query
          name: timeframe
          required: false
          schema:
            default: M1
            example: M15
            type: string
        - description: Number of candles to return (most recent first)
          in: query
          name: count
          required: false
          schema:
            default: 100
            example: 500
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/RateResponse'
                type: array
          description: OHLCV candles
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid timeframe or count
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or invalid Bearer token
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: MT5 not initialized
components:
  schemas:
    RateResponse:
      additionalProperties: true
      description: A single OHLCV candle.
      properties:
        close:
          example: 95050
          type: number
        high:
          example: 95200
          type: number
        low:
          example: 94900
          type: number
        open:
          example: 95000
          type: number
        real_volume:
          example: 0
          type: integer
        spread:
          description: >-
            Spread in raw points. For BTCUSD on RoboForex: 1459 pts × $0.01 =
            $14.59 round-turn.
          example: 1459
          type: integer
        tick_volume:
          example: 1234
          type: integer
        time:
          description: Candle open time as Unix epoch (broker server time).
          example: 1777879200
          type: integer
      type: object
    ErrorResponse:
      additionalProperties: true
      description: MT5 error payload returned on non-2xx responses.
      properties:
        message:
          example: Invalid stops
          type: string
        retcode:
          description: MT5 error code (e.g. 10014 = invalid stops, 10018 = market closed).
          example: 10014
          type: integer
      type: object
  securitySchemes:
    bearerAuth:
      description: Set `API_TOKEN` in `.env` to match the token configured on the server.
      scheme: bearer
      type: http

````