fixer: Error: base_currency_access_restricted
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);
  }
}
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 3
- Comments: 18
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
EURas 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.
Try this
http://data.fixer.io/api/latest?cbase=USD&access_key=35a3ad0f2f253d37131b68cd1b5953fc
Please note that instead of ‘base’, ‘cbase’ is passed.
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.
@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
Wow! Smart, you can always learn something …
formula in PHP:
Where
fx_ratesis the response of/v1/latestusing theratespropertyThere’s multiple websites owned by
apilayerthat in the end all are the same thing. https://fixer.io/product https://exchangeratesapi.io/pricing/ https://currencylayer.com/productI made the switch to https://openexchangerates.org/ :
…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.
It seems
exchangeratesapi.iois not free anymore, this link returned this response to me: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.
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.