Authentication

Authentication with an API key is required to access all of the API’s endpoints. You can find your API key by logging in to your account at https://subscriptions.oanda.com, as shown in the screenshot below:

https://subscriptions.oanda.com

The API allows you to authenticate using an HTTP header or a query parameter, as described in the next section.

If you use HTTP header authentication in conjunction with a query parameter, the header is used and the query parameter is discarded.

Please visit the OANDA Exchange Rates page to sign-up for a free trial.

HTTP Header

RECOMMENDED

Add the Authorization header to all requests:

curl -X GET -H "Authorization: Bearer <API_KEY>"
     "https://web-services.oanda.com/rates/api/v2/currencies.json"

Replace <API_KEY> with your API key. Do not include the angle brackets.

Query Parameter

NOT RECOMMENDED

Add the api_key query parameter to all requests:

curl -X GET "https://web-services.oanda.com/rates/api/v2/currencies.json?api_key=<API_KEY>"

Replace <API_KEY> with your API key. Do not include the angle brackets in the URL.

This method is not recommended, as it is insecure. As the API key is within the URL, it may be logged. This method should only be used if the client you use to access the API is unable to set headers.