How does OANDA’s API work?
Integrated market data
Get real-time rates for all tradeable pairs 24 hours a day, and access historical pricing information dating back to 2005. Our historical REST endpoints are highly customisable for pulling specific time bars (ranging from 5-second bars to monthly candlesticks).
WebSockets
We utilise stable, dedicated streaming sockets to separate real-time price delivery from order placement.
Streaming
Our architecture natively separates heavy data loads by streaming real-time ticks continuously rather than forcing developers to poll.
HTTP request/response cycle
This defines how we handle all transactional tasks (placing orders, modifying stops) reliably using standard JSON payloads.
Endpoint
Our developer portal provides highly distinct, well-isolated endpoints categorised clearly by function (Accounts, Orders, Trades, Pricing, Positions and Transactions).
Sandbox environments
Our API gives an excellent, completely unrestricted "FxTrade Practice" sandbox tier that exactly mirrors the production API endpoints for paper trading and backtesting.
Bid/Ask pricing fields
Our API passes full, independent Bid and Ask price objects across both REST and WebSocket feeds.
HTTP Persistent Connections (Keep-Alive)
The API servers actively support and require Keep-Alive configurations to minimise connection overhead.
Transaction system / TransactionID
The API relies on a highly rigorous, sequential transaction tracking engine (TransactionID) that makes state auditing incredibly stable.
Diff
Instead of downloading an entire portfolio block repeatedly, our transaction endpoint allows you to pass the last known transaction ID to fetch only the incremental changes ("diff") since your last call.
Build code to monitor strategies
Generate your personal token to access OANDA's API. By clicking Generate, you are acknowledging that you have read, understand and agree to be legally bound by the API Agreement.
How to get started
Learn
Explore our developer portal to understand:
Build
Once you’re up to speed, generate your personal access token to start building:
Test
After successfully testing out the API, use the sample code we’ve provided on our developer portal to help you start building your strategies with the API.
Each sample code comes with instructions and comments. Please note, you will need your personal token and account ID (see above).
Automate
Once you’re happy with the code you’ve built, set up and monitor your strategies as they execute automatically.
Effortless account opening in minutes
Go from application to trading in three easy steps: