Since 2014 I invest and trade with stocks. Since then, I always wanted to create programs which make my life as an Investor easier and since then my journey with always reliving finance API problems started.
Unfortunately I didn’t find my first PHP scripts which tried to get stock data - so I don’t remember which API stopped back then, but the rest of my journey was well documented with the help of Git.
Yahoo Stock Data API⌗
# Read Symbols from Database symbols = datab.getSymbols() # Get Price Data for each Symbol from yahoo for sym in symbols: url = "http://finance.yahoo.com/d/quotes.csv?s="+sym+"&f=sabd" with closing(requests.get(url, stream=True)) as r:
Guess what: The API is not available anymore.
Yahoo Currency Data API⌗
with urllib.request.urlopen("http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json") as url:
Current Currency rates on a stable API? Not with Yahoo!
CoinMarketCap Free Crypto API⌗
# Get Market Data with urllib.request.urlopen("https://api.coinmarketcap.com/v1/ticker/?convert=EUR&limit=0") as url:
Free Crypto prices? No! The guys behind CoinMarketCap found out that offering a free and open service is stupid and now ask for money!
Finsymbols Python lib⌗
Mainly get obtained via web scraping. I didn’t check all the functions, but it seems that many are outdated now.
Back in the day I was crazy about this. A whole exchange which advertised it was made for developers with a free API.
iexurl = "https://api.iextrading.com/1.0/stock/"+sym+"/quote" with urllib.request.urlopen(iexurl) as url:
Ha! Markets move too fast to provide the same URL for a longer period! You now have to use a new one, and it is not even free anymore.
Was a free and open source service with API for current exchange rates from the ECB.
The guy behind it sold it to a company which is owned by a big American Corporation. Of course, they now ask for money, even while there are many APIs which offer the same for free.
These are not even all APIs that changed - I used other ones before that. I use finance APIs since 2014, and I never encountered one which didn’t change after a few years or months.
So to rely on any finance API alone sounds stupid to me now because even the biggest players in this area changed their API dramatically multiple times.
I think the only solution for that problem is to create a wrapper around multiple APIs, check which APIs are online and give the fastest responses and deliver the information from these APIs.
Because there are many APIs which deliver the data from the European Central Bank and have a similar / compatible API to what exchangeratesapi.io had back in the day, I created two wrappers for currencies:
exchangerates-wrapper outputs a URL to an API which is online, and you can also define which currencies need to be supported from the API. It’s written in TypeScript and usable for projects in the Node ecosystem.
go-currency-wrapper is the same, but for projects which use the Go programming language.
What about stocks and crypto?⌗
While I plan similar projects for stocks and cryptocurrencies, I am currently not sure if or when I will release it to the public. However, other projects also have similar ideas: https://github.com/piquette/finance-go/issues/14