forked from maanavshah/stock-market-india
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
266 lines (233 loc) · 8.71 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
// var API = require('indian-stock-exchange');
var express = require("express");
var API = require('./index');
var BSEAPI = API.BSE;
var NSEAPI = API.NSE;
const PORT = process.env.PORT || 3000;
var app = express();
app.listen(PORT, () => {
console.log("Server running on port " + PORT);
});
// National Stock Exchange (NSE) APIS
// Get the stock market status (open/closed) - JSON
// Example: http://localhost:3000/get_market_status
app.get("/get_market_status", (req, res, next) => {
NSEAPI.getMarketStatus()
.then(function (response) {
res.json(response.data);
});
});
// Get the NSE indexes information (last updated, name, previous close, open, low, high, last, percent change, year high and low, index order) - JSON
// Example: http://localhost:3000/nse/get_indices
app.get("/nse/get_indices", (req, res, next) => {
NSEAPI.getIndices()
.then(function (response) {
res.json(response.data);
});
});
// Get the quotes of all indexes in NSE - HTML
// Example: http://localhost:3000/nse/get_quotes
app.get("/nse/get_quotes", (req, res, next) => {
NSEAPI.getQuotes()
.then(function (response) {
res.json(response.data);
});
});
// Get the quotation data of the symbol (companyName) from NSE - JSON
// Example: http://localhost:3000/nse/get_quote_info?companyName=TCS
app.get("/nse/get_quote_info", (req, res, next) => {
NSEAPI.getQuoteInfo(req.query.companyName)
.then(function (response) {
res.json(response.data);
});
});
// Get the quotation data of the symbols (companyNames) from NSE - JSON
// Example: http://localhost:3000/nse/get_multiple_quote_info?companyNames=TCS,WIPRO
app.get("/nse/get_multiple_quote_info", (req, res, next) => {
const companyNames = req.query.companyNames.split(",");
NSEAPI.getMultipleQuoteInfo(companyNames).then(r => res.json(r));
});
// Get the top 10 gainers of NSE - JSON
// Example: http://localhost:3000/nse/get_gainers
app.get("/nse/get_gainers", (req, res, next) => {
NSEAPI.getGainers()
.then(function (response) {
res.json(response.data);
});
});
// Get the top 10 losers of NSE - JSON
// Example: http://localhost:3000/nse/get_losers
app.get("/nse/get_losers", (req, res, next) => {
NSEAPI.getLosers()
.then(function (response) {
res.json(response.data);
});
});
// Get advances/declines of individual index, and the value if its changed or not - JSON
// Example: http://localhost:3000/nse/get_incline_decline
app.get("/nse/get_incline_decline", (req, res, next) => {
NSEAPI.getInclineDecline()
.then(function (response) {
res.json(response.data);
});
});
// Get the information of all the companies in a single NSE index (slug) JSON
// Example: http://localhost:3000/nse/get_index_stocks?symbol=nifty
app.get("/nse/get_index_stocks", (req, res, next) => {
NSEAPI.getIndexStocks(req.query.symbol)
.then(function (response) {
res.json(response.data);
});
});
// Get the list of companies in provided NSE index with matching keyword data - JSON
// Example: http://localhost:3000/nse/search_stocks?keyword=AXIS
app.get("/nse/search_stocks", (req, res, next) => {
NSEAPI.searchStocks(req.query.keyword)
.then(function (response) {
res.json(response.data);
});
});
// Get the intra day data of company in NSE - XML
// Example: http://localhost:3000/nse/get_intra_day_data?companyName=TCS&time=1
// Example: http://localhost:3000/nse/get_intra_day_data?companyName=TCS&time=month
app.get("/nse/get_intra_day_data", (req, res, next) => {
NSEAPI.getIntraDayData(req.query.companyName, req.query.time)
.then(function (response) {
res.json(response.data);
});
});
// Get 52 weeks all high stocks in NSE - JSON
// Example: http://localhost:3000/nse/get_52_week_high
app.get("/nse/get_52_week_high", (req, res, next) => {
NSEAPI.get52WeekHigh()
.then(function (response) {
res.json(response.data);
});
});
// Get 52 weeks all low stocks in NSE - JSON
// Example: http://localhost:3000/nse/get_52_week_low
app.get("/nse/get_52_week_low", (req, res, next) => {
NSEAPI.get52WeekLow()
.then(function (response) {
res.json(response.data);
});
});
// Get the NSE stocks whose values are highest - JSON
// Example: http://localhost:3000/nse/get_top_value_stocks
app.get("/nse/get_top_value_stocks", (req, res, next) => {
NSEAPI.getTopValueStocks()
.then(function (response) {
res.json(response.data);
});
});
// Get the NSE stocks whose volumes sold are highest - JSON
// Example: http://localhost:3000/nse/get_top_volume_stocks
app.get("/nse/get_top_volume_stocks", (req, res, next) => {
NSEAPI.getTopVolumeStocks()
.then(function (response) {
res.json(response.data);
});
});
// Get the futures data for a company stock (symbol) and time - JSON
// Example: http://localhost:3000/nse/get_stock_futures_data?companyName=TCS&time=15
// Example: http://localhost:3000/nse/get_stock_futures_data?companyName=VEDL&time=month
app.get("/nse/get_stock_futures_data", (req, res, next) => {
NSEAPI.getStockFuturesData(req.query.companyName, req.query.time)
.then(function (response) {
res.json(response.data);
});
});
// Get chart data of a companyName(symbol) depending on time in NSE - CSV Format (delimiter - |)
// Example: http://localhost:3000/nse/get_chart_data_new?companyName=VEDL&time=5
// Example: http://localhost:3000/nse/get_chart_data_new?companyName=VEDL&time=year
app.get("/nse/get_chart_data_new", (req, res, next) => {
NSEAPI.getChartDataNew(req.query.companyName, req.query.time)
.then(function (response) {
res.json(response.data);
});
});
// Bombay Stock Exchange (NSE) APIS
// Get details of all index in BSE Stock exchange - JSON
// Example: http://localhost:3000/bse/get_indices
app.get("/bse/get_indices", (req, res, next) => {
BSEAPI.getIndices()
.then(function (response) {
res.json(response.data);
});
});
// Get the information of only a single index eg. SENSEX (16) - JSON
// Example: http://localhost:3000/bse/getIndexInfo?indexId=16
app.get("/bse/getIndexInfo", (req, res, next) => {
BSEAPI.getIndexInfo(req.query.indexId)
.then(function (response) {
res.json(response.data);
});
});
// Get todays closing data and daily data of past time using IndexId and time from BSE - JSON
// Example: http://localhost:3000/bse/get_index_chart_data?indexId=16
app.get("/bse/get_index_chart_data", (req, res, next) => {
BSEAPI.getIndexChartData(req.query.indexId, req.query.time)
.then(function (response) {
res.json(response.data);
});
});
// Get details of all the stocks in an index - JSON
// Example: http://localhost:3000/bse/get_index_stocks?indexId=16
app.get("/bse/get_index_stocks", (req, res, next) => {
BSEAPI.getIndexStocks(req.query.indexId)
.then(function (response) {
res.json(response.data);
});
});
// Get details of company (stock) using securityCode - JSON
// 500112 - symbol (securityCode) of SBIN stock BSE
// Example: http://localhost:3000/bse/get_company_info?companyKey=500325
app.get("/bse/get_company_info", (req, res, next) => {
BSEAPI.getCompanyInfo(req.query.companyKey)
.then(function (response) {
res.json(response.data);
});
});
// Get chart type details of stocks in BSE using companyKey and time - JSON
// returns(StockValue, Volume) for company in specified past time
// Example: http://localhost:3000/bse/get_stocks_chart_data?companyKey=500325&time=5
// Example: http://localhost:3000/bse/get_stocks_chart_data?companyKey=500325&time=month
app.get("/bse/get_stocks_chart_data", (req, res, next) => {
BSEAPI.getStocksChartData(req.query.companyKey, req.query.time)
.then(function (response) {
res.json(response.data);
});
});
// Get BSE stock data of stock info and day chart - HTML
// Example: http://localhost:3000/bse/get_stock_info_and_day_chart_data?companyKey=500325
app.get("/bse/get_stock_info_and_day_chart_data", (req, res, next) => {
BSEAPI.getStockInfoAndDayChartData(req.query.companyKey)
.then(function (response) {
res.json(response.data);
});
});
// Get the top gainers of BSE stock exchange - JSON
// Example: http://localhost:3000/bse/get_gainers
app.get("/bse/get_gainers", (req, res, next) => {
BSEAPI.getGainers()
.then(function (response) {
res.json(response.data);
});
});
// Get the top losers of BSE stock exchange - JSON
// Example: http://localhost:3000/bse/get_losers
app.get("/bse/get_losers", (req, res, next) => {
BSEAPI.getLosers()
.then(function (response) {
res.json(response.data);
});
});
// Get the top turnovers of BSE stock exchange - JSON
// Example: http://localhost:3000/bse/getTopTurnOvers
app.get("/bse/getTopTurnOvers", (req, res, next) => {
BSEAPI.getTopTurnOvers()
.then(function (response) {
res.json(response.data);
});
});
module.exports = app;