openapi: 3.1.0
info:
  title: ATLAS Public API — UDF REST API
  version: 1.0.0
  description: "TradingView UDF read endpoints for charting. The only REST surface: everything else is JSON-RPC (see the OpenRPC spec) or WebSocket push (see the AsyncAPI spec)."
servers:
  - url: https://testnet.atlas.layerzero.network/market
    description: ATLAS testnet. Every request needs an X-Api-Key header.
paths:
  /udf/config:
    get:
      operationId: udfConfig
      x-rateLimit:
        defaultWeight: 1
      summary: Exchange capabilities advertised to TradingView
      description: |
        Returns the UDF configuration object describing supported resolutions,
        exchange metadata, and feature flags.  TradingView calls this once at
        chart initialization.
      tags:
        - UDF
      responses:
        "200":
          description: UDF configuration
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UdfConfig"
        "429":
          $ref: "#/components/responses/UdfRateLimited"
  /udf/time:
    get:
      operationId: udfTime
      x-rateLimit:
        defaultWeight: 1
      summary: Current server Unix time in seconds
      description: |
        Returns a plain integer (not a JSON object) — TradingView expects the raw
        number in the response body.  Used to align the client clock with the server.
      tags:
        - UDF
      responses:
        "200":
          description: Unix timestamp in seconds
          content:
            text/plain:
              schema:
                type: integer
                example: 1711000000
        "429":
          $ref: "#/components/responses/UdfRateLimited"
  /udf/symbols:
    get:
      operationId: udfSymbols
      x-rateLimit:
        defaultWeight: 5
      summary: Symbol metadata for one market
      description: |
        Returns symbol info for the requested ticker.  TradingView calls this when
        the user changes the chart symbol.  The ticker is the market id as a
        decimal string; `name` and `description` carry the published symbol.
      tags:
        - UDF
      parameters:
        - name: symbol
          in: query
          required: true
          description: Market id as a decimal string, e.g. "7".
          schema:
            type: string
            example: "7"
      responses:
        "200":
          description: Symbol info or error
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/UdfSymbolInfo"
                  - $ref: "#/components/schemas/UdfError"
        "400":
          $ref: "#/components/responses/UdfBadQuery"
        "429":
          $ref: "#/components/responses/UdfRateLimited"
  /udf/search:
    get:
      operationId: udfSearch
      x-rateLimit:
        defaultWeight: 5
      summary: Symbol search
      description: |
        Returns a list of symbols matching the query string.  TradingView uses this
        to power the symbol search box in the charting library.  Each result's
        `symbol`/`full_name` is the market id as a decimal string; the query
        matches the published symbol.
      tags:
        - UDF
      parameters:
        - name: query
          in: query
          required: false
          description: Search string. Absent or empty = return all symbols.
          schema:
            type: string
            example: BTC
        - name: limit
          in: query
          required: false
          description: Maximum results to return. Default 10, max 50.
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 10
      responses:
        "200":
          description: List of matching symbols
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/UdfSearchResult"
        "400":
          $ref: "#/components/responses/UdfBadQuery"
        "429":
          $ref: "#/components/responses/UdfRateLimited"
  /udf/history:
    get:
      operationId: udfHistory
      x-rateLimit:
        defaultWeight: 20
      summary: Historical OHLCV bars
      description: |
        Returns OHLCV bars for the requested symbol and resolution.
        The symbol is the market id as a decimal string.
        Timestamps in the response are Unix **seconds** (not milliseconds) —
        this is a TradingView UDF requirement.

        ## Resolution mapping (TradingView → ATLAS)

        | TradingView | ATLAS interval |
        |-------------|----------------|
        | `1`         | `1m`           |
        | `5`         | `5m`           |
        | `15`        | `15m`          |
        | `60`        | `1h`           |
        | `240`       | `4h`           |
        | `1D`        | `1d`           |
      tags:
        - UDF
      parameters:
        - name: symbol
          in: query
          required: true
          description: Market id as a decimal string.
          schema:
            type: string
            example: "7"
        - name: resolution
          in: query
          required: true
          description: Bar resolution in TradingView format.
          schema:
            type: string
            enum:
              - "1"
              - "5"
              - "15"
              - "60"
              - "240"
              - 1D
            example: "60"
        - name: from
          in: query
          required: true
          description: Range start, Unix seconds (inclusive).
          schema:
            type: integer
            example: 1711000000
        - name: to
          in: query
          required: true
          description: Range end, Unix seconds (inclusive).
          schema:
            type: integer
            example: 1711100000
      responses:
        "200":
          description: Historical bars or no-data / error
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/UdfHistoryOk"
                  - $ref: "#/components/schemas/UdfHistoryNoData"
                  - $ref: "#/components/schemas/UdfError"
        "400":
          $ref: "#/components/responses/UdfBadQuery"
        "429":
          $ref: "#/components/responses/UdfRateLimited"
components:
  responses:
    UdfBadQuery:
      description: |
        A required query parameter is missing, or a parameter cannot be parsed (for example a non-numeric `from`). The body is a plain-text message, not a UDF object.
      content:
        text/plain:
          schema:
            type: string
    UdfRateLimited:
      description: Rate limit exceeded; wait `retryAfterMs` before retrying.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/UdfRateLimitError"
  schemas:
    UdfConfig:
      type: object
      required:
        - supported_resolutions
        - supports_search
        - supports_group_request
        - supports_marks
        - supports_timescale_marks
        - supports_time
      properties:
        supported_resolutions:
          type: array
          items:
            type: string
          example:
            - "1"
            - "5"
            - "15"
            - "60"
            - "240"
            - 1D
        supports_search:
          type: boolean
        supports_group_request:
          type: boolean
        supports_marks:
          type: boolean
        supports_timescale_marks:
          type: boolean
        supports_time:
          type: boolean
        exchanges:
          type: array
          items:
            type: object
        symbols_types:
          type: array
          items:
            type: object
    UdfError:
      type: object
      required:
        - s
        - errmsg
      properties:
        s:
          type: string
          enum:
            - error
        errmsg:
          type: string
          description: Human-readable error message.
    UdfHistoryNoData:
      type: object
      required:
        - s
      properties:
        s:
          type: string
          enum:
            - no_data
        nextTime:
          type: integer
          description: |
            Unix seconds of the nearest available bar after the requested range. Present when known; absent otherwise.
    UdfHistoryOk:
      type: object
      required:
        - s
        - t
        - o
        - h
        - l
        - c
        - v
      properties:
        s:
          type: string
          enum:
            - ok
        t:
          type: array
          items:
            type: integer
          description: Bar open times, Unix seconds.
        o:
          type: array
          items:
            type: string
          description: Open prices (decimal strings).
        h:
          type: array
          items:
            type: string
          description: High prices (decimal strings).
        l:
          type: array
          items:
            type: string
          description: Low prices (decimal strings).
        c:
          type: array
          items:
            type: string
          description: Close prices (decimal strings).
        v:
          type: array
          items:
            type: string
          description: Volume values (decimal strings).
    UdfRateLimitError:
      type: object
      required:
        - status
        - response
        - limiter
        - retryAfterMs
      properties:
        status:
          type: string
          enum:
            - err
        response:
          type: string
          enum:
            - "[rate_limit_exceeded]"
        limiter:
          type: string
          description: The limiter that refused the request.
        retryAfterMs:
          type: integer
          minimum: 0
          description: Milliseconds to wait before retrying.
    UdfSearchResult:
      type: object
      required:
        - symbol
        - full_name
        - description
        - type
        - exchange
      properties:
        symbol:
          type: string
          example: "7"
          description: Market id as a decimal string.
        full_name:
          type: string
          example: Atlas:BTC
        description:
          type: string
          example: BTC Perpetual
        type:
          type: string
          example: crypto
        exchange:
          type: string
          example: Atlas
    UdfSymbolInfo:
      type: object
      required:
        - name
        - ticker
        - description
        - type
        - session
        - timezone
        - exchange
        - minmov
        - pricescale
        - has_intraday
        - supported_resolutions
      properties:
        name:
          type: string
          example: BTC
          description: Published market symbol.
        ticker:
          type: string
          example: "7"
          description: Market id as a decimal string; TradingView passes it back to /udf/history.
        description:
          type: string
          example: BTC Perpetual
        type:
          type: string
          example: crypto
        session:
          type: string
          example: 24x7
        timezone:
          type: string
          example: Etc/UTC
        exchange:
          type: string
          example: Atlas
        listed_exchange:
          type: string
          example: Atlas
        minmov:
          type: integer
          example: 1
        pricescale:
          type: integer
          description: |
            Number of decimal digits in price = log10(pricescale). pricescale=100 → 2 decimal places.
          example: 100
        has_intraday:
          type: boolean
        has_daily:
          type: boolean
        has_no_volume:
          type: boolean
        has_weekly_and_monthly:
          type: boolean
        supported_resolutions:
          type: array
          items:
            type: string
        volume_precision:
          type: integer
          example: 4
        data_status:
          type: string
          enum:
            - streaming
            - endofday
            - pulsed
            - delayed_streaming
          example: streaming
        format:
          type: string
          enum:
            - price
            - volume
          example: price
