> ## 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.

# List historical TPO (Market Profile) data

> Provide `exchange`, `symbol`, and `timeframe`. Nothing else is required: the
window defaults to the 40 timeframe periods before now.

- With `from` the window starts there and runs forward, ending at `to` or after
  `period` seconds (40 timeframe periods by default).
- Without `from` the window ends at `to` (now by default) and runs backwards over
  `period` seconds or the 40 timeframe periods before it.
- The default is measured in wall-clock time, so it holds fewer than 40 periods on an
  exchange with non-trading days (about 28 for a 1d frame on a weekday-only market).
- `period` cannot be added to an explicit `from`+`to` window.
- Supported timeframes are day, week, and month based (1d..31d, 1w..4w, 1M).
- If `from` is not aligned to a timeframe period boundary, the beginning of the next
  period is used.
- The requested range is limited to at most 400 profiles (with
  `mergeSessions=GROUP_BY_TYPE` every session type of a period counts as a profile).

**Cost:** 25 credits per returned timeframe period (distinct `openTradingDay`), at least
1000 credits per request. With `mergeSessions=GROUP_BY_TYPE` one profile per session
type is built for every period at no additional cost.




## OpenAPI

````yaml /platform-api/specs/openapi.yaml get /api/v1/marketdata/tpo
openapi: 3.0.3
info:
  title: TakeProfit API (REST)
  version: 0.6.0
  contact:
    email: support@takeprofit.com
  description: |
    Historical marketdata and the security catalog over REST. Live streams
    (candles, volume footprint, order books) are served over WebSocket and
    described by the AsyncAPI document at
    `https://public-api.takeprofit.com/api/v1/marketdata/asyncapi.yaml`.
    Guides (getting an API key, credits and quota, errors) live at
    [takeprofit.com/docs](https://takeprofit.com/docs).

    ## Requests

    - Base URL: `https://public-api.takeprofit.com`.
    - Every endpoint answers `GET` only.
    - Authenticate with the `x-api-key` header; exactly one header value is
      required.
    - Unknown query parameters and repeated scalar parameters are rejected
      with 400.
    - Identify securities with `exchange` and `symbol` as returned by the
      catalog endpoints; internal ids and GUIDs are not accepted (search
      additionally accepts an ISIN as a lookup key).

    ## Credits and quota

    Requests are metered in credits against a fixed quota window of 100000
    credits per 60 seconds, shared by all API keys of the account. Each
    operation states its price; every billed request costs at least 1000
    credits, so an account makes at most 100 requests per minute. Every
    authenticated response carries the window state:

    - `X-RateLimit-Limit` - credits per window;
    - `X-RateLimit-Remaining` - credits still available after this request;
    - `X-RateLimit-Reset` - epoch second the window resets at.

    A request the remaining credits cannot cover is rejected with 429 and
    `Retry-After` (seconds until the window resets); the rejection itself is
    free.

    ## Errors

    Every error response is `{"error": {"code": "<stable code>", "message":
    "<human-readable text>"}}`. The statuses listed on each operation (400,
    401, 403, 404, 429) are the outcomes a client handles explicitly. A 400
    is either `invalid_argument` (a malformed request) or `too_much_data`: the
    request produces more data than can be served in one response, and only a
    narrower window fixes it - it is never a rate limit. In
    addition, any operation can answer 502 (`bad_gateway`), 503
    (`unavailable`) or 504 (`deadline_exceeded`) while the gateway or an
    upstream is unavailable or slow; these are transient - retry with
    exponential backoff.
servers:
  - url: https://public-api.takeprofit.com
    description: Production
security: []
paths:
  /api/v1/marketdata/tpo:
    get:
      tags:
        - TPO
      summary: List historical TPO (Market Profile) data
      description: >
        Provide `exchange`, `symbol`, and `timeframe`. Nothing else is required:
        the

        window defaults to the 40 timeframe periods before now.


        - With `from` the window starts there and runs forward, ending at `to`
        or after
          `period` seconds (40 timeframe periods by default).
        - Without `from` the window ends at `to` (now by default) and runs
        backwards over
          `period` seconds or the 40 timeframe periods before it.
        - The default is measured in wall-clock time, so it holds fewer than 40
        periods on an
          exchange with non-trading days (about 28 for a 1d frame on a weekday-only market).
        - `period` cannot be added to an explicit `from`+`to` window.

        - Supported timeframes are day, week, and month based (1d..31d, 1w..4w,
        1M).

        - If `from` is not aligned to a timeframe period boundary, the beginning
        of the next
          period is used.
        - The requested range is limited to at most 400 profiles (with
          `mergeSessions=GROUP_BY_TYPE` every session type of a period counts as a profile).

        **Cost:** 25 credits per returned timeframe period (distinct
        `openTradingDay`), at least

        1000 credits per request. With `mergeSessions=GROUP_BY_TYPE` one profile
        per session

        type is built for every period at no additional cost.
      operationId: listTpo
      parameters:
        - name: exchange
          in: query
          required: true
          schema:
            $ref: '#/components/schemas/ExchangeCode'
        - name: symbol
          in: query
          required: true
          description: >-
            Public security symbol returned by
            /api/v1/marketdata/exchanges/{exchange}/securities.
          schema:
            $ref: '#/components/schemas/SecuritySymbol'
        - name: timeframe
          in: query
          required: true
          description: Day (1d..31d), week (1w..4w), or month (1M) timeframe id.
          schema:
            $ref: '#/components/schemas/TimeframeId'
          example: 1d
        - name: from
          in: query
          required: false
          description: >-
            Range start as Unix seconds or RFC3339 timestamp. Without it the
            window is measured backwards from to.
          schema:
            $ref: '#/components/schemas/TimestampQuery'
        - name: to
          in: query
          required: false
          description: >-
            Range end as Unix seconds or RFC3339 timestamp, greater than from.
            Defaults to now when from is omitted.
          schema:
            $ref: '#/components/schemas/TimestampQuery'
        - name: period
          in: query
          required: false
          description: >-
            Range duration in seconds, counted forward from from or backwards
            from to.
          schema:
            $ref: '#/components/schemas/PositiveSeconds'
        - name: blockSize
          in: query
          required: false
          description: Duration of each profile time block. Defaults to 30m.
          schema:
            $ref: '#/components/schemas/TpoBlockSize'
        - name: rowSize
          in: query
          required: false
          description: >-
            Price row height in tick size. 0 (or omitted) enables automatic row
            size detection.
          schema:
            type: integer
            minimum: 0
            maximum: 1000000
          example: 0
        - name: sessionType
          in: query
          required: false
          description: >-
            Optional session filter. Repeat this parameter or pass
            comma-separated values.
          style: form
          explode: true
          schema:
            type: array
            items:
              $ref: '#/components/schemas/SessionType'
        - name: mergeSessions
          in: query
          required: false
          description: How sessions are merged into profiles. Defaults to MERGE_ALL.
          schema:
            $ref: '#/components/schemas/TpoMergeSessions'
      responses:
        '200':
          description: TPO response.
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TpoResponse'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ExchangeCode:
      type: string
      description: TakeProfit exchange code as returned by /api/v1/marketdata/exchanges.
      example: BATS
    SecuritySymbol:
      type: string
      description: >-
        TakeProfit security symbol as returned by
        /api/v1/marketdata/exchanges/{exchange}/securities. In a path segment a
        slash must be percent-encoded (BTC/USDT is requested as BTC%2FUSDT).
      example: AAPL
    TimeframeId:
      type: string
      description: >-
        Timeframe id returned by /api/v1/marketdata/timeframes. Canonical
        suffixes include M for months and Q for quarters.
      example: 1h
    TimestampQuery:
      type: string
      description: Unix seconds (for example 1790000000) or RFC3339 timestamp.
    PositiveSeconds:
      type: integer
      minimum: 1
    TpoBlockSize:
      type: string
      description: Duration of each TPO time block.
      enum:
        - 30m
        - 1h
        - 2h
        - 4h
    SessionType:
      type: string
      enum:
        - MAINSESSION
        - PRE_MARKET
        - POST_MARKET
    TpoMergeSessions:
      type: string
      description: >-
        MERGE_ALL merges all sessions into one profile per period. GROUP_BY_TYPE
        builds one profile per session type per period.
      enum:
        - MERGE_ALL
        - GROUP_BY_TYPE
    TpoResponse:
      type: object
      required:
        - meta
        - profiles
      properties:
        meta:
          $ref: '#/components/schemas/CandlesMeta'
        profiles:
          type: array
          items:
            $ref: '#/components/schemas/TpoProfile'
      example:
        meta:
          exchange: BATS
          symbol: AAPL
          timeframe: 1d
        profiles:
          - openTradingDay: '2026-09-21T00:00:00Z'
            profileEnd: '2026-09-21T20:00:00Z'
            sessionType: MAINSESSION
            rowSize: '0.26'
            pointOfControl: '338.26'
            initialBalanceHigh: '337.74'
            initialBalanceLow: '332.8'
            blocks:
              - 48600
              - 50400
              - 52200
              - 54000
              - 55800
              - 57600
              - 59400
              - 61200
              - 63000
              - 64800
              - 66600
              - 68400
              - 70200
            rows:
              - - '332.8'
                - - 0
                - '0'
                - '106'
              - - '333.06'
                - - 0
                - '2754'
                - '4223'
              - - '333.32'
                - - 0
                - '7037'
                - '9217'
              - - '333.58'
                - - 0
                - '7783'
                - '9611'
              - - '333.84'
                - - 0
                - '8329'
                - '15930'
              - - '334.1'
                - - 0
                - '9352'
                - '8254'
              - - '334.36'
                - - 0
                - '9777'
                - '11524'
              - - '334.62'
                - - 0
                - '4930'
                - '2161'
              - - '334.88'
                - - 0
                - '7366'
                - '2128'
              - - '335.14'
                - - 0
                - '12193'
                - '9753'
              - - '335.4'
                - - 0
                - '2663'
                - '1883'
              - - '335.66'
                - - 0
                  - 1
                - '10208'
                - '10787'
              - - '335.92'
                - - 0
                  - 1
                - '20081'
                - '7412'
              - - '336.18'
                - - 0
                  - 1
                  - 2
                - '12438'
                - '4948'
              - - '336.44'
                - - 1
                  - 2
                - '21328'
                - '43779'
              - - '336.7'
                - - 1
                  - 2
                  - 3
                  - 4
                - '19068'
                - '29667'
              - - '336.96'
                - - 1
                  - 2
                  - 3
                  - 4
                - '43127'
                - '21425'
              - - '337.22'
                - - 1
                  - 2
                  - 3
                  - 4
                - '20867'
                - '16892'
              - - '337.48'
                - - 1
                  - 2
                  - 3
                  - 4
                  - 5
                - '26492'
                - '13659'
              - - '337.74'
                - - 1
                  - 2
                  - 3
                  - 4
                  - 5
                  - 9
                - '26485'
                - '10554'
              - - '338'
                - - 2
                  - 4
                  - 5
                  - 8
                  - 9
                  - 11
                - '32058'
                - '16709'
              - - '338.26'
                - - 4
                  - 5
                  - 6
                  - 7
                  - 8
                  - 9
                  - 10
                  - 11
                - '34640'
                - '20544'
              - - '338.52'
                - - 5
                  - 6
                  - 7
                  - 8
                  - 9
                  - 10
                  - 11
                - '57464'
                - '46732'
              - - '338.78'
                - - 5
                  - 6
                  - 7
                  - 8
                  - 9
                  - 10
                  - 11
                  - 12
                - '90818'
                - '36228'
              - - '339.04'
                - - 6
                  - 7
                  - 9
                  - 10
                  - 11
                  - 12
                - '43163'
                - '29151'
              - - '339.3'
                - - 11
                  - 12
                - '29120'
                - '10199'
              - - '339.56'
                - - 11
                  - 12
                - '2754'
                - '3395'
    CandlesMeta:
      type: object
      required:
        - exchange
        - symbol
        - timeframe
      properties:
        exchange:
          $ref: '#/components/schemas/ExchangeCode'
        symbol:
          $ref: '#/components/schemas/SecuritySymbol'
        timeframe:
          $ref: '#/components/schemas/TimeframeId'
    TpoProfile:
      type: object
      required:
        - openTradingDay
        - sessionType
        - rowSize
        - blocks
        - rows
      properties:
        openTradingDay:
          type: string
          format: date-time
          description: First trading day of the profile period.
        profileEnd:
          type: string
          format: date-time
          description: End time of the last session included in this profile, exclusive.
        sessionType:
          allOf:
            - $ref: '#/components/schemas/SessionType'
          description: >-
            With MERGE_ALL this is the type of the first session used to build
            the profile.
        rowSize:
          type: string
          description: Effective price increment per row, in quote currency units.
        pointOfControl:
          type: string
          description: Price of the row with the highest number of active time blocks.
        initialBalanceHigh:
          type: string
          description: Highest price row reached during the first two time blocks.
        initialBalanceLow:
          type: string
          description: Lowest price row reached during the first two time blocks.
        blocks:
          type: array
          description: >-
            Active time block start offsets in seconds relative to
            openTradingDay, in block order. Blocks are not necessarily
            contiguous across session gaps; the last block of a session may be
            shorter than blockSize.
          items:
            type: integer
            format: int64
        rows:
          type: array
          description: Price rows ordered from lowest to highest price.
          items:
            $ref: '#/components/schemas/TpoRow'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Stable public error code.
            message:
              type: string
              description: Human-readable public error message.
      example:
        error:
          code: unauthenticated
          message: authentication failed
    TpoRow:
      type: array
      description: >-
        One price row as the positional array [price, blockIndexes, volumeBuy,
        volumeSell]. price is the lower bound of the half-open interval [price,
        price + rowSize); blockIndexes are indexes into TpoProfile.blocks (0 =
        block A, 1 = B, ...); price and volumes are decimal strings. Future
        fields extend the array, so clients must ignore extra trailing elements.
      minItems: 4
      items: {}
      example:
        - '338.26'
        - - 4
          - 5
          - 6
          - 7
          - 8
          - 9
          - 10
          - 11
        - '34640'
        - '20544'
  headers:
    RateLimitLimit:
      description: Credits allowed per quota window.
      schema:
        type: integer
    RateLimitRemaining:
      description: Credits still available in the current quota window after this request.
      schema:
        type: integer
    RateLimitReset:
      description: Epoch second at which the current quota window resets.
      schema:
        type: integer
        format: int64
    RetryAfter:
      description: Seconds until the quota window resets and the request can be retried.
      schema:
        type: integer
  responses:
    InvalidRequest:
      description: >-
        Invalid request (`invalid_argument`), or a request producing more data
        than can be served (`too_much_data`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: invalid_argument
              message: query parameter "exchange" is required
    Unauthorized:
      description: Authentication failed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: unauthenticated
              message: authentication failed
    Forbidden:
      description: Permission denied.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: permission_denied
              message: permission denied
    NotFound:
      description: The exchange or the security is not served.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: not_found
              message: security not found
    RateLimited:
      description: >-
        The remaining credits of the quota window cannot cover this request;
        retry after the window resets.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: rate_limited
              message: rate limit exceeded
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````