Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: base_currency_access_restricted #117

Open
leongaban opened this issue Feb 1, 2019 · 18 comments
Open

Error: base_currency_access_restricted #117

leongaban opened this issue Feb 1, 2019 · 18 comments

Comments

@leongaban
Copy link

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);
  }
}
@rmorrin
Copy link

rmorrin commented Feb 6, 2019

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

@MarcoTomasRodriguez
Copy link

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.

@DataStrategist
Copy link

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)

@zeroidentidad
Copy link

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

@AltafPk
Copy link

AltafPk commented May 28, 2020

Try this

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

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

@dylan-lom
Copy link

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

@AltafPk
Copy link

AltafPk commented Jun 6, 2020

@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

@lostpebble
Copy link

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.

@Zeshi97-bit
Copy link

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

@matthysdt
Copy link

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

@marcotas
Copy link

marcotas commented Apr 7, 2021

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

@Luckz
Copy link

Luckz commented Apr 8, 2021

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.

@vojtasvoboda
Copy link

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

@Luckz
Copy link

Luckz commented Apr 20, 2021

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

@itsbhm
Copy link

itsbhm commented Apr 26, 2021

Try out this logic

@lochiwei
Copy link

@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

@akhil018
Copy link

akhil018 commented Jul 20, 2021

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.

@petertoth-dev
Copy link

petertoth-dev commented Nov 9, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests