Request bid, ask and mid prices for all currencies, where available.
We calculate the best available (top of the book) buy and sell prices for the majority of currencies we offer, and provide these instead of a single midpoint rate when you use the show_bid_ask
API parameter.
Using this parameter replaces the regular results, so that instead of a midpoint currency value for each returned currency symbol, you will receive an object containing ask
, bid
, and mid
.
Currently available for clients of our VIP Platinum tier. Please contact us if you would like to test out this feature.
Request 'Bid-Ask' Rates
Append the show_bid_ask
query parameter to your latest.json
, historical/
or spot.json
API request, like so:
https://openexchangerates.org/api/latest.json
?app_id=YOUR_APP_ID
&show_bid_ask=1
$.get('https://openexchangerates.org/api/latest.json', {app_id: 'YOUR_APP_ID', show_alternative: 1}, function(data) {
console.log(data);
});
The response format is the same as the standard API response, except that instead of a single (midpoint) value for each returned currency symbol, you will now receive an object containing bid
, ask
and mid
for each currency where these are available*:
{
"disclaimer": "...",
"license": "...",
"timestamp": 1501084644,
"base": "USD",
"rates": {
"AED": {
"bid": 3.67229,
"ask": 3.67378,
"mid": 3.673035
},
"AFN": {
"bid": 68.399726,
"ask": 68.690659,
"mid": 68.545193
},
/* ... */
}
*For some currencies, we do not currently provide bid and ask prices. In such cases, or if we don't have bid
and ask
prices available for a given currency or data, we will not return them for that symbol.
You will still receive mid
, but bid
and ask
will not be included.
Basic Code Samples
$.get('https://openexchangerates.org/api/latest.json', {app_id: 'YOUR_APP_ID', show_bid_ank: 1}, function(data) {
console.log("USD/GBP 'bid' price: " + data.rates.GBP.bid);
console.log("USD/GBP 'ask' price: " + data.rates.GBP.ask);
});
More code samples are on their way! Please get in touch if you'd like to submit a new/improved code sample in your languague or framework.
Combining Parameters
The show_bid_ask
parameter can be combined with any other parameters available, such as base
and symbols
, and historical queries.