fixer icon indicating copy to clipboard operation
fixer copied to clipboard

Error: base_currency_access_restricted

Open leongaban opened this issue 6 years ago • 19 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);
  }
}

leongaban avatar Feb 01 '19 21:02 leongaban

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)!

rmorrin avatar Feb 06 '19 11:02 rmorrin

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.

MarcoTomasRodriguez avatar Feb 10 '19 20:02 MarcoTomasRodriguez

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)

DataStrategist avatar Oct 16 '19 08:10 DataStrategist

try to use with https://rapidapi.com/fixer/api/fixer-currency

zeroidentidad avatar Dec 14 '19 04:12 zeroidentidad

Try this

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

Please note that instead of 'base', 'cbase' is passed.

AltafPk avatar May 28 '20 00:05 AltafPk

@AltafPk the cbase option is ignored and doesn't change the response base -- it's still in base: EUR

dylan-lom avatar Jun 04 '20 00:06 dylan-lom

@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

AltafPk avatar Jun 06 '20 09:06 AltafPk

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.

lostpebble avatar Oct 19 '20 12:10 lostpebble

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

Zeshi97-bit avatar Dec 22 '20 06:12 Zeshi97-bit

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

matthysdt avatar Jan 27 '21 14:01 matthysdt

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

marcotas avatar Apr 07 '21 17:04 marcotas

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 avatar Apr 08 '21 00:04 Luckz

@Luckz Why openexchagerates.org? They have pricing $12/m and on exchangeratesapi.io you have $10/m?

vojtasvoboda avatar Apr 20 '21 10:04 vojtasvoboda

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

Luckz avatar Apr 20 '21 19:04 Luckz

Try out this logic

itsbhm avatar Apr 26 '21 08:04 itsbhm

@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

lochiwei avatar Jun 11 '21 03:06 lochiwei

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.

akhil018 avatar Jul 20 '21 17:07 akhil018

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

petertoth-dev avatar Nov 09 '23 12:11 petertoth-dev