OANDA API troubleshooting guide
Why can I no longer see or copy my API token?
For account security, your API token is displayed only once upon generation. Once you refresh or navigate away from the page, the API token is permanently hidden. If you have not saved it, you need to revoke the current API token and generate a new one.
"Insufficient authorization to perform request" error message
The most common reason for this error is sending a request to the incorrect environment endpoint for your API token type, or your API token is no longer valid. To resolve this issue, follow these steps:
-
Ensure you use the correct URL depending on the account type (live or demo).
-
After creating a new account, revoke your current API token and generate a new one to access the new account through the v20 REST API.
"Insufficient authorization to perform request" error message when using Java wrapper
If your JAR files for dependent libraries are out of date, you may receive this error while executing Java code, even if your accountID and token work perfectly when using standard curl commands.
To resolve this issue, follow these steps:
-
Upgrade all libraries by deleting the external JAR files.
-
Reload the files’ latest versions.
The following list shows the current libraries you may refer to:
-
common-logging-1.1.1.jar
-
gson-2.6.2.jar
-
httpclient-4.0-alpha4.jar
-
httpclient-4.3.5.jar
-
httpcore-4.3.2.jar
-
v20-3.0.21.jar
-
JRE System Library
-
Maven Dependencies (junit-3.8.1.jar)
"Insufficient authorization to perform request" error message when using oandapyv20
oandapyV20 is a third-party wrapper and is not officially supported by OANDA, so we cannot help with solving any issues. That is why we provide an official v20 Python wrapper on our developer page.
If you continue to use the third-party wrapper, confirm the following items:
-
Environment settings: In the wrapper's sample code, the default environment is often set to practice/demo. If you are trading on a live account, you must edit the code to reflect the live environment:
client = oandapyV20.API(access_token=access_token, environment="live") -
Authentication header: Ensure your authentication token is valid and has been correctly formatted as a Bearer token in the HTTP Authorization header.
"The provided request was forbidden" error message
The most common reason for this error is utilizing an invalid accountID in your request path. To locate your correct account ID, refer to this topic.
Why is historical data different from live data?
OANDA’s historical data can differ from live streaming data because the API serves different pricing segments depending on the endpoint used. Take note of the following items:
-
Historical data (
/candles): The historical candlestick endpoint provides base-price group data. -
Live data (polling and streaming): The live pricing endpoints utilize your specific
accountIDto return live data tailored to your account's specific pricing group and spread profile.
Using
"GET /v3/accounts/{accountID}/orders" returns an empty order list
By default, the /v3/accounts/{accountID}/orders endpoint only queries pending orders. Once an order is filled, it transitions into an open trade and is no longer classified as a pending order. If all your submitted orders have executed or been cancelled, the endpoint returns an empty list.
To view orders that have already executed, closed, or cancelled, you must specify the state query parameter (such as state=FILLED, state=CANCELLED, or state=ALL)
state=ALL on its own. On accounts with extensive trading history, requesting all states without additional filters forces the API to retrieve every order ever submitted on that account. This creates an unnecessarily large payload that can significantly slow down server response times, cause request timeouts, or cause your client application to crash.Always narrow the scope of your request by combining multiple query parameters, such as pairing state with instrument and a count limit.
Refer to the following request example:
curl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
"https://api-fxtrade.oanda.com/v3/accounts/<YOUR_ACCOUNT_ID>/orders?instrument=EUR_USD&state=FILLED&count=50"
For a full list of values for the OrderStateFilter, refer to this page.
Why can I not construct open-high-low-close (OHLC) candlesticks using the stream endpoint?
You cannot reliably build accurate OHLC candlestick data using the streaming endpoint because the streaming response packets do not guarantee they capture the exact open, high, low, and close ticks for a specific timeframe.
To create accurate candlestick charts containing all price activity, use the instrument/candles endpoint, which queries the server for the finalized, authoritative data once a time period (bar) has closed.
Experiencing a different error?
If you receive a status code or error message not listed above, refer to this page for a comprehensive list of API error codes, rejection reasons, and their solutions.
Technical support
We do not review, write, or debug custom code. If you have any issues, verify your implementation against the following basic functionality checklist:
-
Environment URL: Confirm whether your script connects to the practice/demo or live URL.
-
API token: Verify that your token matches the environment you are accessing and has not been regenerated.
-
Endpoint accuracy: Ensure the endpoint path exists in the official documentation and is spelled correctly.
-
Grammar and syntax: Check your code carefully for spelling errors, incorrect capitalization, missing quotation marks, or malformed JSON syntax.
If you still need technical support after reviewing the above checklist and our documentation, email api@oanda.com and include the following items:
-
Your complete HTTP request payload and URL.
-
Your server response logs and error codes.
-
Any other relevant contextual information (such as the specific
accountIDand timestamp of the error).