Which API should I use?

  • Use v20 REST API only if you have a v20 account
  • Use v1 REST API if your account id contains only digits (ie. 2534253) as it is a legacy account

Troubleshooting & Errors


Service Outages

Occasionally the OANDA API might be down or unresponsive (most notably during our maintenance period). The OANDA API Status Page is a service hosted at an independent location that will provide up-to-the-minute information about the status of the various platforms. There is even a publicly available API to programatically check the status of the OANDA API with documentation available here.

The simplest way to check the current status of all of the services would be to look for the current_event information for each service in the GET services call outlined below.

curl http://api-status.oanda.com/api/v1/services

Common HTTP Error Responses

Following are common HTTP Error Responses that may be returned from the v20 REST API when an error occurs.

400 Bad Request

A “400 Bad Request” reponse may be returned from the v20 REST API when the client has provided invalid data to be processed. The response Content-Type will be application/json and has the following schema:

{
    # 
    # The code of the error that has occurred.  This field may not be returned
    # for some errors.
    # 
    errorCode : (string),

    # 
    # The human-readable description of the error that has occurred.
    # 
    errorMessage : (string, required)
}

401 Unauthorized

A “401 Unauthorized” reponse may be returned from the v20 REST API when the endpoint being accessed requires the client to be authenticated however the authentication token is invalid or has not been provided. The response Content-Type will be application/json and has the following schema:

{
    # 
    # The code of the error that has occurred.  This field may not be returned
    # for some errors.
    # 
    errorCode : (string),

    # 
    # The human-readable description of the error that has occurred.
    # 
    errorMessage : (string, required)
}

403 Forbidden

A “403 Forbidden” response may be returned from the v20 REST API when the client has provided a token that does not authorize them to perform the action implemented by the API endpoint. The response Content-Type will be application/json and has the following schema:

{
    # 
    # The code of the error that has occurred.  This field may not be returned
    # for some errors.
    # 
    errorCode : (string),

    # 
    # The human-readable description of the error that has occurred.
    # 
    errorMessage : (string, required)
}

404 Not Found

A “404 Not Found” response may be returned from the v20 REST API when the client is attempting to refer to an entity (Account, Trade, Order, Position, etc.) that does not exist. The response Content-Type will be application/json and has the following schema:

{
    # 
    # The code of the error that has occurred.  This field may not be returned
    # for some errors.
    # 
    errorCode : (string),

    # 
    # The human-readable description of the error that has occurred.
    # 
    errorMessage : (string, required)
}

405 Method Not Allowed

A “405 Method Not Allowed” response may be returned from the v20 REST API when the client is attempting to access an API endpoint with an HTTP method that is not supported. The response Content-Type will be application/json and has the following schema:

{
    # 
    # The code of the error that has occurred.  This field may not be returned
    # for some errors.
    # 
    errorCode : (string),

    # 
    # The human-readable description of the error that has occurred.
    # 
    errorMessage : (string, required)
}

416 Range Not Satisfiable

A “416 Range Not Satisfiable” response may be returned from the v20 REST API when the client has specified a range (time range or Transaction range) that is invalid or cannot be processed. The response Content-Type will be application/json and has the following schema:

{
    # 
    # The code of the error that has occurred.  This field may not be returned
    # for some errors.
    # 
    errorCode : (string),

    # 
    # The human-readable description of the error that has occurred.
    # 
    errorMessage : (string, required)
}