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

Made compatible with new exchange rate api #88

Closed
wants to merge 3 commits into from

Conversation

DaBors
Copy link

@DaBors DaBors commented May 20, 2021

Note: This is not an optimal change just a hotfix to make the code work

You will need your own access_key which you can get for free after registering with 1000 request limit per month, please provide this key when you create CurrencyCodes as an argument CurrencyCodes(access_key)

Also note that with free tier they don't support HTTPS currently all request will be HTTP based by default

You will need your own access_key which you can get for free after registering with 1000 request limit per month, please provide this key when you create CurrencyCodes as an argument CurrencyCodes(access_key)

Also note that with free tier they don't support HTTPS currently all request will be HTTP based by default
@DaBors DaBors mentioned this pull request May 20, 2021
@bh
Copy link

bh commented May 21, 2021

Also note that with free tier they don't support HTTPS currently all request will be HTTP based by default

It's like online banking for free bank accounts without HTTPS!

@UltimaHoarder
Copy link

UltimaHoarder commented May 21, 2021

@DaBors I got an error on line 106. CurrencyRates() in converter.py was expecting the api key. I just put empty quotes instead.
Using Python 3.9.1
image

Script works for me after doing this. Thank you.

@DaBors
Copy link
Author

DaBors commented May 21, 2021

@DaBors I got an error on line 106. CurrencyRates() in converter.py was expecting the api key. I just put empty quotes instead.
Using Python 3.9.1
image

Script works for me after doing this. Thank you.

@DIGITALCRIMINAL Thank you for noticing that, should be fixed now.

@DillonB07
Copy link

Thank you for doing this. I was really confused when my program stopped working a day or two ago.
You've now fixed it for me if I can get this working!
I was creating a general Metric Unit Converter.
So, how do I use your version is what I wanted to ask?
Can I install it with pip?
Maybe you should edit the README to include this information.

@UltimaHoarder
Copy link

Thank you for doing this. I was really confused when my program stopped working a day or two ago.
You've now fixed it for me if I can get this working!
I was creating a general Metric Unit Converter.
So, how do I use your version is what I wanted to ask?
Can I install it with pip?
Maybe you should edit the README to include this information.

I ended up downloading the code and pasting it into my project. Couldn't get it to work with pip via github.

@DillonB07
Copy link

Please can you explain that?
I use https://repl.it
Would it be possible using that?

@thusodangersimon
Copy link

I don't think your get_rates method works. I keep getting only EUR exchange rates when I put different currencies in.
So for example I want the rates for AED, so the AED to AED exchange rate should be 1 but this is the output:
`

CurrencyRates(api_key).get_rates('AED', date(2021,5,23))
{'AED': 4.474332,
'AFN': 94.530512,
'ALL': 123.152614,
'AMD': 634.107629,
'ANG': 2.187004,
'AOA': 789.984166,
'ARS': 114.757918,
'AUD': 1.576311,
'AWG': 2.193321,
'AZN': 2.068216,
'BAM': 1.950216,
'BBD': 2.460118,
'BDT': 103.341762,
'BGN': 1.956166,
'BHD': 0.459218,
'BIF': 2401.019625,
'BMD': 1.218173,
'BND': 1.620595,
'BOB': 8.413288,
'BRL': 6.533427,
'BSD': 1.218393,
'BTC': 3.494333e-05,
'BTN': 88.654081,
'BWP': 12.989827,
'BYN': 3.053809,
'BYR': 23876.197187,
'BZD': 2.45593,
'CAD': 1.470274,
'CDF': 2438.782941,
'CHF': 1.093201,
'CLF': 0.031831,
'CLP': 878.302599,
'CNY': 7.837973,
'COP': 4564.495452,
'CRC': 752.743129,
'CUC': 1.218173,
'CUP': 32.281593,
'CVE': 110.701568,
'CZK': 25.458544,
'DJF': 216.493715,
'DKK': 7.436522,
'DOP': 69.424079,
'DZD': 162.160433,
'EGP': 19.07026,
'ERN': 18.275024,
'ETB': 52.247448,
'EUR': 1,
'FJD': 2.479593,
'FKP': 0.866749,
'GBP': 0.861365,
'GEL': 4.026072,
'GGP': 0.866749,
'GHS': 7.047173,
'GIP': 0.866749,
'GMD': 62.388725,
'GNF': 12023.370488,
'GTQ': 9.40363,
'GYD': 254.906219,
'HKD': 9.458068,
'HNL': 29.369822,
'HRK': 7.510283,
'HTG': 107.524476,
'HUF': 348.994082,
'IDR': 17486.878093,
'ILS': 3.965787,
'IMP': 0.866749,
'INR': 88.817078,
'IQD': 1780.969402,
'IRR': 51291.187597,
'ISK': 148.991075,
'JEP': 0.866749,
'JMD': 182.302707,
'JOD': 0.863654,
'JPY': 132.688324,
'KES': 131.843293,
'KGS': 102.059537,
'KHR': 4964.056223,
'KMF': 492.142091,
'KPW': 1096.356136,
'KRW': 1373.843706,
'KWD': 0.366122,
'KYD': 1.015402,
'KZT': 522.276557,
'LAK': 11499.556167,
'LBP': 1860.150705,
'LKR': 240.032246,
'LRD': 209.068968,
'LSL': 16.993676,
'LTL': 3.596949,
'LVL': 0.736861,
'LYD': 5.433018,
'MAD': 10.742468,
'MDL': 21.553655,
'MGA': 4577.895372,
'MKD': 61.378355,
'MMK': 2005.548353,
'MNT': 3472.906288,
'MOP': 9.744509,
'MRO': 434.887668,
'MUR': 49.582844,
'MVR': 18.764621,
'MWK': 962.357239,
'MXN': 24.290193,
'MYR': 5.044443,
'MZN': 72.724707,
'NAD': 16.993634,
'NGN': 502.723441,
'NIO': 42.983223,
'NOK': 10.210875,
'NPR': 141.84617,
'NZD': 1.698481,
'OMR': 0.468979,
'PAB': 1.218393,
'PEN': 4.555363,
'PGK': 4.300689,
'PHP': 58.402844,
'PKR': 186.929066,
'PLN': 4.493859,
'PYG': 8182.048384,
'QAR': 4.435386,
'RON': 4.927528,
'RSD': 117.242502,
'RUB': 89.715785,
'RWF': 1212.082459,
'SAR': 4.568389,
'SBD': 9.70277,
'SCR': 20.001793,
'SDG': 502.499382,
'SEK': 10.135263,
'SGD': 1.621961,
'SHP': 0.866749,
'SLL': 12474.094845,
'SOS': 712.631863,
'SRD': 17.242042,
'STD': 25259.779578,
'SVC': 10.66131,
'SYP': 1531.89592,
'SZL': 17.005751,
'THB': 38.214062,
'TJS': 13.895899,
'TMT': 4.275788,
'TND': 3.314035,
'TOP': 2.73962,
'TRY': 10.258604,
'TTD': 8.268398,
'TWD': 34.064981,
'TZS': 2824.944367,
'UAH': 33.416008,
'UGX': 4343.596379,
'USD': 1.218173,
'UYU': 53.812419,
'UZS': 12894.364153,
'VEF': 260482273111.7318,
'VND': 28086.204201,
'VUV': 132.058779,
'WST': 3.064863,
'XAF': 654.068807,
'XAG': 0.044182,
'XAU': 0.000647,
'XCD': 3.292175,
'XDR': 0.844562,
'XOF': 654.158734,
'XPF': 119.868942,
'YER': 304.604449,
'ZAR': 17.006553,
'ZMK': 10965.023085,
'ZMW': 27.383672,
'ZWL': 392.252182}`

@DaBors
Copy link
Author

DaBors commented May 26, 2021

@thusodangersimon
Hi :)
Thank you for letting me know I added the fix to the code.

NOTE: Changing the source currency is only available if you are on a paying plan it's not available for users through free plan. In that case the new fix should solve your problem.

image

@DaBors
Copy link
Author

DaBors commented May 26, 2021

@dbarnes18
You should be able to use pip with the following format: pip install git+https://github.com/user/repo.git@branch

Which in this case should be: pip install git+https://github.com/DaBors/forex-python.git@ratesapi-fix

Not sure if this is allowed in your platform, if not you can copy paste the code, or pick one of these shorter solutions mentioned in the api issue:

#86 (comment)
#86 (comment)

Hope you can make it work :)

@DillonB07
Copy link

DillonB07 commented May 26, 2021 via email

@DaBors
Copy link
Author

DaBors commented May 26, 2021

@dbarnes18

Yes, you can create a free account with the free account the usages are quite limited the currency rates are only being updated once per day, switching source currency is not supported. (You can also pay for an account, but not all the changes in the API are not implemented yet here)

I would suggest you to switch to this project https://pypi.org/project/CurrencyConverter/ a lot of people changed to it, since this problem occurred.

@DillonB07
Copy link

DillonB07 commented May 26, 2021 via email

raise RatesNotAvailableError("Currency Rates Source Not Ready")


_CURRENCY_FORMATTER = CurrencyRates()
# Please add your access key here
_CURRENCY_FORMATTER = CurrencyRates("your_access_key")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the access key should be read from on environtment variable.
This will allow to make it work without alterint the source code.

Probably the same should be done to activate the SSL access.

@ravigadila
Copy link

@DaBors
We started this project to give free exchange rates to students, starters. We don't want any restrictions on requests you make or paid plans in this repo.
So we changed api to theforexapi Please try it and report if any issues.
#91

@ashwin31
Copy link
Member

ashwin31 commented Jun 7, 2021

I totally agree with you @ravigadila and users should have freedom to use other paid services too if they want.
@DaBors can you make this a optional to overrride the default one base on optional parameters ?
@ravigadila think about it.

@ravigadila
Copy link

@ashwin31 It's good idea to make exchangerateapi as optional and default option as free api.

@DaBors DaBors closed this Jan 16, 2022
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

Successfully merging this pull request may close these issues.

None yet

8 participants