Real Time Market Data API by Market Stack
- remove_red_eye257 Views
- event17 Jul 2020
- access_time3 min read
The MarketStack is a SaaS platform that provides real-time, intraday, historical stock market data via an API. The MarketStack is a product by apilayer team.
How to use MarketStack API
To use MarketStack API, you need to create an account on MarketStack. You can simply navigate to the sign up page and create a new free account.
Once you have created your account, MarketStack will generate an API key for you. Make sure that you don’t share it with unauthorized users.
Let’s call a simple API to observe how it works.
Here is a sample API to check various exchanges and their details around the world.
Once you hit the request, you should get the following response instantly.
GeSHi Error: GeSHi could not find the language json (using path /var/www/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
Awesome. It works.
At present, MarketStack provides the following set of data.
- End-of-Day Data: Get daily stock market data.
- Intraday Data: Get intraday and real-time market data.
- Tickers: Get information about stock ticker symbols.
- Exchanges: Get information about all supported exchanges.
- Currencies: Get information about all supported currencies.
- Timezones: Get information about all supported timezones.
You can check out the documentation of MarketStack for more details.
Integrating with Node.js
Here is a sample code to Integrate MarketStack API’s with Node.js.
First, install axios.
Replace the access key with your access key in the code shown below.
const params = {
access_key: 'YOUR_ACCESS_KEY'
}
axios.get('http://api.marketstack.com/v1/tickers/aapl/eod', {params})
.then(response => {
const apiResponse = response.data;
console.log(apiResponse);
}).catch(error => {
console.log(error);
});
Save the file and run the code using the following command.
You should the following output in the terminal.
MarketStack is really easy to use and provides a fast, JSON based response. I highly recommend you give this SaaS platform a try.