yahoo-nse-api
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -0,3 +1,5 @@ | ||
import { YahooChartResponse } from "./yahoo.charts.types"; | ||
import { YahooQuoteResponse, YahooQuoteResult } from "./yahoo.quotes.types"; | ||
export declare const getMultipleLTPs: (symbols: string[]) => Promise<YahooQuoteResponse>; | ||
export declare const getLTP: (symbol: string) => Promise<YahooQuoteResult>; | ||
export declare const getHistoricalData: (symbol: string, interval: string, range: string) => Promise<YahooChartResponse>; |
@@ -39,3 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLTP = exports.getMultipleLTPs = void 0; | ||
exports.getHistoricalData = exports.getLTP = exports.getMultipleLTPs = void 0; | ||
var fetch = function (url, init) { | ||
@@ -89,1 +89,31 @@ return Promise.resolve().then(function () { return require("node-fetch"); }).then(function (_a) { | ||
exports.getLTP = getLTP; | ||
var getHistoricalData = function (symbol, interval, range) { return __awaiter(void 0, void 0, void 0, function () { | ||
var baseV8YahooFinanceURL, symbolWithNSE, url, response, data; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
validateFrame(range, "range"); | ||
validateFrame(interval, "interval"); | ||
baseV8YahooFinanceURL = "https://query1.finance.yahoo.com/v8/finance/chart/"; | ||
symbolWithNSE = symbol + ".NS"; | ||
url = "".concat(baseV8YahooFinanceURL).concat(symbolWithNSE, "?&interval=").concat(interval, "&range=").concat(range); | ||
return [4 /*yield*/, fetch(url)]; | ||
case 1: | ||
response = _a.sent(); | ||
return [4 /*yield*/, response.json()]; | ||
case 2: | ||
data = _a.sent(); | ||
return [2 /*return*/, data]; | ||
} | ||
}); | ||
}); }; | ||
exports.getHistoricalData = getHistoricalData; | ||
function validateFrame(frame, frameType) { | ||
// should begin with a number | ||
// should end with either d,mo,y, or max | ||
// should not contain any other characters | ||
var regex = /^[0-9]+[dmy]|max$/; | ||
if (!regex.test(frame)) { | ||
throw new Error("Invalid" + frameType); | ||
} | ||
} |
{ | ||
"name": "yahoo-nse-api", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A Yahoo API Wrapper for getting quotes from the national stock exchance (NSE) ", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11896
8
273
4