Error: base_currency_access_restricted
leongaban opened this issue ยท 18 comments
Hi, I tried using base=USD
however I get back the following error:
{"success":false,"error":{"code":105,"type":"base_currency_access_restricted"}}
url: http://data.fixer.io/api/latest?base=USD&access_key=35a3ad0f2f253d37131b68cd1b5953fc
My services/api.ts file
import axios from 'axios'
import { converters } from '../utils'
const fixerAPI = 'http://data.fixer.io/api/';
const fixerKey = '35a3ad0f2f253d37131b68cd1b5953fc';
export const getLatest = async () => {
const fixer = axios.create({
baseURL: fixerAPI,
params: {
base: 'USD',
access_key: fixerKey
}
});
try {
const res = await fixer.get('latest');
const ratesArray = converters.ratesIntoArray(res);
return ratesArray;
} catch (err) {
console.error(err);
}
}
Is this on a free plan? I noticed on the pricing page it lists 'All Base Currencies' as a feature of the paid plans. I can't find any info around which ones are supported on the free tier, but at the very least EUR is working for me.
Also, you may not want want to include your real API key here (assuming the above is valid)!
You can't, that's for paid users. But you can try to convert all the values to dollars, dividing them by their value in dollars with respect to the euro.
Just ran into this. Not sure when it changed... but this should fix it:
## get thingie in Euros
df <- fixer_latest() %>% mutate(date = Sys.Date()) %>% spread(name, value)
## convert to dollars
df <- df %>% mutate_if(is.numeric, ~./df$USD)
try to use with https://rapidapi.com/fixer/api/fixer-currency
Try this
http://data.fixer.io/api/latest?cbase=USD&access_key=35a3ad0f2f253d37131b68cd1b5953fc
Please note that instead of 'base', 'cbase' is passed.
@AltafPk the cbase option is ignored and doesn't change the response base -- it's still in base: EUR
@dylan-lom Thanks for highlighting that, looks like fixer.io doesn't offer change of base currency in their free plan, better to use some other API like https://api.exchangeratesapi.io/latest?base=CAD
I find it a little bit ridiculous that I had to scrounge around the internet and find this obscure github issue in order to find out that on the free plan fixer only allows EUR
as a base currency... Even the error messages don't offer any indication besides saying "access restricted" - are we suppose to try them all and do a process of deduction?
This can clearly be displayed on the pricing / compare plans page.
This error is because of free plain. in free plain you can take base currency only EUR.
http://data.fixer.io/api/latest?access_key=Enter_your_access_key_here&base=EUR&symbols=USD
@dylan-lom Thanks for highlighting that, looks like fixer.io doesn't offer change of base currency in their free plan, better to use some other API like https://api.exchangeratesapi.io/latest?base=CAD
Good option, unfortunately exchangeratesapi.io only updates their rates once a day (from my experience).
@dylan-lom Thanks for highlighting that, looks like fixer.io doesn't offer change of base currency in their free plan, better to use some other API like https://api.exchangeratesapi.io/latest?base=CAD
It seems exchangeratesapi.io
is not free anymore, this link returned this response to me:
{
"success": false,
"error": {
"code": 101,
"type": "missing_access_key",
"info": "You have not supplied an API Access Key. [Required format: access_key=YOUR_ACCESS_KEY]"
}
}
I've created a free account on both fixer.io and exchangeratesapi.io and they are the same platform, with different databases. Even their plans are the same.
There's multiple websites owned by apilayer
that in the end all are the same thing.
https://fixer.io/product
https://exchangeratesapi.io/pricing/
https://currencylayer.com/product
I made the switch to https://openexchangerates.org/ :
const exchangeAPI = (currencies) => `http://api.exchangeratesapi.io/latest?symbols=${currencies}&base=USD&access_key=MYKEY`;
const exchangeAPI = (currencies) => `https://openexchangerates.org/api/latest.json?symbols=${currencies}&base=USD&app_id=MYAPP`;
..because I really cba to base my personal-use code on something else than USD.
In case you use that, apilayer APIs have a property: "date":"2021-04-08" and for openexchangerates you get a unix timestamp instead.
@Luckz Why openexchagerates.org? They have pricing $12/m and on exchangeratesapi.io you have $10/m?
@Luckz Why openexchagerates.org? They have pricing $12/m and on exchangeratesapi.io you have $10/m?
@vojtasvoboda I used the free plan on each.
-> When the base=USD
(and https access?) was removed from the free offers on apilayer sites, I had to move to openexchangerates to not have to re-do all my code to base it on EUR, and to avoid CORS issues etc from accessing an insecure resource (HTTP) from a secure site (HTTPS). I only need to get rates a few times per day for a tool I wrote. The free plan might of course be insufficient for whatever bigger project you work on.
@dylan-lom Thanks for highlighting that, looks like fixer.io doesn't offer change of base currency in their free plan, better to use some other API like https://api.exchangeratesapi.io/latest?base=CAD
same thing with http://api.exchangeratesapi.io/latest?access_key=API_KEY&base=CAD
(free plan):
response:
{"success":false,"error":{"code":105,"type":"base_currency_access_restricted"}}
base_currency_access_restricted โ
You can't, that's for paid users. But you can try to convert all the values to dollars, dividing them by their value in dollars with respect to the euro.
this is a simple hack it seems. for example considering you are getting base EURO exchange rates for all other countries
lets assume you want to convert 20 USD to any other country currency (target currency)
1 EURO = 1.177461 USD so 1 USD = 0.849285029 EUROS ( 1 / 1.177461 )
20 USD * 0.849285029 EUROS = 16.985700588 EUROS
16.985700588 EUROS * any other country currency rate (target currency exchange rate) = x (target currency amount)
but I appreciate if you use their paid plans as they provide paid features.
Wow! Smart, you can always learn something ...
formula in PHP:
static function convert($value, $from, $to ): float|int
{
self::getExchangeRates([]);
$from_rate = self::$fx_rates->{$from};
$to_rate = self::$fx_rates->{$to};
return $value*((1/$from_rate)*$to_rate);
}
Where fx_rates
is the response of /v1/latest
using the rates
property