Free API for getting stock prices
This guide will also be a promotion of our own 100% free API for getting stock prices. When we publish our software, we are proud of it and our biggest achievement is when people are actually using it to solve problems or when it brings business values. So I will take this opportunity to show what this API has to offer.
About the API
To give a very short background, the reason we created this API was to give our free stock widget some data to show. So when this article was written, the API is quite small since it was built for giving the widget the necessary data. But we really hope to extend it with more functionality, so if any ideas on how to improve it to fit your needs, we are very happy to get any feedback here.
How to use it
So, if you want to get stock prices for any ticker or percentage changes from the last opening to the current price, this is how you can achieve it. In below example, we will fetch prices for three famous stocks - Apple, Microsoft and Tesla.
const response = await fetch( `https://stocks.algobook.info/api/v1/stocks?tickers=AAPL,MSFT,TSLA` ); const prices = await response.json(); console.log(prices);
And then API will give us
[ { "ticker": "AAPL", "open": 168.49, "lastClose": 168.41, "lastPrice": 168.36, "percentage": -0.03, "currency": "USD", "companyName": "Apple Inc." }, { "ticker": "MSFT", "open": 304.01, "lastClose": 304.83, "lastPrice": 305.42, "percentage": 0.19, "currency": "USD", "companyName": "Microsoft Corporation" }, { "ticker": "TSLA", "open": 160.9, "lastClose": 160.19, "lastPrice": 164.35, "percentage": 2.6, "currency": "USD", "companyName": "Tesla, Inc." } ]
As you can see, it is quite small amount of data. It is a very fast API, and gives us what we need to show current price, open price, yesterdays close price and also the percentage change and company name.
- Apple is down 0.03% and Microsoft is up 0.19% and Tesla is up 2.6% today
- We are also providing the full company name based on the ticker
Outro
That's it. That's what we have to offer in our stock API. As stated, it was built in small scale to make us able to release our stock widget. And if you are sitting now and thinking that this was somewhat useful, but you were hoping for more, please reach out - we love to take on any challenge, especially when it comes to creating good software and improve our offerings.
I hope you found this short post interesting, and I hope even more that you could think of using this API in your application!
All the best,