MicroPyramid / forex-python

Foreign exchange rates, Bitcoin price index and currency conversion using ratesapi.io
http://forex-python.readthedocs.io/en/latest/usage.html
MIT License
662 stars 197 forks source link

theforexapi.com is not working #149

Open fnikky opened 1 year ago

fnikky commented 1 year ago

theforexapi.com is not working, can I change the API to another one? Please fix the problem as soon as possible

fhoek commented 1 year ago

It hasn't been working since 16th of October.

Andrewnolan13 commented 1 year ago

Hi, the API pulls form the European Central Bank website. Alternatively, you can go to the ECB website and just download the csv.

a more automated way of doing this is the following:

import requests import zipfile import io

url = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.zip?a6ef9319d740f54c034942a0317114f8" filepath = ... #where you want to save the csv

response = requests.get(url) z = zipfile.ZipFile(io.BytesIO(response.content)) z.extractall()

csv_file = z.namelist()[0] z.extract(csv_file)

Rename the file to your desired filepath

os.rename(csv_file, filepath)

......

This way you can reference the csv file you have downloaded instead of referencing the api.

ddofborg commented 1 year ago

Based on @Andrewnolan13 comment I created a function which downloads the ZIP and generates the rates. See https://github.com/ddofborg/exchange_rates

Get a list of exchange rates for a given currency on a given date. Data is download from the European Central Bank history zipfile.

Note, rates are not cached. Each request will download the data again.

Usage:

>>> from exchange_rates import get_exchange_rates
>>> print( get_exchange_rates('USD', target_currencies=['EUR', 'CAD', 'USD'], on_date='2023-10-01') )
{'EUR': 0.9496676163342831, 'CAD': 1.3613485280151947, 'USD': 1.0}
>>> print( get_exchange_rates('EUR', target_currencies=['EUR', 'CAD', 'USD'], on_date='2023-10-01') )
{'EUR': 1.0, 'CAD': 1.4335, 'USD': 1.053}
cagdasulas commented 1 year ago

Is there any update regarding when the API will be again up ?

hjerbii commented 1 year ago

Hello, any updates?

fnikky commented 1 year ago

@abhijeet-1110 hi API is not working, ERROR 504, fix please.

fnikky commented 1 year ago

@abhijeet-1110 please fix API

ddofborg commented 1 year ago

I think theforexapi.com is dead.

Some other packages which work: https://github.com/ddofborg/exchange_rates (mine, returns a dict with rates) and https://github.com/oddaspa/easy-exchange-rates (returns a pandas dataframe).

abhijeet-1110 commented 1 year ago

@all Sorry for the inconvenience. It is working now. Please check

pienegu commented 10 months ago

@ddofborg Thanks for a simple and stable solution. The ECB is seldom down.

I made a wrapper that caches the rates and only downloads new rates once a day. It migh be useful to others. https://github.com/pienegu/div/blob/main/exchange_rates_cached

msarokinmkrst commented 9 months ago

Hi @abhijeet-1110

Is there a way to make the API available again? It's down as many people mentioned here 😄

bambussoeren commented 9 months ago

The api / the python module is very unreliable I have to say. Serveral days unavailable each month. Will use different api / module in the future, despite liking the ease of use for this module.

abhijeet-1110 commented 9 months ago

@all My sincere apologies to all,Due to server upgradtion currently facing the issue. We can't repeat it

DLu commented 9 months ago

You can't repeat the problem, or you can't repeat the solution you used before?

ddofborg commented 9 months ago

There are some other packages which use ECB data (with caching). That should stay up:) See https://github.com/MicroPyramid/forex-python/issues/149#issuecomment-1805480580 and https://github.com/MicroPyramid/forex-python/issues/149#issuecomment-1805480580

DavidGergov03 commented 7 months ago

@ddofborg i downloaded exchange_rates but there is no function get_exchange_rates in it?

ddofborg commented 7 months ago

@ddofborg i downloaded exchange_rates but there is no function get_exchange_rates in it?

It's there:

https://github.com/ddofborg/exchange_rates/blob/d0e7e0f6cf377850ac674f36be967b2f6094a5dd/exchange_rates.py#L35

ThibaultDC commented 7 months ago

Hello, still not working

ddofborg commented 7 months ago

Hello, still not working

Please give me some context, otherwise there is really no advice I can give you.