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

Most upvoted comments

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.

Try this

http://data.fixer.io/api/latest?cbase=USD&access_key=35a3ad0f2f253d37131b68cd1b5953fc

Please note that instead of ‘base’, ‘cbase’ is passed.

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.

@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:

    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

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.

@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.

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.