hakanensari / frankfurter

💱 Open-source API that wraps currency data provided by the ECB

Home Page:https://www.frankfurter.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

base rate in EUR even though requested USD

gingerlime opened this issue · comments

Hi there,

Thanks for frankfurter (and previously fixer)! It works great for us.

However this morning we bumped into a strange issue: the base rate suddenly switched to EUR, even though we're requesting USD as the base. We haven't touched this code recently, but noticed that suddenly the data returned changed

[1] pry(main)> response = RestClient.get(
[1] pry(main)*   "https://frankfurter.app/latest",
[1] pry(main)*   :params => {:base => "USD"}
[1] pry(main)* )
=> <RestClient::Response 200 "{\"amount\":1...">
[2] pry(main)> JSON.parse(response)
=> {"amount"=>1.0,
 "base"=>"EUR",
 "date"=>"2019-12-23",
 "rates"=>
  {"AUD"=>1.6008,
   "BGN"=>1.9558,
   "BRL"=>4.522,
   "CAD"=>1.4577,
   "CHF"=>1.087,
   "CNY"=>7.7652,
   "CZK"=>25.499,
   "DKK"=>7.4719,
   "GBP"=>0.85708,
   "HKD"=>8.6232,
   "HRK"=>7.446,
   "HUF"=>331.24,
   "IDR"=>15490,
   "ILS"=>3.8452,
   "INR"=>78.946,
   "ISK"=>135.4,
   "JPY"=>121.18,
   "KRW"=>1288.52,
   "MXN"=>21.002,
   "MYR"=>4.5878,
   "NOK"=>9.913,
   "NZD"=>1.6732,
   "PHP"=>56.471,
   "PLN"=>4.2609,
   "RON"=>4.7733,
   "RUB"=>69.03,
   "SEK"=>10.4473,
   "SGD"=>1.5018,
   "THB"=>33.408,
   "TRY"=>6.5834,
   "USD"=>1.1075,
   "ZAR"=>15.7605}}

Any suggestions on how to resolve this?

@gingerlime We recently migrated the API to a new subdomain (api.frankfurter.app) and redirected the old endpoints. It seems we made a mistake in the redirection rules, which resulted in query parameters being dropped. This should now be fixed.

Thanks @hakanensari. I can confirm that the redirect now works as expected. I did notice that the param name changed on redirect (I used base and got redirected to from). Should we stop using base and switch to form as well?

It's up to you. I prefer the more intuitive to and from but am keeping the older names intact. In any case, I just updated the redirect rules so base should remain unchanged.

On a different note, if you have not already done so, it would be a good idea to update the base URL to api.frankfurter.app to avoid the extra hop.

Good to know that base is still available :)

Yes, we already updated the base URL to use api.frankfurter.app. Is there a channel we can subscribe to for announcement / breaking changes etc going forward?

Other than this episode, which certainly taught me a thing or two about how (not) to migrate URLs 😳, the project has remained stable over the past few years, with no deprecations or removals.

Going forwards, I'll add a CHANGELOG and start tagging releases for the Docker image. You could then watch the repo for releases.

Thanks @hakanensari! That's a good idea. I used this IFTTT recipe to watch the releases atom feed.

Another thank you. The IFTTT rule worked :)