forex-python icon indicating copy to clipboard operation
forex-python copied to clipboard

theforexapi.com is not working

Open fnikky opened this issue 1 year ago • 19 comments

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

fnikky avatar Oct 29 '23 05:10 fnikky

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

fhoek avatar Oct 30 '23 10:10 fhoek

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.

Andrewnolan13 avatar Oct 31 '23 11:10 Andrewnolan13

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}

ddofborg avatar Nov 02 '23 10:11 ddofborg

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

cagdasulas avatar Nov 03 '23 07:11 cagdasulas

Hello, any updates?

hjerbii avatar Nov 03 '23 15:11 hjerbii

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

fnikky avatar Nov 08 '23 16:11 fnikky

@abhijeet-1110 please fix API

fnikky avatar Nov 10 '23 09:11 fnikky

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

ddofborg avatar Nov 10 '23 10:11 ddofborg

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

abhijeet-1110 avatar Nov 14 '23 06:11 abhijeet-1110

@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

pienegu avatar Jan 18 '24 02:01 pienegu

Hi @abhijeet-1110

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

msarokinmkrst avatar Feb 20 '24 11:02 msarokinmkrst

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.

bambussoeren avatar Feb 21 '24 12:02 bambussoeren

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

abhijeet-1110 avatar Feb 21 '24 12:02 abhijeet-1110

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

DLu avatar Feb 21 '24 17:02 DLu

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

ddofborg avatar Feb 21 '24 19:02 ddofborg

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

DavidGergov03 avatar Apr 19 '24 16:04 DavidGergov03

@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

ddofborg avatar Apr 20 '24 20:04 ddofborg

Hello, still not working

ThibaultDC avatar Apr 21 '24 11:04 ThibaultDC

Hello, still not working

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

ddofborg avatar Apr 21 '24 12:04 ddofborg