OANDA Instruments API

The Instruments API from OANDA — 5 operation(s) for instruments.

Operations 5

GET /instruments/{instrument}/candles Get Candlesticks #
GET /instruments/{instrument}/price Price #
GET /instruments/{instrument}/price/range Get Prices #
GET /instruments/{instrument}/orderBook Get Order Book
GET /instruments/{instrument}/positionBook Get Position Book

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/oanda-instruments-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

oanda-instruments-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: OANDA v20 REST Accounts Instruments API
  description: The full OANDA v20 REST API Specification. This specification defines how to interact with v20 Accounts, Trades, Orders, Pricing and more.
  contact:
    name: OANDA API Support
    url: http://developer.oanda.com/rest-live-v20/introduction/
    email: api@oanda.com
  license:
    name: MIT
    url: https://github.com/oanda/v20-openapi/blob/master/LICENSE.txt
  version: 3.0.25
servers:
- url: /v3
tags:
- name: Instruments
paths:
  /instruments/{instrument}/candles:
    get:
      summary: Get Candlesticks
      description: Fetch candlestick data for an instrument.
      operationId: getInstrumentCandles
      parameters:
      - $ref: '#/components/parameters/authorizationHeaderParam'
      - $ref: '#/components/parameters/acceptDatetimeFormatHeaderParam'
      - $ref: '#/components/parameters/instrumentNamePathParam'
      - name: price
        description: The Price component(s) to get candlestick data for. Can contain any combination of the characters "M" (midpoint candles) "B" (bid candles) and "A" (ask candles).
        in: query
        schema:
          type: string
      - name: granularity
        description: The granularity of the candlesticks to fetch
        in: query
        schema:
          type: string
      - name: count
        description: The number of candlesticks to return in the reponse. Count should not be specified if both the start and end parameters are provided, as the time range combined with the graularity will determine the number of candlesticks to return.
        in: query
        schema:
          type: integer
      - name: from
        description: The start of the time range to fetch candlesticks for.
        in: query
        schema:
          type: string
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
      - name: to
        description: The end of the time range to fetch candlesticks for.
        in: query
        schema:
          type: string
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
      - name: smooth
        description: A flag that controls whether the candlestick is "smoothed" or not.  A smoothed candlestick uses the previous candle's close price as its open price, while an unsmoothed candlestick uses the first price from its time range as its open price.
        in: query
        schema:
          type: boolean
      - name: includeFirst
        description: A flag that controls whether the candlestick that is covered by the from time should be included in the results. This flag enables clients to use the timestamp of the last completed candlestick received to poll for future candlesticks but avoid receiving the previous candlestick repeatedly.
        in: query
        schema:
          type: boolean
      - name: dailyAlignment
        description: The hour of the day (in the specified timezone) to use for granularities that have daily alignments.
        in: query
        schema:
          type: integer
      - name: alignmentTimezone
        description: The timezone to use for the dailyAlignment parameter. Candlesticks with daily alignment will be aligned to the dailyAlignment hour within the alignmentTimezone.  Note that the returned times will still be represented in UTC.
        in: query
        schema:
          type: string
      - name: weeklyAlignment
        description: The day of the week used for granularities that have weekly alignment.
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Pricing information has been successfully provided.
          headers:
            RequestID:
              description: The unique identifier generated for the request
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                properties:
                  instrument:
                    type: string
                    description: The instrument whose Prices are represented by the candlesticks.
                    format: A string containing the base currency and quote currency delimited by a "_".
                  granularity:
                    type: string
                    description: The granularity of the candlesticks provided.
                    enum:
                    - S5
                    - S10
                    - S15
                    - S30
                    - M1
                    - M2
                    - M4
                    - M5
                    - M10
                    - M15
                    - M30
                    - H1
                    - H2
                    - H3
                    - H4
                    - H6
                    - H8
                    - H12
                    - D
                    - W
                    - M
                  candles:
                    type: array
                    description: The list of candlesticks that satisfy the request.
                    items:
                      $ref: '#/components/schemas/Candlestick'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '404':
          $ref: '#/components/responses/404'
        '405':
          $ref: '#/components/responses/405'
      tags:
      - Instruments
  /instruments/{instrument}/price:
    get:
      summary: Price
      description: Fetch a price for an instrument. Accounts are not associated in any way with this endpoint.
      operationId: getInstrumentPrice
      parameters:
      - $ref: '#/components/parameters/authorizationHeaderParam'
      - $ref: '#/components/parameters/acceptDatetimeFormatHeaderParam'
      - $ref: '#/components/parameters/instrumentNamePathParam'
      - name: time
        description: The time at which the desired price is in effect. The current price is returned if no time is provided.
        in: query
        schema:
          type: string
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
      responses:
        '200':
          description: Pricing information has been successfully provided.
          headers:
            RequestID:
              description: The unique identifier generated for the request
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                properties:
                  price:
                    $ref: '#/components/schemas/Price'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '404':
          $ref: '#/components/responses/404'
        '405':
          $ref: '#/components/responses/405'
      tags:
      - Instruments
  /instruments/{instrument}/price/range:
    get:
      summary: Get Prices
      description: Fetch a range of prices for an instrument. Accounts are not associated in any way with this endpoint.
      operationId: getInstrumentPriceRange
      parameters:
      - $ref: '#/components/parameters/authorizationHeaderParam'
      - $ref: '#/components/parameters/acceptDatetimeFormatHeaderParam'
      - $ref: '#/components/parameters/instrumentNamePathParam'
      - name: from
        description: The start of the time range to fetch prices for.
        in: query
        required: true
        schema:
          type: string
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
      - name: to
        description: The end of the time range to fetch prices for. The current time is used if this parameter is not provided.
        in: query
        schema:
          type: string
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
      responses:
        '200':
          description: Pricing information has been successfully provided.
          headers:
            RequestID:
              description: The unique identifier generated for the request
              schema:
                type: string
            Link:
              description: A link to the next page of results if the results were paginated
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                properties:
                  prices:
                    type: array
                    description: The list of prices that satisfy the request.
                    items:
                      $ref: '#/components/schemas/Price'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '404':
          $ref: '#/components/responses/404'
        '405':
          $ref: '#/components/responses/405'
      tags:
      - Instruments
  /instruments/{instrument}/orderBook:
    get:
      summary: Get Order Book
      description: Fetch an order book for an instrument.
      parameters:
      - $ref: '#/components/parameters/authorizationHeaderParam'
      - $ref: '#/components/parameters/acceptDatetimeFormatHeaderParam'
      - $ref: '#/components/parameters/instrumentNamePathParam'
      - name: time
        description: The time of the snapshot to fetch. If not specified, then the most recent snapshot is fetched.
        in: query
        schema:
          type: string
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
      responses:
        '200':
          description: The order book has been successfully provided.
          headers:
            Content-Encoding:
              description: Value will be "gzip" regardless of provided Accept-Encoding header
              schema:
                type: string
            Link:
              description: A link to the next/previous order book snapshot.
              schema:
                type: string
            RequestID:
              description: The unique identifier generated for the request
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                properties:
                  orderBook:
                    $ref: '#/components/schemas/OrderBook'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '404':
          $ref: '#/components/responses/404'
        '405':
          $ref: '#/components/responses/405'
      tags:
      - Instruments
  /instruments/{instrument}/positionBook:
    get:
      summary: Get Position Book
      description: Fetch a position book for an instrument.
      parameters:
      - $ref: '#/components/parameters/authorizationHeaderParam'
      - $ref: '#/components/parameters/acceptDatetimeFormatHeaderParam'
      - $ref: '#/components/parameters/instrumentNamePathParam'
      - name: time
        description: The time of the snapshot to fetch. If not specified, then the most recent snapshot is fetched.
        in: query
        schema:
          type: string
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
      responses:
        '200':
          description: The position book has been successfully provided.
          headers:
            Content-Encoding:
              description: Value will be "gzip" regardless of provided Accept-Encoding header
              schema:
                type: string
            Link:
              description: A link to the next/previous position book snapshot.
              schema:
                type: string
            RequestID:
              description: The unique identifier generated for the request
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                properties:
                  positionBook:
                    $ref: '#/components/schemas/PositionBook'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '404':
          $ref: '#/components/responses/404'
        '405':
          $ref: '#/components/responses/405'
      tags:
      - Instruments
components:
  schemas:
    Candlestick:
      type: object
      description: The Candlestick representation
      properties:
        time:
          type: string
          description: The start time of the candlestick
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
        bid:
          $ref: '#/components/schemas/CandlestickData'
        ask:
          $ref: '#/components/schemas/CandlestickData'
        mid:
          $ref: '#/components/schemas/CandlestickData'
        volume:
          type: integer
          description: The number of prices created during the time-range represented by the candlestick.
        complete:
          type: boolean
          description: A flag indicating if the candlestick is complete. A complete candlestick is one whose ending time is not in the future.
    Price:
      type: object
      description: The Price representation
      properties:
        instrument:
          type: string
          description: The Price's Instrument.
          format: A string containing the base currency and quote currency delimited by a "_".
        tradeable:
          type: boolean
          description: Flag indicating if the Price is tradeable or not
        timestamp:
          type: string
          description: The date/time when the Price was created.
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
        baseBid:
          type: string
          description: The base bid price as calculated by pricing.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        baseAsk:
          type: string
          description: The base ask price as calculated by pricing.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        bids:
          type: array
          description: The list of prices and liquidity available on the Instrument's bid side. It is possible for this list to be empty if there is no bid liquidity currently available for the Instrument in the Account.
          items:
            $ref: '#/components/schemas/PriceBucket'
        asks:
          type: array
          description: The list of prices and liquidity available on the Instrument's ask side. It is possible for this list to be empty if there is no ask liquidity currently available for the Instrument in the Account.
          items:
            $ref: '#/components/schemas/PriceBucket'
        closeoutBid:
          type: string
          description: The closeout bid price. This price is used when a bid is required to closeout a Position (margin closeout or manual) yet there is no bid liquidity. The closeout bid is never used to open a new position.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        closeoutAsk:
          type: string
          description: The closeout ask price. This price is used when an ask is required to closeout a Position (margin closeout or manual) yet there is no ask liquidity. The closeout ask is never used to open a new position.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
    OrderBookBucket:
      type: object
      description: The order book data for a partition of the instrument's prices.
      properties:
        price:
          type: string
          description: The lowest price (inclusive) covered by the bucket. The bucket covers the price range from the price to price + the order book's bucketWidth.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        longCountPercent:
          type: string
          description: The percentage of the total number of orders represented by the long orders found in this bucket.
          format: A decimal number encoded as a string. The amount of precision provided depends on what the number represents.
        shortCountPercent:
          type: string
          description: The percentage of the total number of orders represented by the short orders found in this bucket.
          format: A decimal number encoded as a string. The amount of precision provided depends on what the number represents.
    CandlestickData:
      type: object
      description: The price data (open, high, low, close) for the Candlestick representation.
      properties:
        o:
          type: string
          description: The first (open) price in the time-range represented by the candlestick.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        h:
          type: string
          description: The highest price in the time-range represented by the candlestick.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        l:
          type: string
          description: The lowest price in the time-range represented by the candlestick.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        c:
          type: string
          description: The last (closing) price in the time-range represented by the candlestick.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
    PositionBook:
      type: object
      description: The representation of an instrument's position book at a point in time
      properties:
        instrument:
          type: string
          description: The position book's instrument
          format: A string containing the base currency and quote currency delimited by a "_".
        time:
          type: string
          description: The time when the position book snapshot was created
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
        price:
          type: string
          description: The price (midpoint) for the position book's instrument at the time of the position book snapshot
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        bucketWidth:
          type: string
          description: The price width for each bucket. Each bucket covers the price range from the bucket's price to the bucket's price + bucketWidth.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        buckets:
          type: array
          description: The partitioned position book, divided into buckets using a default bucket width. These buckets are only provided for price ranges which actually contain order or position data.
          items:
            $ref: '#/components/schemas/PositionBookBucket'
    PriceBucket:
      type: object
      description: A Price Bucket represents a price available for an amount of liquidity
      properties:
        price:
          type: string
          description: The Price offered by the PriceBucket
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        liquidity:
          type: integer
          description: The amount of liquidity offered by the PriceBucket
    OrderBook:
      type: object
      description: The representation of an instrument's order book at a point in time
      properties:
        instrument:
          type: string
          description: The order book's instrument
          format: A string containing the base currency and quote currency delimited by a "_".
        time:
          type: string
          description: The time when the order book snapshot was created.
          format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).
        price:
          type: string
          description: The price (midpoint) for the order book's instrument at the time of the order book snapshot
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        bucketWidth:
          type: string
          description: The price width for each bucket. Each bucket covers the price range from the bucket's price to the bucket's price + bucketWidth.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        buckets:
          type: array
          description: The partitioned order book, divided into buckets using a default bucket width. These buckets are only provided for price ranges which actually contain order or position data.
          items:
            $ref: '#/components/schemas/OrderBookBucket'
    PositionBookBucket:
      type: object
      description: The position book data for a partition of the instrument's prices.
      properties:
        price:
          type: string
          description: The lowest price (inclusive) covered by the bucket. The bucket covers the price range from the price to price + the position book's bucketWidth.
          format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.
        longCountPercent:
          type: string
          description: The percentage of the total number of positions represented by the long positions found in this bucket.
          format: A decimal number encoded as a string. The amount of precision provided depends on what the number represents.
        shortCountPercent:
          type: string
          description: The percentage of the total number of positions represented by the short positions found in this bucket.
          format: A decimal number encoded as a string. The amount of precision provided depends on what the number represents.
  parameters:
    authorizationHeaderParam:
      name: Authorization
      description: The authorization bearer token previously obtained by the client
      in: header
      required: true
      schema:
        type: string
        format: The string 'Bearer ' followed by the token.
    acceptDatetimeFormatHeaderParam:
      name: Accept-Datetime-Format
      description: Format of DateTime fields in the request and response.
      in: header
      schema:
        type: string
    instrumentNamePathParam:
      name: instrument
      description: Name of the Instrument
      in: path
      required: true
      schema:
        type: string
        format: A string containing the base currency and quote currency delimited by a "_".
  responses:
    '405':
      description: Method Not Allowed. The client has attempted to access an endpoint using an HTTP method that is not supported.
      headers:
        RequestID:
          description: The unique identifier generated for the request
          schema:
            type: string
      content:
        application/json:
          schema:
            type: object
            properties:
              errorCode:
                type: string
                description: The code of the error that has occurred. This field may not be returned for some errors.
              errorMessage:
                type: string
                description: The human-readable description of the error that has occurred.
    '400':
      description: Bad Request. The client has provided invalid data to be processed by the server.
      headers:
        RequestID:
          description: The unique identifier generated for the request
          schema:
            type: string
      content:
        application/json:
          schema:
            type: object
            properties:
              errorCode:
                type: string
                description: The code of the error that has occurred. This field may not be returned for some errors.
              errorMessage:
                type: string
                description: The human-readable description of the error that has occurred.
    '401':
      description: Unauthorized. The endpoint being access required the client to authenticated, however the the authentication token is invalid or has not been provided.
      headers:
        RequestID:
          description: The unique identifier generated for the request
          schema:
            type: string
      content:
        application/json:
          schema:
            type: object
            properties:
              errorCode:
                type: string
                description: The code of the error that has occurred. This field may not be returned for some errors.
              errorMessage:
                type: string
                description: The human-readable description of the error that has occurred.
    '404':
      description: Not Found. The client has attempted to access an entity that does not exist.
      headers:
        RequestID:
          description: The unique identifier generated for the request
          schema:
            type: string
      content:
        application/json:
          schema:
            type: object
            properties:
              errorCode:
                type: string
                description: The code of the error that has occurred. This field may not be returned for some errors.
              errorMessage:
                type: string
                description: The human-readable description of the error that has occurred.