Disclaimer: The OANDA API is currently available for use in our developer sandbox, where you are free to develop and test your apps. To use the API with production accounts, please email us at api@oanda.com.
Before getting into the details below, let's try using the API. Issue the following GET request using your favourite HTTP client. The response will tell you what price EUR/USD is currently trading at. Seriously, try it out.
http://api-sandbox.oanda.com/v1/instruments/EUR_USD/price
You'll get back some JSON that looks like:
{
"instrument":"EUR_USD",
"time":1353974468.336059,
"bid":1.29838,
"ask":1.29844
}
This response tells us that at the time we made the request (epoch time), the bid price of EUR/USD is 1.29838, and the ask price is 1.29844.
- Check out our getting started guide
- Check out a few example apps that use the API
- Check out our documentation to see what we offer
All requests will use http://api-sandbox.oanda.com as the base url, and follow the convention in the diagram below.
- An action (CRUD) can be performed on a resource
- A resource belongs to a collection
- A collection exists under a version
One or more CRUD (Create, Read, Update, Delete) operations can be performed on a single URL, depending on the action desired.
| POST (Create) | POST requests are used to submit new data |
| GET (Read) | GET requests are used to read data |
| PUT (Update) | PUT requests are used to modify existing data |
| DELETE (Delete) | DELETE requests are used to delete data |
##Authentication
In order to trade, you will need an OANDA account id. Creating a new user will automatically generate a new account id for you. While our API is still being drafted, you will not need your username/password for any purpose other than creating an account. Please be respectful of others by not trading on accounts that you don't own.
All requests require Content-Type: application/x-www-form-urlencoded unless specified otherwise.
All response will be in JSON format.
When an error occurs, the applicable HTTP response code is returned as well as an error message in the body in the following format:
{
"errorCode" : [OANDA error code, may or may kot be the same as the HTTP status code],
"message" : [a description of the error which occurred, intended for developers],
"moreInfo" : [a link to a web page describing the error and possible causes and solutions]
}| Resource | URI | Methods | Description |
|---|---|---|---|
| user | /users/:username | POST | User registration, user profile |
| account | /accounts/:account_id | GET | Contains account information for a specific account |
| account collection | /accounts | GET | Contains list of accounts for a specific user |
| trade | /accounts/:account_id/trades/:trade_id | GET, PUT, DELETE | Contains info of a specific trade. |
| trade collection | /accounts/:id/trades | GET, POST | Contain a list of trade for a specific account. Use POST to create new trades |
| order | /accounts/:account_id/orders/:order_id | GET, PUT, DELETE | Contains info of a specific order. GET to retrieve info. PUT to change, DELETE to delete. |
| order collection | /accounts/:account_id/orders | GET, POST | Contain a list of trade for a specific account. Use POST to create new trades |
| position collection | /accounts/:account_id/position | GET, DELETE | Contain a list of positions for a specific account. Use GET to retrieve. DELTE to delete existing position. |
| transaction | /accounts/:account_id/transactions/:trans_id | GET | Contains info of a specific transaction. |
| transaction collection | /accounts/:account_id/transaction | GET | Contains info of a list transactions. |
| rates | Market rates data. |


