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

# Data Pair



## OpenAPI

````yaml open-apis/node.json get /node/v1/data/{base}/{quote}
openapi: 3.1.0
info:
  title: pragma-node
  description: ''
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://{environment}.pragma.build
    variables:
      environment:
        default: api.devnet
security: []
tags:
  - name: pragma-node
    description: Pragma Node API
paths:
  /node/v1/data/{base}/{quote}:
    get:
      tags:
        - Price Data
      summary: Get the latest price entry for a trading pair
      operationId: get_entry
      parameters:
        - name: base
          in: path
          description: Base asset symbol (e.g. BTC)
          required: true
          schema:
            type: string
        - name: quote
          in: path
          description: Quote asset symbol (e.g. USD)
          required: true
          schema:
            type: string
        - name: timestamp
          in: query
          description: >-
            The unix timestamp in seconds to retrieve historical price data.

            This endpoint will return the first update whose timestamp is <= the
            provided value.


            If not provided, returns the latest available price.


            # Examples

            - `1_647_820_800`: Returns price data from March 21, 2022 00:00:00
            UTC

            - `null`: Returns the most recent price update


            NOTE: This only works for `median` aggregation
          required: false
          schema:
            oneOf:
              - type: 'null'
              - 99bf9019-06c1-4240-b828-2ad6fd847bce
        - name: interval
          in: query
          description: >-
            Time interval for aggregated price data. Different intervals affect
            how price data is

            aggregated and can be used to get OHLC (Open/High/Low/Close) data at
            various timeframes.


            # Available intervals

            - `100ms`: 100 milliseconds - High frequency trading

            - `1s`: 1 second - Real-time trading

            - `5s`: 5 seconds - Short-term price movements

            - `1min`: 1 minute - Intraday trading

            - `15min`: 15 minutes - Medium-term analysis

            - `1h`: 1 hour - Daily trading patterns

            - `2h`: 2 hours (default) - Extended market analysis

            - `1d`: 1 day - Long-term trends

            - `1w`: 1 week - Strategic market overview
          required: false
          schema:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/Interval'
        - name: routing
          in: query
          description: >-
            Enable price routing through intermediate pairs.

            When true, if a direct price for the requested pair is not
            available,

            the system will attempt to calculate it using intermediate pairs.


            # Example

            For BTC/EUR when routing is enabled:

            - If direct BTC/EUR price is unavailable

            - System might route through BTC/USD and EUR/USD


            Default: true
          required: false
          schema:
            type:
              - boolean
              - 'null'
        - name: aggregation
          in: query
          description: |-
            Method used to aggregate prices from multiple sources.

            # Available modes
            - `median`: Middle value (default, more manipulation resistant)
            - `mean`: Average of all values
            - `twap`: Time-Weighted Average Price
          required: false
          schema:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/AggregationMode'
        - name: entry_type
          in: query
          description: |-
            Type of market entry to retrieve

            # Available types
            - `spot`: Spot market prices (default)
            - `perp`: Perpetual futures prices
            - `future`: Fixed-expiry futures prices
          required: false
          schema:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/EntryType'
        - name: expiry
          in: query
          description: |-
            Expiry date for future contracts in ISO 8601 format.
            Only applicable when `entry_type` is "future".

            # Example
            - `"2024-12-31"`: December 31, 2024 expiry
            - `null`: Not applicable for spot/perp markets
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: with_components
          in: query
          description: >-
            Include source components in the response.

            When true, the response will include price data from individual
            sources.


            # Example

            - `true`: Include source breakdown in response

            - `false`: Return aggregated data only (default)
          required: false
          schema:
            type:
              - boolean
              - 'null'
      responses:
        '200':
          description: Successfully retrieved price entry
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetEntryResponse'
              example:
                components:
                  - price: '0x6cc61113f5871b1000'
                    source: BINANCE
                    timestamp: 1743082057
                decimals: 18
                num_sources_aggregated: 5
                pair_id: BTC/USD
                price: '0x1234567890abcdef'
                timestamp: 1647820800
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntryError'
        '404':
          description: Price entry not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntryError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntryError'
      security:
        - api_key: []
components:
  schemas:
    Interval:
      type: string
      enum:
        - 100ms
        - 1s
        - 5s
        - 10s
        - 1min
        - 5min
        - 15min
        - 1h
        - 2h
        - 1d
        - 1w
    AggregationMode:
      type: string
      enum:
        - median
        - twap
    EntryType:
      type: string
      enum:
        - spot
        - perp
        - future
    GetEntryResponse:
      type: object
      required:
        - num_sources_aggregated
        - pair_id
        - price
        - timestamp
        - decimals
      properties:
        components:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/EntryComponent'
        decimals:
          type: integer
          format: int32
          minimum: 0
        num_sources_aggregated:
          type: integer
          minimum: 0
        pair_id:
          type: string
        price:
          type: string
        timestamp:
          type: integer
          format: int64
          minimum: 0
    EntryError:
      oneOf:
        - type: object
          required:
            - InvalidSignature
          properties:
            InvalidSignature:
              $ref: '#/components/schemas/SignerError'
          example: invalid signature
        - type: object
          required:
            - InvalidTimestamp
          properties:
            InvalidTimestamp:
              $ref: '#/components/schemas/TimestampError'
          example: invalid timestamp
        - type: string
          enum:
            - InvalidExpiry
          example: invalid expiry
        - type: object
          required:
            - InvalidInterval
          properties:
            InvalidInterval:
              type: array
              items:
                type: object
              maxItems: 2
              minItems: 2
          example: unsupported interval 1s for aggregation median
        - type: object
          required:
            - InvalidOnchainInterval
          properties:
            InvalidOnchainInterval:
              $ref: '#/components/schemas/Interval'
          example: unsupported interval 1s for onchain data
        - type: object
          required:
            - InvalidLoginMessage
          properties:
            InvalidLoginMessage:
              type: string
        - type: object
          required:
            - InvalidDataTypeForNetwork
          properties:
            InvalidDataTypeForNetwork:
              type: array
              items:
                type: object
              maxItems: 2
              minItems: 2
        - type: object
          required:
            - Unauthorized
          properties:
            Unauthorized:
              type: string
        - type: object
          required:
            - PairNotFound
          properties:
            PairNotFound:
              type: string
        - type: object
          required:
            - EntryNotFound
          properties:
            EntryNotFound:
              type: string
        - type: object
          required:
            - PublisherNotFound
          properties:
            PublisherNotFound:
              type: string
        - type: object
          required:
            - RouteNotFound
          properties:
            RouteNotFound:
              type: string
        - type: string
          enum:
            - HistoryNotFound
        - type: object
          required:
            - PublisherError
          properties:
            PublisherError:
              $ref: '#/components/schemas/PublisherError'
        - type: object
          required:
            - PublishData
          properties:
            PublishData:
              type: string
        - type: object
          required:
            - BuildPublish
          properties:
            BuildPublish:
              type: string
        - type: string
          enum:
            - InvalidSigner
        - type: object
          required:
            - DatabaseError
          properties:
            DatabaseError:
              type: string
        - type: object
          required:
            - InternalServerError
          properties:
            InternalServerError:
              type: string
        - type: object
          required:
            - WebSocketError
          properties:
            WebSocketError:
              $ref: '#/components/schemas/WebSocketError'
      example:
        code: UNAUTHORIZED
        message: 'Unauthorized request: Invalid API key'
        timestamp: '2024-03-20T10:30:00Z'
    EntryComponent:
      type: object
      required:
        - source
        - price
        - timestamp
      properties:
        price:
          type: string
        source:
          type: string
        timestamp:
          type: integer
          format: int64
          minimum: 0
    SignerError:
      oneOf:
        - type: object
          required:
            - ConversionError
          properties:
            ConversionError:
              $ref: '#/components/schemas/ConversionError'
        - type: object
          required:
            - SigningError
          properties:
            SigningError:
              type: string
        - type: object
          required:
            - InvalidSignature
          properties:
            InvalidSignature:
              type: string
        - type: object
          required:
            - Unauthorized
          properties:
            Unauthorized:
              type: string
        - type: object
          required:
            - InvalidMessage
          properties:
            InvalidMessage:
              type: string
    TimestampError:
      oneOf:
        - type: object
          required:
            - RangeError
          properties:
            RangeError:
              $ref: '#/components/schemas/TimestampRangeError'
        - type: object
          required:
            - ToDatetimeErrorU64
          properties:
            ToDatetimeErrorU64:
              type: integer
              format: int64
              minimum: 0
        - type: object
          required:
            - ToDatetimeErrorI64
          properties:
            ToDatetimeErrorI64:
              type: integer
              format: int64
        - type: object
          required:
            - Other
          properties:
            Other:
              type: string
    PublisherError:
      oneOf:
        - type: object
          required:
            - InvalidKey
          properties:
            InvalidKey:
              type: string
        - type: object
          required:
            - InvalidAddress
          properties:
            InvalidAddress:
              type: string
        - type: object
          required:
            - InactivePublisher
          properties:
            InactivePublisher:
              type: string
        - type: string
          enum:
            - NotFound
        - type: string
          enum:
            - InternalServerError
    WebSocketError:
      oneOf:
        - type: string
          enum:
            - ChannelInit
        - type: object
          required:
            - MessageDecode
          properties:
            MessageDecode:
              type: string
        - type: string
          enum:
            - ChannelClose
    ConversionError:
      oneOf:
        - type: string
          enum:
            - FailedSerialization
        - type: string
          enum:
            - InvalidDateTime
        - type: string
          enum:
            - BigDecimalConversion
        - type: string
          enum:
            - FeltConversion
        - type: string
          enum:
            - U128Conversion
        - type: string
          enum:
            - StringTimestampConversion
        - type: string
          enum:
            - StringPriceConversion
        - type: object
          required:
            - FailedSignature
          properties:
            FailedSignature:
              type: string
    TimestampRangeError:
      oneOf:
        - type: string
          enum:
            - StartAfterEnd
        - type: string
          enum:
            - EndInFuture
        - type: string
          enum:
            - StartEqualsEnd
        - type: string
          enum:
            - ConversionError
        - type: object
          required:
            - Other
          properties:
            Other:
              type: string
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: x-api-key

````