Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
share-price
Advanced tools
NPM library to get realtime Share / Stock Price from Yahoo Finance Website. This library uses axios under the hood to make HTTP Call to Yahoo Finance.
This function is used to retrieve the Share Price of a given Stock Symbol. stockSymbol
is a mandatory property for config
parameter of getSharePrice(config, callbackFunction(sharePrice, error))
function. You must pass valid values for the 2 config properties, otherwise the library function will retun error. If you are not sure of the exact stockSymbol for a Company, you can use the getStockSymbol()
function to search it.
You can optionally use any of the axios request config along with stockName
and exchageCode
If you are using the library behind a coporate proxy please refer axios request config properties link on how to set your proxy settings.
number
sharePrice decimal value or errorvar sharePrice = require("share-price");
//Using a Promise.
sharePrice.getSharePrice({ stockSymbol: "AAPL" }).then(function(stockPrice) {
console.log(stockPrice);
}).catch((error) => {
console.log(error);
});
//Using a callback function.
sharePrice.getSharePrice({ stockSymbol: "AAPL" }, function(stockPrice, error) {
if (error) {
console.error(error);
} else {
console.log(stockPrice);
}
});
This function is used to search for Stock Symbols for a given Stock Name String. stockName
is a mandatory property for config
parameter of getStockSymbol(config, callbackFunction(stockSymbolResult, error))
function. . You must pass valid value for the config property, otherwise the library function will retun error. Optionally you can send another config property list
as boolean value true
or false
. When list: true
is sent, the function returns an array of matching Stock Symbols along with Full Company and Stock Exchange Names.
You can optionally use any of the axios request config along with stockName
and exchageCode
If you are using the library behind a coporate proxy please refer axios request config properties link on how to set your proxy settings.
string
stockSymbolResult containing only the best matched Stock symbol name if list config is not sent as true
or errorarray
stockSymbolResult containing a list of matching Stock symbol names along with Full Company and Stock Exchange Names if list config is not sent as true
or errorvar sharePrice = require("share-price");
//Using a Promise retrieve list.
sharePrice.getStockSymbol({ stockName: "Apple Inc", list: true }).then(function(stockSymbolResult) {
console.log(stockSymbolResult);
}).catch((error) => {
console.log(error);
});
//Using a callback function rerieve best match.
sharePrice.getStockSymbol({ stockName: "Apple Inc" }, function(stockSymbolResult, error) {
if (error) {
console.error(error);
} else {
console.log(stockSymbolResult);
}
});
FAQs
Completely free NPM library to get realtime Stock / Share Price
We found that share-price 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.