@invezgo/sdk 1.3.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +318 -314
  2. package/dist/cache.d.ts +27 -0
  3. package/dist/cache.d.ts.map +1 -0
  4. package/dist/client.d.ts +15 -18
  5. package/dist/client.d.ts.map +1 -1
  6. package/dist/errors.d.ts +71 -0
  7. package/dist/errors.d.ts.map +1 -0
  8. package/dist/generated/resources.d.ts +3382 -0
  9. package/dist/generated/resources.d.ts.map +1 -0
  10. package/dist/generated/types.d.ts +3873 -0
  11. package/dist/generated/types.d.ts.map +1 -0
  12. package/dist/http.d.ts +66 -0
  13. package/dist/http.d.ts.map +1 -0
  14. package/dist/index.d.ts +9 -16
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +760 -1080
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +781 -0
  19. package/dist/index.mjs.map +1 -0
  20. package/package.json +66 -63
  21. package/dist/endpoints/ai.d.ts +0 -98
  22. package/dist/endpoints/ai.d.ts.map +0 -1
  23. package/dist/endpoints/alerts.d.ts +0 -49
  24. package/dist/endpoints/alerts.d.ts.map +0 -1
  25. package/dist/endpoints/analysis.d.ts +0 -380
  26. package/dist/endpoints/analysis.d.ts.map +0 -1
  27. package/dist/endpoints/batch.d.ts +0 -40
  28. package/dist/endpoints/batch.d.ts.map +0 -1
  29. package/dist/endpoints/health.d.ts +0 -24
  30. package/dist/endpoints/health.d.ts.map +0 -1
  31. package/dist/endpoints/journals.d.ts +0 -49
  32. package/dist/endpoints/journals.d.ts.map +0 -1
  33. package/dist/endpoints/membership.d.ts +0 -35
  34. package/dist/endpoints/membership.d.ts.map +0 -1
  35. package/dist/endpoints/portfolios.d.ts +0 -14
  36. package/dist/endpoints/portfolios.d.ts.map +0 -1
  37. package/dist/endpoints/posts.d.ts +0 -42
  38. package/dist/endpoints/posts.d.ts.map +0 -1
  39. package/dist/endpoints/profile.d.ts +0 -34
  40. package/dist/endpoints/profile.d.ts.map +0 -1
  41. package/dist/endpoints/recommendation.d.ts +0 -10
  42. package/dist/endpoints/recommendation.d.ts.map +0 -1
  43. package/dist/endpoints/screener.d.ts +0 -45
  44. package/dist/endpoints/screener.d.ts.map +0 -1
  45. package/dist/endpoints/search.d.ts +0 -18
  46. package/dist/endpoints/search.d.ts.map +0 -1
  47. package/dist/endpoints/trades.d.ts +0 -31
  48. package/dist/endpoints/trades.d.ts.map +0 -1
  49. package/dist/endpoints/usage.d.ts +0 -11
  50. package/dist/endpoints/usage.d.ts.map +0 -1
  51. package/dist/endpoints/watchlists.d.ts +0 -64
  52. package/dist/endpoints/watchlists.d.ts.map +0 -1
  53. package/dist/index.esm.js +0 -1130
  54. package/dist/index.esm.js.map +0 -1
  55. package/dist/invezgo.d.ts +0 -42
  56. package/dist/invezgo.d.ts.map +0 -1
  57. package/dist/types.d.ts +0 -610
  58. package/dist/types.d.ts.map +0 -1
package/dist/index.esm.js DELETED
@@ -1,1130 +0,0 @@
1
- class InvezgoError extends Error {
2
- constructor(statusCode, message, error, response) {
3
- super(message);
4
- this.statusCode = statusCode;
5
- this.message = message;
6
- this.error = error;
7
- this.response = response;
8
- this.name = 'InvezgoError';
9
- Object.setPrototypeOf(this, InvezgoError.prototype);
10
- }
11
- }
12
- class HttpClient {
13
- constructor(config) {
14
- // Ensure baseURL doesn't have trailing slash since paths start with /
15
- const baseURL = config.baseURL || 'https://api.invezgo.com';
16
- this.baseURL = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;
17
- this.apiKey = config.apiKey;
18
- this.timeout = config.timeout || 30000;
19
- if (!this.apiKey) {
20
- throw new Error('API Key is required');
21
- }
22
- }
23
- async request(method, path, options = {}) {
24
- const url = `${this.baseURL}${path}`;
25
- const controller = new AbortController();
26
- const timeoutId = setTimeout(() => controller.abort(), options.timeout || this.timeout);
27
- try {
28
- const headers = {
29
- 'Authorization': `Bearer ${this.apiKey}`,
30
- 'Content-Type': 'application/json',
31
- 'User-Agent': 'Invezgo JS SDK',
32
- ...options.headers,
33
- };
34
- const response = await fetch(url, {
35
- method,
36
- headers,
37
- signal: controller.signal,
38
- });
39
- clearTimeout(timeoutId);
40
- // Handle 204 No Content
41
- if (response.status === 204) {
42
- return [];
43
- }
44
- const data = await response.json().catch(() => ({}));
45
- // Handle error responses
46
- if (!response.ok) {
47
- throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
48
- }
49
- return data;
50
- }
51
- catch (error) {
52
- clearTimeout(timeoutId);
53
- if (error.name === 'AbortError') {
54
- throw new InvezgoError(408, 'Request timeout', 'Timeout');
55
- }
56
- if (error instanceof InvezgoError) {
57
- throw error;
58
- }
59
- throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
60
- }
61
- }
62
- async get(path, params, options) {
63
- let url = path;
64
- if (params && Object.keys(params).length > 0) {
65
- const searchParams = new URLSearchParams();
66
- Object.entries(params).forEach(([key, value]) => {
67
- if (value !== undefined && value !== null) {
68
- if (Array.isArray(value)) {
69
- value.forEach(v => searchParams.append(key, String(v)));
70
- }
71
- else {
72
- searchParams.append(key, String(value));
73
- }
74
- }
75
- });
76
- url = `${path}?${searchParams.toString()}`;
77
- }
78
- return this.request('GET', url, options);
79
- }
80
- async post(path, body, options) {
81
- const requestOptions = {
82
- ...options,
83
- headers: {
84
- ...options?.headers,
85
- },
86
- };
87
- const controller = new AbortController();
88
- const timeoutId = setTimeout(() => controller.abort(), requestOptions.timeout || this.timeout);
89
- try {
90
- const url = `${this.baseURL}${path}`;
91
- const headers = {
92
- 'Authorization': `Bearer ${this.apiKey}`,
93
- 'Content-Type': 'application/json',
94
- 'User-Agent': 'Invezgo JS SDK',
95
- ...requestOptions.headers,
96
- };
97
- const response = await fetch(url, {
98
- method: 'POST',
99
- headers,
100
- body: body ? JSON.stringify(body) : undefined,
101
- signal: controller.signal,
102
- });
103
- clearTimeout(timeoutId);
104
- if (response.status === 204) {
105
- return {};
106
- }
107
- const data = await response.json().catch(() => ({}));
108
- if (!response.ok) {
109
- throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
110
- }
111
- return data;
112
- }
113
- catch (error) {
114
- clearTimeout(timeoutId);
115
- if (error.name === 'AbortError') {
116
- throw new InvezgoError(408, 'Request timeout', 'Timeout');
117
- }
118
- if (error instanceof InvezgoError) {
119
- throw error;
120
- }
121
- throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
122
- }
123
- }
124
- async put(path, body, options) {
125
- const controller = new AbortController();
126
- const timeoutId = setTimeout(() => controller.abort(), options?.timeout || this.timeout);
127
- try {
128
- const url = `${this.baseURL}${path}`;
129
- const headers = {
130
- 'Authorization': `Bearer ${this.apiKey}`,
131
- 'Content-Type': 'application/json',
132
- 'User-Agent': 'Invezgo JS SDK',
133
- ...options?.headers,
134
- };
135
- const response = await fetch(url, {
136
- method: 'PUT',
137
- headers,
138
- body: body ? JSON.stringify(body) : undefined,
139
- signal: controller.signal,
140
- });
141
- clearTimeout(timeoutId);
142
- if (response.status === 204) {
143
- return {};
144
- }
145
- const data = await response.json().catch(() => ({}));
146
- if (!response.ok) {
147
- throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
148
- }
149
- return data;
150
- }
151
- catch (error) {
152
- clearTimeout(timeoutId);
153
- if (error.name === 'AbortError') {
154
- throw new InvezgoError(408, 'Request timeout', 'Timeout');
155
- }
156
- if (error instanceof InvezgoError) {
157
- throw error;
158
- }
159
- throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
160
- }
161
- }
162
- async patch(path, body, options) {
163
- const controller = new AbortController();
164
- const timeoutId = setTimeout(() => controller.abort(), options?.timeout || this.timeout);
165
- try {
166
- const url = `${this.baseURL}${path}`;
167
- const headers = {
168
- 'Authorization': `Bearer ${this.apiKey}`,
169
- 'Content-Type': 'application/json',
170
- 'User-Agent': 'Invezgo JS SDK',
171
- ...options?.headers,
172
- };
173
- const response = await fetch(url, {
174
- method: 'PATCH',
175
- headers,
176
- body: body ? JSON.stringify(body) : undefined,
177
- signal: controller.signal,
178
- });
179
- clearTimeout(timeoutId);
180
- if (response.status === 204) {
181
- return {};
182
- }
183
- const data = await response.json().catch(() => ({}));
184
- if (!response.ok) {
185
- throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
186
- }
187
- return data;
188
- }
189
- catch (error) {
190
- clearTimeout(timeoutId);
191
- if (error.name === 'AbortError') {
192
- throw new InvezgoError(408, 'Request timeout', 'Timeout');
193
- }
194
- if (error instanceof InvezgoError) {
195
- throw error;
196
- }
197
- throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
198
- }
199
- }
200
- async delete(path, params, options) {
201
- let url = path;
202
- if (params && Object.keys(params).length > 0) {
203
- const searchParams = new URLSearchParams();
204
- Object.entries(params).forEach(([key, value]) => {
205
- if (value !== undefined && value !== null) {
206
- if (Array.isArray(value)) {
207
- value.forEach(v => searchParams.append(key, String(v)));
208
- }
209
- else {
210
- searchParams.append(key, String(value));
211
- }
212
- }
213
- });
214
- url = `${path}?${searchParams.toString()}`;
215
- }
216
- return this.request('DELETE', url, options);
217
- }
218
- }
219
-
220
- class AlertsEndpoints {
221
- constructor(client) {
222
- this.client = client;
223
- }
224
- /**
225
- * Get list of alerts.
226
- */
227
- async list() {
228
- return this.client.get('/alerts');
229
- }
230
- /**
231
- * Create alert.
232
- */
233
- async add(dto) {
234
- return this.client.post('/alerts', dto);
235
- }
236
- /**
237
- * Update alert.
238
- */
239
- async update(id, dto) {
240
- return this.client.put(`/alerts/${id}`, dto);
241
- }
242
- /**
243
- * Delete alert.
244
- */
245
- async delete(id) {
246
- return this.client.delete(`/alerts/${id}`);
247
- }
248
- /**
249
- * Test alert formula.
250
- */
251
- async test(dto) {
252
- return this.client.post('/alerts/test', dto);
253
- }
254
- }
255
-
256
- class AnalysisEndpoints {
257
- constructor(client) {
258
- this.client = client;
259
- }
260
- /**
261
- * Get list of all stocks listed on BEI.
262
- */
263
- async getStockList() {
264
- return this.client.get('/analysis/list/stock');
265
- }
266
- /**
267
- * Get list of all brokers/securities on BEI.
268
- */
269
- async getBrokerList() {
270
- return this.client.get('/analysis/list/broker');
271
- }
272
- /**
273
- * Get list of all supported IDX indexes.
274
- */
275
- async getIndexList() {
276
- return this.client.get('/analysis/list/index');
277
- }
278
- /**
279
- * Get complete company information.
280
- */
281
- async getInformation(code) {
282
- return this.client.get(`/analysis/information/${code}`);
283
- }
284
- /**
285
- * Get top gainer and loser stocks for a specific date.
286
- */
287
- async getTopChange(date) {
288
- return this.client.get('/analysis/top/change', { date });
289
- }
290
- /**
291
- * Get top foreign accumulation and distribution.
292
- */
293
- async getTopForeign(date) {
294
- return this.client.get('/analysis/top/foreign', { date });
295
- }
296
- /**
297
- * Get top bandarmology accumulation and distribution.
298
- */
299
- async getTopAccumulation(date) {
300
- return this.client.get('/analysis/top/accumulation', { date });
301
- }
302
- /**
303
- * Get top retail accumulation and distribution.
304
- */
305
- async getTopRitel(date) {
306
- return this.client.get('/analysis/top/ritel', { date });
307
- }
308
- /**
309
- * Alias for getTopRitel.
310
- */
311
- async getTopRetail(date) {
312
- return this.getTopRitel(date);
313
- }
314
- /**
315
- * Get intraday chart data.
316
- */
317
- async getIntradayChart(code, market = 'RG') {
318
- return this.client.get(`/analysis/intraday/${code}`, { market });
319
- }
320
- /**
321
- * Get intraday stock summary data.
322
- */
323
- async getIntradayData(code, market = 'RG') {
324
- return this.client.get(`/analysis/intraday-data/${code}`, { market });
325
- }
326
- /**
327
- * Get intraday index summary data.
328
- */
329
- async getIntradayIndex(code, market = 'RG') {
330
- return this.client.get(`/analysis/intraday-index/${code}`, { market });
331
- }
332
- /**
333
- * Get order book data.
334
- */
335
- async getOrderBook(code, market = 'RG') {
336
- return this.client.get(`/analysis/order-book/${code}`, { market });
337
- }
338
- /**
339
- * Get complete stock chart data.
340
- */
341
- async getChart(code, params) {
342
- return this.client.get(`/analysis/chart/stock/${code}`, params);
343
- }
344
- /**
345
- * Get historical index chart data.
346
- */
347
- async getIndexChart(code, params) {
348
- return this.client.get(`/analysis/chart/index/${code}`, params);
349
- }
350
- /**
351
- * Get stock chart with technical indicator.
352
- */
353
- async getIndicatorChart(code, indicator, params) {
354
- return this.client.get(`/analysis/chart/stock/${indicator}/${code}`, params);
355
- }
356
- /**
357
- * Get shareholder detail above 5%.
358
- */
359
- async getShareholderDetail(code) {
360
- return this.client.get(`/analysis/shareholder-detail/${code}`);
361
- }
362
- /**
363
- * Get shareholder detail above 1% for a specific holder.
364
- */
365
- async getShareholderDetailOne(params) {
366
- return this.client.get('/analysis/shareholder-detail-one', params);
367
- }
368
- /**
369
- * Get number of shareholders.
370
- */
371
- async getShareholderNumber(code) {
372
- return this.client.get(`/analysis/shareholder/number/${code}`);
373
- }
374
- /**
375
- * Get shareholder relation graph.
376
- */
377
- async getShareholderRelation(params) {
378
- return this.client.get('/analysis/shareholder/relation', params);
379
- }
380
- /**
381
- * Get shareholder composition.
382
- */
383
- async getShareholder(code) {
384
- return this.client.get(`/analysis/shareholder/${code}`);
385
- }
386
- /**
387
- * Get KSEI shareholder data.
388
- */
389
- async getShareholderKSEI(code, range) {
390
- return this.client.get(`/analysis/shareholder/ksei/${code}`, {
391
- range: Math.min(range, 12),
392
- });
393
- }
394
- /**
395
- * Get broker summary for a stock.
396
- */
397
- async getBrokerSummaryStock(code, params) {
398
- return this.client.get(`/analysis/summary/stock/${code}`, params);
399
- }
400
- /**
401
- * Get broker summary for a broker.
402
- */
403
- async getBrokerSummaryBroker(code, params) {
404
- return this.client.get(`/analysis/summary/broker/${code}`, params);
405
- }
406
- /**
407
- * Get sector stalker data.
408
- */
409
- async getStalkerSector(params) {
410
- return this.client.get('/analysis/stalker/sector', params);
411
- }
412
- /**
413
- * Get sector rotation chart.
414
- */
415
- async getSectorRotation(params) {
416
- return this.client.get('/analysis/sector/rotation', params);
417
- }
418
- /**
419
- * Get broker stalker data for a stock.
420
- */
421
- async getBrokerStalker(broker, stock, params) {
422
- return this.client.get(`/analysis/stalker/broker/${broker}/${stock}`, params);
423
- }
424
- /**
425
- * Get broker stalker list.
426
- */
427
- async getBrokerStalkerList(code, params) {
428
- return this.client.get(`/analysis/stalker/list/${code}`, params);
429
- }
430
- /**
431
- * Get broker summary chart for a stock.
432
- */
433
- async getBrokerSummaryChartStock(code, params) {
434
- return this.client.get(`/analysis/summary-chart/stock/${code}`, params);
435
- }
436
- /**
437
- * Get broker summary chart for a broker.
438
- */
439
- async getBrokerSummaryChartBroker(code, params) {
440
- return this.client.get(`/analysis/summary-chart/broker/${code}`, params);
441
- }
442
- /**
443
- * Get inventory chart for a stock.
444
- */
445
- async getInventoryChartStock(code, params) {
446
- return this.client.get(`/analysis/inventory-chart/stock/${code}`, params);
447
- }
448
- /**
449
- * Get inventory chart for a broker.
450
- */
451
- async getInventoryChartBroker(code, params) {
452
- return this.client.get(`/analysis/inventory-chart/broker/${code}`, params);
453
- }
454
- /**
455
- * Get momentum chart.
456
- */
457
- async getMomentumChart(code, params) {
458
- return this.client.get(`/analysis/momentum-chart/${code}`, params);
459
- }
460
- /**
461
- * Get intraday inventory chart.
462
- */
463
- async getIntradayInventoryChart(code, params) {
464
- return this.client.get(`/analysis/intraday-inventory-chart/${code}`, params);
465
- }
466
- /**
467
- * Get distribution or crossing chart.
468
- */
469
- async getSankeyChart(code, params) {
470
- return this.client.get(`/analysis/sankey-chart/${code}`, params);
471
- }
472
- /**
473
- * Get price table.
474
- */
475
- async getPriceTable(code, date) {
476
- return this.client.get(`/analysis/price-table/${code}`, { date });
477
- }
478
- /**
479
- * Get time table.
480
- */
481
- async getTimeTable(code, params) {
482
- return this.client.get(`/analysis/time-table/${code}`, params);
483
- }
484
- /**
485
- * Get price diary.
486
- */
487
- async getPriceDiary(code) {
488
- return this.client.get(`/analysis/price-diary/${code}`);
489
- }
490
- /**
491
- * Get price seasonality.
492
- */
493
- async getPriceSeasonality(code, range) {
494
- return this.client.get(`/analysis/price-seasonality/${code}`, {
495
- range: Math.min(range, 60),
496
- });
497
- }
498
- /**
499
- * Get shareholders above 5%.
500
- */
501
- async getShareholderAbove(params) {
502
- return this.client.get('/analysis/shareholder-above', params);
503
- }
504
- /**
505
- * Get shareholder above 5% chart.
506
- */
507
- async getShareholderAboveChart(code, params) {
508
- return this.client.get(`/analysis/shareholder-above-chart/${code}`, params);
509
- }
510
- /**
511
- * Get shareholders above 1%.
512
- */
513
- async getShareholderOne(params) {
514
- return this.client.get('/analysis/shareholder-one', params);
515
- }
516
- /**
517
- * Get shareholder above 1% chart.
518
- */
519
- async getShareholderOneChart(code, params) {
520
- return this.client.get(`/analysis/shareholder-one-chart/${code}`, params);
521
- }
522
- /**
523
- * Get insider trading data.
524
- */
525
- async getInsiderTrading(params) {
526
- return this.client.get('/analysis/shareholder-insider', params);
527
- }
528
- /**
529
- * Get insider chart.
530
- */
531
- async getInsiderChart(code, params) {
532
- return this.client.get(`/analysis/insider-chart/${code}`, params);
533
- }
534
- /**
535
- * Get financial statement.
536
- */
537
- async getFinancialStatement(code, params) {
538
- return this.client.get(`/analysis/financial-statement/${code}`, { ...params, limit: Math.min(params.limit, 20) });
539
- }
540
- /**
541
- * Get financial statement chart.
542
- */
543
- async getFinancialStatementChart(code, params) {
544
- return this.client.get(`/analysis/financial-statement-chart/${code}`, { ...params, limit: Math.min(params.limit, 20) });
545
- }
546
- /**
547
- * Get key statistics.
548
- */
549
- async getKeyStat(code, params) {
550
- return this.client.get(`/analysis/keystat/${code}`, {
551
- ...params,
552
- limit: Math.min(params.limit, 20),
553
- });
554
- }
555
- /**
556
- * Get key statistics chart.
557
- */
558
- async getKeyStatChart(code, params) {
559
- return this.client.get(`/analysis/keystat-chart/${code}`, {
560
- ...params,
561
- limit: Math.min(params.limit, 20),
562
- });
563
- }
564
- /**
565
- * Get corporate action calendar.
566
- */
567
- async getCalendar(params) {
568
- return this.client.get('/analysis/calendar', params);
569
- }
570
- /**
571
- * Alias for getCalendar.
572
- */
573
- async getCorporateActionCalendar(params) {
574
- return this.getCalendar(params);
575
- }
576
- /**
577
- * Get multi-timeframe chart data for stocks or indexes.
578
- */
579
- async getMultiTimeChart(code, params) {
580
- return this.client.get(`/analysis/chart/multi-time/${code}`, params);
581
- }
582
- /**
583
- * Get high concentration stock ownership data for all issuers.
584
- */
585
- async getShareholderHigh() {
586
- return this.client.get('/analysis/shareholder/high');
587
- }
588
- /**
589
- * Get complete shareholder data with all investor classifications for a specific period.
590
- */
591
- async getShareholderClassification(code, range) {
592
- return this.client.get(`/analysis/shareholder/classification/${code}`, { range: Math.min(range, 36) });
593
- }
594
- /**
595
- * Get latest shareholder data with investor classifications in table format.
596
- */
597
- async getShareholderClassifyTable(code) {
598
- return this.client.get(`/analysis/shareholder/classify-table/${code}`);
599
- }
600
- /**
601
- * Get order queue (order tracking) for a stock at a specific price, side, page, and limit.
602
- */
603
- async getOrderQueue(code, params) {
604
- return this.client.get(`/analysis/queue/${code}`, params);
605
- }
606
- /**
607
- * Get realtime/historical running trade transaction data for a specific stock code.
608
- *
609
- * @param code Stock code (e.g. 'BBCA')
610
- * @param params Query parameters including date (YYYY-MM-DD), page, limit, type, orderby, etc.
611
- */
612
- async getRunningTrade(code, params) {
613
- return this.client.get(`/analysis/running-trade/${code}`, params);
614
- }
615
- /**
616
- * Alias for getRunningTrade.
617
- */
618
- async getStockRunningTrade(code, params) {
619
- return this.getRunningTrade(code, params);
620
- }
621
- }
622
-
623
- class WatchlistsEndpoints {
624
- constructor(client) {
625
- this.client = client;
626
- }
627
- /**
628
- * Get list of watchlists.
629
- */
630
- async list(group = 'null') {
631
- return this.client.get('/watchlists', { group });
632
- }
633
- /**
634
- * Add stock to watchlist.
635
- */
636
- async add(dto) {
637
- return this.client.post('/watchlists', dto);
638
- }
639
- /**
640
- * Delete watchlist entries.
641
- *
642
- * The current OpenAPI spec does not describe delete filters,
643
- * but the SDK keeps optional query params for batch deletion support.
644
- */
645
- async delete(params) {
646
- return this.client.delete('/watchlists', params);
647
- }
648
- /**
649
- * Get list of watchlist groups.
650
- */
651
- async listGroups() {
652
- return this.client.get('/watchlists/group');
653
- }
654
- /**
655
- * Add new watchlist group.
656
- */
657
- async addGroup(dto) {
658
- return this.client.post('/watchlists/group', dto);
659
- }
660
- /**
661
- * Update watchlist group.
662
- */
663
- async updateGroup(id, dto) {
664
- return this.client.put(`/watchlists/group/${id}`, dto);
665
- }
666
- /**
667
- * Delete watchlist group.
668
- */
669
- async deleteGroup(id) {
670
- return this.client.delete(`/watchlists/group/${id}`);
671
- }
672
- /**
673
- * Update watchlist.
674
- */
675
- async update(id, dto) {
676
- return this.client.put(`/watchlists/${id}`, dto);
677
- }
678
- /**
679
- * Update watchlist note.
680
- */
681
- async updateNote(id, dto) {
682
- return this.client.patch(`/watchlists/${id}`, dto);
683
- }
684
- }
685
-
686
- class JournalsEndpoints {
687
- constructor(client) {
688
- this.client = client;
689
- }
690
- /**
691
- * Extract journal transactions from uploaded file.
692
- */
693
- async extractFromFile(file) {
694
- const formData = new FormData();
695
- formData.append('file', file);
696
- const url = `${this.client.baseURL}/journals/file`;
697
- const response = await fetch(url, {
698
- method: 'POST',
699
- headers: {
700
- Authorization: `Bearer ${this.client.apiKey}`,
701
- },
702
- body: formData,
703
- });
704
- if (!response.ok) {
705
- const data = (await response.json().catch(() => ({})));
706
- throw new InvezgoError(response.status, data.message || 'Failed to extract journal from file', data.error, data);
707
- }
708
- return response.json().catch(() => ({}));
709
- }
710
- /**
711
- * Add new journal transaction.
712
- */
713
- async add(dto) {
714
- return this.client.post('/journals', dto);
715
- }
716
- /**
717
- * List journal transactions.
718
- */
719
- async list() {
720
- return this.client.get('/journals');
721
- }
722
- /**
723
- * Delete journal entries.
724
- *
725
- * The current OpenAPI spec does not describe delete filters,
726
- * but the SDK keeps optional query params for batch deletion support.
727
- */
728
- async delete(params) {
729
- return this.client.delete('/journals', params);
730
- }
731
- /**
732
- * Get journal transactions summary.
733
- */
734
- async getSummary() {
735
- return this.client.get('/journals/summary');
736
- }
737
- /**
738
- * Update journal transaction note.
739
- */
740
- async updateNote(id, dto) {
741
- return this.client.patch(`/journals/${id}`, dto);
742
- }
743
- }
744
-
745
- class PortfoliosEndpoints {
746
- constructor(client) {
747
- this.client = client;
748
- }
749
- /**
750
- * Get list of portfolios
751
- */
752
- async list() {
753
- return this.client.get('/portfolios');
754
- }
755
- /**
756
- * Get portfolio summary
757
- */
758
- async getSummary() {
759
- return this.client.get('/portfolios/summary');
760
- }
761
- }
762
-
763
- class SearchEndpoints {
764
- constructor(client) {
765
- this.client = client;
766
- }
767
- /**
768
- * Search for stocks or users
769
- */
770
- async search(query) {
771
- return this.client.get('/search', { query });
772
- }
773
- /**
774
- * Search for stocks
775
- */
776
- async searchStock(query, cursor) {
777
- return this.client.get('/search/stock', { query, cursor });
778
- }
779
- /**
780
- * Search for users
781
- */
782
- async searchUser(query, cursor) {
783
- return this.client.get('/search/user', { query, cursor });
784
- }
785
- }
786
-
787
- class ProfileEndpoints {
788
- constructor(client) {
789
- this.client = client;
790
- }
791
- /**
792
- * Get user profile details
793
- */
794
- async getUserDetails(username) {
795
- return this.client.get(`/profile/detail/${username}`);
796
- }
797
- /**
798
- * Get user posts
799
- */
800
- async getUserPosts(username, page, limit) {
801
- return this.client.get(`/profile/posts/${username}`, { page, limit });
802
- }
803
- /**
804
- * Get user posts by category
805
- */
806
- async getCategoryPosts(username, category, page, limit) {
807
- return this.client.get(`/profile/posts/${username}/${category}`, { page, limit });
808
- }
809
- /**
810
- * Get user watchlist
811
- */
812
- async getUserWatchlist(username) {
813
- return this.client.get(`/profile/watchlist/${username}`);
814
- }
815
- /**
816
- * Get user followers
817
- */
818
- async getFollowers(username) {
819
- return this.client.get(`/profile/follow/${username}`);
820
- }
821
- /**
822
- * Get users being followed
823
- */
824
- async getFollowing(username) {
825
- return this.client.get(`/profile/following/${username}`);
826
- }
827
- /**
828
- * Get user memberships
829
- */
830
- async getMemberships(username) {
831
- return this.client.get(`/profile/membership/${username}`);
832
- }
833
- }
834
-
835
- class MembershipEndpoints {
836
- constructor(client) {
837
- this.client = client;
838
- }
839
- /**
840
- * Get list of memberships.
841
- */
842
- async list() {
843
- return this.client.get('/membership');
844
- }
845
- /**
846
- * Add new membership.
847
- */
848
- async add(dto) {
849
- return this.client.post('/membership', dto);
850
- }
851
- /**
852
- * Get membership scopes.
853
- */
854
- async getScope() {
855
- return this.client.get('/membership/scope');
856
- }
857
- /**
858
- * Get membership transactions.
859
- */
860
- async getTransactions() {
861
- return this.client.get('/membership/list');
862
- }
863
- /**
864
- * Update membership.
865
- */
866
- async update(id, dto) {
867
- return this.client.put(`/membership/${id}`, dto);
868
- }
869
- /**
870
- * Delete membership.
871
- */
872
- async delete(id) {
873
- return this.client.delete(`/membership/${id}`);
874
- }
875
- }
876
-
877
- class PostsEndpoints {
878
- constructor(client) {
879
- this.client = client;
880
- }
881
- /**
882
- * Get all posts
883
- */
884
- async getAll() {
885
- return this.client.get('/posts');
886
- }
887
- /**
888
- * Get posts by category
889
- */
890
- async getByCategory(category) {
891
- return this.client.get(`/posts/category/${category}`);
892
- }
893
- /**
894
- * Get posts for a stock
895
- */
896
- async getStockPosts(code) {
897
- return this.client.get(`/posts/space/${code}`);
898
- }
899
- /**
900
- * Get stock posts by category
901
- */
902
- async getStockCategoryPosts(code, category) {
903
- return this.client.get(`/posts/space/category/${code}/${category}`);
904
- }
905
- /**
906
- * Get post details
907
- */
908
- async getPostById(id) {
909
- return this.client.get(`/posts/detail/${id}`);
910
- }
911
- /**
912
- * Get post comments
913
- */
914
- async getComments(id) {
915
- return this.client.get(`/posts/comment/${id}`);
916
- }
917
- /**
918
- * Get liked posts
919
- */
920
- async getLiked() {
921
- return this.client.get('/posts/like');
922
- }
923
- /**
924
- * Get favorite posts
925
- */
926
- async getFavorites() {
927
- return this.client.get('/posts/favorite');
928
- }
929
- /**
930
- * Get post voters
931
- */
932
- async getVoters(id) {
933
- return this.client.get(`/posts/vote/${id}`);
934
- }
935
- }
936
-
937
- class RecommendationEndpoints {
938
- constructor(client) {
939
- this.client = client;
940
- }
941
- /**
942
- * Get user recommendations.
943
- */
944
- async getUserRecommendations() {
945
- return this.client.get('/recommendation/user');
946
- }
947
- }
948
-
949
- class TradesEndpoints {
950
- constructor(client) {
951
- this.client = client;
952
- }
953
- /**
954
- * Get list of realized trades
955
- */
956
- async list() {
957
- return this.client.get('/trades');
958
- }
959
- /**
960
- * Delete trades
961
- */
962
- async delete(params) {
963
- return this.client.delete('/trades', params);
964
- }
965
- /**
966
- * Get trades summary
967
- */
968
- async getSummary() {
969
- return this.client.get('/trades/summary');
970
- }
971
- /**
972
- * Get trades summary chart
973
- */
974
- async getSummaryChart() {
975
- return this.client.get('/trades/summary-chart');
976
- }
977
- /**
978
- * Update trade note
979
- */
980
- async updateNote(id, dto) {
981
- return this.client.patch(`/trades/${id}`, dto);
982
- }
983
- }
984
-
985
- class ScreenerEndpoints {
986
- constructor(client) {
987
- this.client = client;
988
- }
989
- /**
990
- * Get list of preset screeners.
991
- */
992
- async list() {
993
- return this.client.get('/screener');
994
- }
995
- /**
996
- * Save preset screener.
997
- */
998
- async save(dto) {
999
- return this.client.post('/screener', dto);
1000
- }
1001
- /**
1002
- * Update preset screener.
1003
- */
1004
- async update(id, dto) {
1005
- return this.client.put(`/screener/${id}`, dto);
1006
- }
1007
- /**
1008
- * Delete preset screener.
1009
- */
1010
- async delete(id) {
1011
- return this.client.delete(`/screener/${id}`);
1012
- }
1013
- /**
1014
- * Run screener.
1015
- */
1016
- async screen(dto) {
1017
- return this.client.post('/screener/screen', dto);
1018
- }
1019
- }
1020
-
1021
- class UsageEndpoints {
1022
- constructor(client) {
1023
- this.client = client;
1024
- }
1025
- /**
1026
- * Get API usage statistics for the configured API key.
1027
- */
1028
- async getApiUsage() {
1029
- return this.client.get('/usage/api');
1030
- }
1031
- }
1032
-
1033
- class BatchEndpoints {
1034
- constructor(client) {
1035
- this.client = client;
1036
- }
1037
- formatCode(code) {
1038
- return Array.isArray(code) ? code.join('|') : code;
1039
- }
1040
- /**
1041
- * Get order book data for multiple stocks in a single request (max 3 for MAX, 10 for ELITE).
1042
- *
1043
- * @param code Stock codes (e.g. 'BBCA|GOTO|HUMI' or ['BBCA', 'GOTO', 'HUMI'])
1044
- * @param params Parameters including required market ('RG', 'NG', 'TN'), optional date, and time
1045
- */
1046
- async getOrderBook(code, params) {
1047
- const formattedCode = this.formatCode(code);
1048
- return this.client.get(`/batch/order-book/${formattedCode}`, params);
1049
- }
1050
- /**
1051
- * Alias for getOrderBook.
1052
- */
1053
- async getOrderBookBatch(code, params) {
1054
- return this.getOrderBook(code, params);
1055
- }
1056
- /**
1057
- * Get summary intraday price data for multiple stocks in a single request (max 3 for MAX, 10 for ELITE).
1058
- *
1059
- * @param code Stock codes (e.g. 'BBCA|GOTO|HUMI' or ['BBCA', 'GOTO', 'HUMI'])
1060
- * @param params Parameters including required market ('RG', 'NG', 'TN') and optional date
1061
- */
1062
- async getIntradayData(code, params) {
1063
- const formattedCode = this.formatCode(code);
1064
- return this.client.get(`/batch/intraday-data/${formattedCode}`, params);
1065
- }
1066
- /**
1067
- * Alias for getIntradayData.
1068
- */
1069
- async getIntradayDataBatch(code, params) {
1070
- return this.getIntradayData(code, params);
1071
- }
1072
- /**
1073
- * Get summary intraday price data for multiple indexes in a single request (max 3 for MAX, 10 for ELITE).
1074
- *
1075
- * @param code Index codes (e.g. 'COMPOSITE|LQ45|IDX30' or ['COMPOSITE', 'LQ45', 'IDX30'])
1076
- */
1077
- async getIntradayIndex(code) {
1078
- const formattedCode = this.formatCode(code);
1079
- return this.client.get(`/batch/intraday-index/${formattedCode}`);
1080
- }
1081
- /**
1082
- * Alias for getIntradayIndex.
1083
- */
1084
- async getIntradayIndexBatch(code) {
1085
- return this.getIntradayIndex(code);
1086
- }
1087
- }
1088
-
1089
- class Invezgo {
1090
- constructor(config) {
1091
- this.client = new HttpClient(config);
1092
- this.alerts = new AlertsEndpoints(this.client);
1093
- this.analysis = new AnalysisEndpoints(this.client);
1094
- this.watchlists = new WatchlistsEndpoints(this.client);
1095
- this.journals = new JournalsEndpoints(this.client);
1096
- this.portfolios = new PortfoliosEndpoints(this.client);
1097
- this.search = new SearchEndpoints(this.client);
1098
- this.profile = new ProfileEndpoints(this.client);
1099
- this.membership = new MembershipEndpoints(this.client);
1100
- this.posts = new PostsEndpoints(this.client);
1101
- this.recommendation = new RecommendationEndpoints(this.client);
1102
- this.trades = new TradesEndpoints(this.client);
1103
- this.screener = new ScreenerEndpoints(this.client);
1104
- this.usage = new UsageEndpoints(this.client);
1105
- this.batch = new BatchEndpoints(this.client);
1106
- }
1107
- /**
1108
- * Update API key.
1109
- */
1110
- setApiKey(apiKey) {
1111
- this.client.apiKey = apiKey;
1112
- }
1113
- /**
1114
- * Check whether an API key is currently configured.
1115
- */
1116
- hasApiKey() {
1117
- return !!this.client.apiKey;
1118
- }
1119
- }
1120
-
1121
- /**
1122
- * Invezgo SDK for JavaScript and TypeScript.
1123
- *
1124
- * Official SDK for accessing Invezgo API.
1125
- *
1126
- * @packageDocumentation
1127
- */
1128
-
1129
- export { AlertsEndpoints, BatchEndpoints, Invezgo, InvezgoError, JournalsEndpoints, MembershipEndpoints, RecommendationEndpoints, ScreenerEndpoints, TradesEndpoints, UsageEndpoints, WatchlistsEndpoints, Invezgo as default };
1130
- //# sourceMappingURL=index.esm.js.map