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

# Live candle stream

> On subscription the stream replays the latest candle of the requested
timeframe and then forwards live updates of the forming candle. Historical
ranges are not part of this API: use the REST endpoint
`GET /api/v1/marketdata/candles` for history. A terminal upstream error is
delivered as an `error` frame and closes the socket; when the upstream
stream ends the socket is closed normally.

**Cost:** 10 credits per subscription, charged again in every quota window
the connection stays open in.




## AsyncAPI

````yaml platform-api/specs/asyncapi.yaml candles
id: candles
title: Live candle stream
description: |
  On subscription the stream replays the latest candle of the requested
  timeframe and then forwards live updates of the forming candle. Historical
  ranges are not part of this API: use the REST endpoint
  `GET /api/v1/marketdata/candles` for history. A terminal upstream error is
  delivered as an `error` frame and closes the socket; when the upstream
  stream ends the socket is closed normally.

  **Cost:** 10 credits per subscription, charged again in every quota window
  the connection stays open in.
servers:
  - id: production
    protocol: wss
    host: public-api.takeprofit.com
    bindings: []
    variables: []
address: /api/v1/marketdata/candles/stream
parameters: []
bindings:
  - protocol: ws
    version: 0.1.0
    value:
      method: GET
      query:
        type: object
        additionalProperties: false
        required:
          - exchange
          - symbol
          - timeframe
        properties:
          exchange: &ref_0
            type: string
            description: >-
              TakeProfit exchange code as returned by GET
              /api/v1/marketdata/exchanges.
            example: CXBNCE
            x-parser-schema-id: ExchangeCode
          symbol: &ref_1
            type: string
            description: >-
              TakeProfit security symbol as returned by GET
              /api/v1/marketdata/exchanges/{exchange}/securities.
            example: BTC/USDT
            x-parser-schema-id: SecuritySymbol
          timeframe: &ref_2
            type: string
            description: >-
              Public timeframe id as returned by GET
              /api/v1/marketdata/timeframes, for example 1m, 5m, 1h, or 1d.
            example: 1m
            x-parser-schema-id: TimeframeId
          sessionType:
            type: string
            description: >-
              Optional session filter; MAINSESSION, PRE_MARKET, POST_MARKET.
              Repeat the parameter or pass comma-separated values. Defaults to
              MAINSESSION.
            example: MAINSESSION
            x-parser-schema-id: SessionTypeQuery
          properties:
            type: string
            description: >-
              Optional candle property filter using the names OPEN, HIGH, LOW,
              CLOSE, VOLUME, and SESSION_TYPE. Repeat the parameter or pass
              comma-separated values. When omitted every property is included.
              The timestamp is always present.
            example: close,volume
          throttlingDelay:
            type: integer
            minimum: 0
            maximum: 60000
            default: 0
            description: >-
              Throttling delay in milliseconds; a positive delay coalesces
              updates into at most one frame per delay, 0 or omitted applies no
              gateway-side throttling.
            x-parser-schema-id: ThrottlingDelay
    schemaProperties:
      - name: method
        type: string
        description: GET
        required: false
      - name: query
        type: object
        required: false
        properties:
          - name: exchange
            type: string
            description: >-
              TakeProfit exchange code as returned by GET
              /api/v1/marketdata/exchanges.
            required: true
          - name: symbol
            type: string
            description: >-
              TakeProfit security symbol as returned by GET
              /api/v1/marketdata/exchanges/{exchange}/securities.
            required: true
          - name: timeframe
            type: string
            description: >-
              Public timeframe id as returned by GET
              /api/v1/marketdata/timeframes, for example 1m, 5m, 1h, or 1d.
            required: true
          - name: sessionType
            type: string
            description: >-
              Optional session filter; MAINSESSION, PRE_MARKET, POST_MARKET.
              Repeat the parameter or pass comma-separated values. Defaults to
              MAINSESSION.
            required: false
          - name: properties
            type: string
            description: >-
              Optional candle property filter using the names OPEN, HIGH, LOW,
              CLOSE, VOLUME, and SESSION_TYPE. Repeat the parameter or pass
              comma-separated values. When omitted every property is included.
              The timestamp is always present.
            required: false
          - name: throttlingDelay
            type: integer
            description: >-
              Throttling delay in milliseconds; a positive delay coalesces
              updates into at most one frame per delay, 0 or omitted applies no
              gateway-side throttling.
            required: false
operations:
  - &ref_5
    id: streamCandles
    title: Stream candles
    description: Frames the gateway delivers to a connected candle stream client.
    type: send
    messages:
      - &ref_6
        id: candle
        contentType: application/json
        payload:
          - name: Candle frame
            description: The latest replayed candle or a live update of the forming candle.
            type: object
            properties:
              - name: const
                type: string
                description: candle
                required: false
              - name: meta
                type: object
                description: Echo of the normalized subscription parameters.
                required: true
                properties:
                  - name: exchange
                    type: string
                    description: >-
                      TakeProfit exchange code as returned by GET
                      /api/v1/marketdata/exchanges.
                    required: true
                  - name: symbol
                    type: string
                    description: >-
                      TakeProfit security symbol as returned by GET
                      /api/v1/marketdata/exchanges/{exchange}/securities.
                    required: true
                  - name: timeframe
                    type: string
                    description: >-
                      Public timeframe id as returned by GET
                      /api/v1/marketdata/timeframes, for example 1m, 5m, 1h, or
                      1d.
                    required: true
              - name: tag
                type: integer
                description: >-
                  Subscription tag echoed from the upstream stream item when
                  present; informational.
                required: false
              - name: isLast
                type: boolean
                description: >-
                  Echo of the upstream replay boundary flag. A subscriber
                  joining an already-running shared stream receives the latest
                  cached frame with its original flag and may never see true, so
                  do not rely on isLast to detect the end of the replay.
                required: true
              - name: candle
                type: object
                description: >-
                  Candle properties filtered by the properties query parameter;
                  the timestamp is always present. Prices and volume are decimal
                  strings.
                required: true
                properties:
                  - name: timestamp
                    type: string
                    required: true
                  - name: open
                    type: string
                    required: false
                  - name: high
                    type: string
                    required: false
                  - name: low
                    type: string
                    required: false
                  - name: close
                    type: string
                    required: false
                  - name: volume
                    type: string
                    required: false
                  - name: sessionType
                    type: string
                    enumValues:
                      - MAINSESSION
                      - PRE_MARKET
                      - POST_MARKET
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - type
            - meta
            - isLast
            - candle
          properties:
            type:
              const: candle
              x-parser-schema-id: <anonymous-schema-2>
            meta: &ref_3
              type: object
              description: Echo of the normalized subscription parameters.
              required:
                - exchange
                - symbol
                - timeframe
              properties:
                exchange: *ref_0
                symbol: *ref_1
                timeframe: *ref_2
              x-parser-schema-id: StreamMeta
            tag: &ref_4
              type: integer
              format: int32
              description: >-
                Subscription tag echoed from the upstream stream item when
                present; informational.
              x-parser-schema-id: Tag
            isLast:
              type: boolean
              description: >-
                Echo of the upstream replay boundary flag. A subscriber joining
                an already-running shared stream receives the latest cached
                frame with its original flag and may never see true, so do not
                rely on isLast to detect the end of the replay.
              x-parser-schema-id: <anonymous-schema-3>
            candle:
              type: object
              description: >-
                Candle properties filtered by the properties query parameter;
                the timestamp is always present. Prices and volume are decimal
                strings.
              required:
                - timestamp
              properties:
                timestamp:
                  type: string
                  format: date-time
                  x-parser-schema-id: <anonymous-schema-4>
                open:
                  type: string
                  x-parser-schema-id: <anonymous-schema-5>
                high:
                  type: string
                  x-parser-schema-id: <anonymous-schema-6>
                low:
                  type: string
                  x-parser-schema-id: <anonymous-schema-7>
                close:
                  type: string
                  x-parser-schema-id: <anonymous-schema-8>
                volume:
                  type: string
                  x-parser-schema-id: <anonymous-schema-9>
                sessionType:
                  type: string
                  enum:
                    - MAINSESSION
                    - PRE_MARKET
                    - POST_MARKET
                  x-parser-schema-id: SessionType
              x-parser-schema-id: Candle
          x-parser-schema-id: <anonymous-schema-1>
        title: Candle frame
        description: The latest replayed candle or a live update of the forming candle.
        example: |-
          {
            "type": "candle",
            "meta": {
              "exchange": "BATS",
              "symbol": "AAPL",
              "timeframe": "1m"
            },
            "tag": 1,
            "isLast": true,
            "candle": {
              "timestamp": "2026-09-21T19:59:00Z",
              "open": "339.27",
              "high": "339.35",
              "low": "338.93",
              "close": "339.05",
              "volume": "17501",
              "sessionType": "MAINSESSION"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: candle
      - &ref_7
        id: error
        contentType: application/json
        payload:
          - name: Error frame
            description: >-
              Terminal error converted from an upstream status; closes the
              socket.
            type: object
            properties:
              - name: const
                type: string
                description: error
                required: false
              - name: meta
                type: object
                description: Echo of the normalized subscription parameters.
                required: true
                properties:
                  - name: exchange
                    type: string
                    description: >-
                      TakeProfit exchange code as returned by GET
                      /api/v1/marketdata/exchanges.
                    required: true
                  - name: symbol
                    type: string
                    description: >-
                      TakeProfit security symbol as returned by GET
                      /api/v1/marketdata/exchanges/{exchange}/securities.
                    required: true
                  - name: timeframe
                    type: string
                    description: >-
                      Public timeframe id as returned by GET
                      /api/v1/marketdata/timeframes, for example 1m, 5m, 1h, or
                      1d.
                    required: true
              - name: tag
                type: integer
                description: >-
                  Subscription tag echoed from the upstream stream item when
                  present; informational.
                required: false
              - name: error
                type: object
                required: true
                properties:
                  - name: code
                    type: string
                    description: Stable public error code.
                    enumValues:
                      - canceled
                      - invalid_argument
                      - unauthenticated
                      - permission_denied
                      - not_found
                      - conflict
                      - rate_limited
                      - too_much_data
                      - deadline_exceeded
                      - unimplemented
                      - unavailable
                      - upstream_error
                    required: true
                  - name: message
                    type: string
                    description: Human-readable public error message.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - type
            - meta
            - error
          properties:
            type:
              const: error
              x-parser-schema-id: <anonymous-schema-11>
            meta: *ref_3
            tag: *ref_4
            error:
              type: object
              required:
                - code
                - message
              properties:
                code:
                  type: string
                  description: Stable public error code.
                  enum:
                    - canceled
                    - invalid_argument
                    - unauthenticated
                    - permission_denied
                    - not_found
                    - conflict
                    - rate_limited
                    - too_much_data
                    - deadline_exceeded
                    - unimplemented
                    - unavailable
                    - upstream_error
                  x-parser-schema-id: <anonymous-schema-12>
                message:
                  type: string
                  description: Human-readable public error message.
                  x-parser-schema-id: <anonymous-schema-13>
              x-parser-schema-id: ErrorBody
          x-parser-schema-id: <anonymous-schema-10>
        title: Error frame
        description: Terminal error converted from an upstream status; closes the socket.
        example: |-
          {
            "type": "error",
            "meta": {
              "exchange": "BATS",
              "symbol": "UNKNOWN",
              "timeframe": "1m"
            },
            "tag": 1,
            "error": {
              "code": "not_found",
              "message": "security not found"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: error
    bindings: []
    extensions:
      - id: x-parser-unique-object-id
        value: candles
sendOperations: []
receiveOperations:
  - *ref_5
sendMessages: []
receiveMessages:
  - *ref_6
  - *ref_7
extensions:
  - id: x-parser-unique-object-id
    value: candles
securitySchemes:
  - id: ApiKeyAuth
    name: x-api-key
    type: httpApiKey
    description: >-
      API key sent on the WebSocket upgrade request. Exactly one header value is
      required; duplicate or comma-combined values are rejected.
    in: header
    extensions: []

````