worldtradingdata
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -12,3 +12,3 @@ "use strict"; | ||
this.requestOptions = {}; | ||
this.staticPath = '/api/v1/'; | ||
this.staticPath = "/api/v1/"; | ||
this.isCsvFormat = false; | ||
@@ -18,4 +18,4 @@ this.agent = new https_1.Agent({ | ||
}); | ||
this.requestOptions.host = 'api.worldtradingdata.com'; | ||
this.requestOptions.method = 'GET'; | ||
this.requestOptions.host = "api.worldtradingdata.com"; | ||
this.requestOptions.method = "GET"; | ||
this.token = token; | ||
@@ -26,5 +26,5 @@ } | ||
* @param symbols Array with stocks you wish to return. | ||
* @param sortOrder Change the sort order of values. Options: 'asc', 'desc'. | ||
* @param sortOrder Change the sort order of values. Options: "asc", "desc". | ||
* @param sortBy Sort by a particular data attribute or by the order you entered the list. Options: symbol, name, list_order | ||
* @param output Change output to CSV. Options: 'csv', 'json'. | ||
* @param output Change output to CSV. Options: "csv", "json". | ||
*/ | ||
@@ -40,3 +40,3 @@ realTime(symbols, sortOrder, sortBy, output) { | ||
}; | ||
this.setRequestPath('stock', props); | ||
this.setRequestPath("stock", props); | ||
var result = this.callAPI(); | ||
@@ -48,5 +48,5 @@ return result; | ||
* @param symbols Array with stocks you wish to return. | ||
* @param sortOrder Change the sort order of values. Options: 'asc', 'desc'. | ||
* @param sortOrder Change the sort order of values. Options: "asc", "desc". | ||
* @param sortBy Sort by a particular data attribute or by the order you entered the list. Options: symbol, name, list_order | ||
* @param output Change output to CSV. Options: 'csv', 'json'. | ||
* @param output Change output to CSV. Options: "csv", "json". | ||
*/ | ||
@@ -62,4 +62,4 @@ mutualFundRealTime(symbols, sortOrder, sortBy, output) { | ||
}; | ||
this.setRequestPath('mutualfund', props); | ||
this.requestOptions.path = this.staticPath + 'mutualfund?' + querystring.stringify(props); | ||
this.setRequestPath("mutualfund", props); | ||
this.requestOptions.path = this.staticPath + "mutualfund?" + querystring.stringify(props); | ||
var result = this.callAPI(); | ||
@@ -73,4 +73,4 @@ return result; | ||
* @param range The number of days data is returned for. Options: 1-30. | ||
* @param sort Change the sort order of values. Options: 'asc', 'desc'. | ||
* @param output Change output to CSV. Options: 'csv', 'json'. | ||
* @param sort Change the sort order of values. Options: "asc", "desc". | ||
* @param output Change output to CSV. Options: "csv", "json". | ||
* @param formatted Alter JSON data format. Does not affect CSV. Options: true, false. | ||
@@ -88,4 +88,4 @@ */ | ||
}; | ||
this.setRequestPath('intraday', props); | ||
var result = this.callAPI({ host: 'intraday.worldtradingdata.com' }); | ||
this.setRequestPath("intraday", props); | ||
var result = this.callAPI({ host: "intraday.worldtradingdata.com" }); | ||
return result; | ||
@@ -98,4 +98,4 @@ } | ||
* @param range The number of days data is returned for. Options: 1-30. | ||
* @param sort Change the sort order of values. Options: 'asc', 'desc'. | ||
* @param output Change output to CSV. Options: 'csv', 'json'. | ||
* @param sort Change the sort order of values. Options: "asc", "desc". | ||
* @param output Change output to CSV. Options: "csv", "json". | ||
* @param formatted Alter JSON data format. Does not affect CSV. Options: true, false. | ||
@@ -113,3 +113,3 @@ */ | ||
}; | ||
this.setRequestPath('history', props); | ||
this.setRequestPath("history", props); | ||
var result = this.callAPI(); | ||
@@ -122,4 +122,4 @@ return result; | ||
* @param date The date you wish to retrieve data for. | ||
* @param sort Change the sort order of values. Options: 'asc', 'desc'. | ||
* @param output Change output to CSV. Options: 'csv', 'json'. | ||
* @param sort Change the sort order of values. Options: "asc", "desc". | ||
* @param output Change output to CSV. Options: "csv", "json". | ||
* @param formatted Alter JSON data format. Does not affect CSV. Options: true, false. | ||
@@ -136,3 +136,3 @@ */ | ||
}; | ||
this.setRequestPath('history_multi_single_day', props); | ||
this.setRequestPath("history_multi_single_day", props); | ||
var result = this.callAPI(); | ||
@@ -150,3 +150,3 @@ return result; | ||
}; | ||
this.setRequestPath('forex', props); | ||
this.setRequestPath("forex", props); | ||
var result = this.callAPI(); | ||
@@ -159,4 +159,4 @@ return result; | ||
* @param convertTo Value of the currency you wish to return conversion data to. | ||
* @param sort Change the sort order of values. Options: 'asc', 'desc'. | ||
* @param output Change output to CSV. Options: 'csv', 'json'. | ||
* @param sort Change the sort order of values. Options: "asc", "desc". | ||
* @param output Change output to CSV. Options: "csv", "json". | ||
* @param formatted Alter JSON data format. Does not affect CSV. Options: true, false. | ||
@@ -173,3 +173,3 @@ */ | ||
}; | ||
this.setRequestPath('forex_history', props); | ||
this.setRequestPath("forex_history", props); | ||
var result = this.callAPI(); | ||
@@ -182,3 +182,3 @@ return result; | ||
* @param date Date you wish to return the conversion data for. | ||
* @param output Change output to CSV. Options: 'csv', 'json'. | ||
* @param output Change output to CSV. Options: "csv", "json". | ||
* @param formatted Alter JSON data format. Does not affect CSV. Options: true, false. | ||
@@ -194,3 +194,3 @@ */ | ||
}; | ||
this.setRequestPath('forex_single_day', props); | ||
this.setRequestPath("forex_single_day", props); | ||
var result = this.callAPI(); | ||
@@ -208,4 +208,4 @@ return result; | ||
* @param sortBy Sort by a specific column. Options: symbol, name, currency, stock_exchange_long, stock_exchange_short, market_cap, volume, change_pct. | ||
* @param sortOrder Change the sort order of values. Options: 'asc', 'desc'. | ||
* @param output Change output to CSV. Options: 'csv', 'json'. | ||
* @param sortOrder Change the sort order of values. Options: "asc", "desc". | ||
* @param output Change output to CSV. Options: "csv", "json". | ||
*/ | ||
@@ -225,3 +225,3 @@ stockSearch(searchTerm, searchBy, stockExchange, currency, limit, page, sortBy, sortOrder, output) { | ||
}; | ||
this.setRequestPath('stock_search', props); | ||
this.setRequestPath("stock_search", props); | ||
var result = this.callAPI(); | ||
@@ -231,3 +231,3 @@ return result; | ||
setRequestPath(endPoint, props) { | ||
if (props.output === 'csv') { | ||
if (props.output === "csv") { | ||
this.isCsvFormat = true; | ||
@@ -241,3 +241,3 @@ } | ||
formatSymbolsFromArray(symbols) { | ||
var symbolUnified = ''; | ||
var symbolUnified = ""; | ||
symbols.forEach((symbol, index) => { | ||
@@ -248,3 +248,3 @@ if (index === symbols.length - 1) { | ||
else { | ||
symbolUnified += symbol + ','; | ||
symbolUnified += symbol + ","; | ||
} | ||
@@ -255,6 +255,6 @@ }); | ||
/** | ||
* Make a request using class prop requestOptions. Default Host: api.worldtradingdata.com, Method: 'GET' | ||
* Make a request using class prop requestOptions. Default Host: api.worldtradingdata.com, Method: "GET" | ||
* @param param0 Object with host and/or http method | ||
*/ | ||
callAPI({ host = 'api.worldtradingdata.com', method = 'GET' } = {}) { | ||
callAPI({ host = "api.worldtradingdata.com", method = "GET" } = {}) { | ||
this.requestOptions.host = host; | ||
@@ -264,7 +264,7 @@ this.requestOptions.method = method; | ||
const req = https_1.request(this.requestOptions, (res) => { | ||
var body = ''; | ||
res.on('data', (data) => { | ||
var body = ""; | ||
res.on("data", (data) => { | ||
body += data; | ||
}); | ||
res.on('end', () => { | ||
res.on("end", () => { | ||
try { | ||
@@ -283,3 +283,3 @@ if (this.isCsvFormat === false) { | ||
}); | ||
req.on('error', (error) => { | ||
req.on("error", (error) => { | ||
return reject(error); | ||
@@ -286,0 +286,0 @@ }); |
{ | ||
"name": "worldtradingdata", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Node.js wrapper for World Trading Data API", | ||
@@ -8,3 +8,3 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"start": "nodemon --watch src --exec ts-node src/server.ts -e ts", | ||
"start": "nodemon --watch src --exec ts-node src/index.ts -e ts", | ||
"build": "tsc -p tsconfig.json", | ||
@@ -39,4 +39,4 @@ "test": "echo \"Error: no test specified\" && exit 1" | ||
"ts-node": "^8.2.0", | ||
"typescript": "^3.4.5" | ||
"typescript": "^3.5.3" | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
export interface ForexData{ | ||
export interface ForexData { | ||
[key: string]: string; | ||
} |
@@ -1,4 +0,4 @@ | ||
import { ForexData } from './forexData'; | ||
import { ForexData } from "./forexData"; | ||
export interface ForexResponse{ | ||
export interface ForexResponse { | ||
symbols_returned: number; | ||
@@ -5,0 +5,0 @@ base: string; |
@@ -1,4 +0,4 @@ | ||
import { ForexData } from './forexData'; | ||
import { ForexData } from "./forexData"; | ||
export interface ForexSingleDay{ | ||
export interface ForexSingleDay { | ||
base: string; | ||
@@ -5,0 +5,0 @@ date: string; |
@@ -1,4 +0,4 @@ | ||
import { DayData } from './dayData'; | ||
import { DayData } from "./dayData"; | ||
export interface HistoricalMarketResponse{ | ||
export interface HistoricalMarketResponse { | ||
name: string; | ||
@@ -8,4 +8,4 @@ history: Historical; | ||
interface Historical{ | ||
interface Historical { | ||
[key: string]: DayData; | ||
} |
@@ -8,3 +8,3 @@ export interface IntradayMarketResponse { | ||
interface Intraday{ | ||
interface Intraday { | ||
[key: string]: DayData; | ||
@@ -11,0 +11,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import { DayData } from './dayData'; | ||
import { DayData } from "./dayData"; | ||
export interface MultiSingleDayHistoryResponse{ | ||
export interface MultiSingleDayHistoryResponse { | ||
date: Date; | ||
@@ -8,4 +8,4 @@ data: Stock; | ||
interface Stock{ | ||
interface Stock { | ||
[key: string]: DayData; | ||
} |
@@ -15,4 +15,4 @@ export interface RealTimeResponse { | ||
day_low: string; | ||
'52_week_high': string; | ||
'52_week_low': string; | ||
"52_week_high": string; | ||
"52_week_low": string; | ||
day_change: string; | ||
@@ -19,0 +19,0 @@ change_pct: string; |
@@ -1,2 +0,2 @@ | ||
export interface StockSearchResponse{ | ||
export interface StockSearchResponse { | ||
total_returned: number; | ||
@@ -10,3 +10,3 @@ total_results: number; | ||
interface StockSeatchData{ | ||
interface StockSeatchData { | ||
symbol: string; | ||
@@ -13,0 +13,0 @@ name: string; |
@@ -5,3 +5,2 @@ { | ||
"esModuleInterop": false, | ||
"declaration": true, | ||
"target": "es6", | ||
@@ -8,0 +7,0 @@ "moduleResolution": "node", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
53346
950