Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
node-stock-data
Advanced tools
An easy to use stock tracking API for Node.js using marketstack as the source.
Node-stock-data is a simple, easy to implement stock tracking API for Node.js that uses marketstack to quickly get current or historical data on any stock.
npm install node-stock-data
Head to marketstack and obtain a free API token by creating an account.
With a free account, you can make a maximum of 1000 API calls per month. You can check your usage from their dashboard.
Since the API token is private, it's recommended to keep it in a separate configuration file or use it as an environment variable.
Each example uses:
const stockdata = require('node-stock-data');
// Get the latest end of day stock information for Boeing (BA)
stockdata.stocks(
{
API_TOKEN: 'YOUR API TOKEN',
options: {
limit: 1,
symbols: 'BA'
}
})
.then(response => {
...
})
.catch(error => {
...
});
// Get the latest information on the CD PROJEKT ticker on Warsaw Stock Exchange (CDR/XWAR)
stockdata.tickers(
{
API_TOKEN: 'YOUR API TOKEN',
options: {
limit: 1,
search: 'CDR',
exchange: 'XWAR', //optional
}
})
.then(response => {
...
})
.catch(error => {
...
});
// Get the latest information on the NASDAQ stock exchange (XNAS)
stockdata.exchanges(
{
API_TOKEN: 'YOUR API TOKEN',
options: {
limit: 1,
search: 'XNAS'
}
})
.then(response => {
...
})
.catch(error => {
...
});
When using the search
parameter, both the exchange's name and their Market Identification Code (MIC) are accepted. For a full list of MICs, look at this list.
// Get today's stock information for Boeing (BA), with intervals of 1 hour.
stockdata.stocksIntraday(
{
API_TOKEN: 'YOUR API TOKEN',
options: {
limit: 5,
interval: '1hour',
symbols: 'BA'
}
})
.then(response => {
...
})
.catch(error => {
...
});
// Get the stock information for Boeing (BA) from January 7th, 2021 to January 9th, 2021
stockdata.stocks(
{
API_TOKEN: 'YOUR API TOKEN',
options: {
limit: 3,
date_from: '2021-03-15',
date_to: '2021-03-17',
symbols: 'BA'
}
})
.then(response => {
...
})
.catch(error => {
...
});
// Get the high price for Boeing (BA) on March 8th, 2021
stockdata.stocks(
{
API_TOKEN: 'YOUR API TOKEN',
options: {
limit: 1,
date_from: '2021-03-08',
symbols: 'BA'
}
})
.then(response => {
response.data.forEach(element => {
console.log(element['high'])
})
})
.catch(error => {
...
});
The stock lookup module returns a JSON array with this structure:
{
count: 1,
data: [
{
"date": "2020-05-21T00:00:00+0000",
"symbol": "AAPL",
"exchange": "XNAS",
"open": 318.66,
"high": 320.89,
"low": 315.87,
"close": 316.85,
"volume": 25672211.0,
"adj_open": 318.66,
"adj_high": 320.89,
"adj_low": 315.87,
"adj_close": 316.85,
"adj_volume": 25672211.0
}
]
}
This format of return means that to access the stock data, you'll need to use response.data
instead of just using response
. You can access the count of responses returned by using response.count
.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
All data gathered comes from the marketstack API. They could choose to modify their terms of service at any time. Please see their website and documentation for the most accurate information about their service.
FAQs
An easy to use stock tracking API for Node.js using marketstack as the source.
The npm package node-stock-data receives a total of 1 weekly downloads. As such, node-stock-data popularity was classified as not popular.
We found that node-stock-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.