reportify-sdk 0.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.
@@ -0,0 +1,505 @@
1
+ /**
2
+ * Reportify SDK Type Definitions
3
+ */
4
+ interface ReportifyConfig {
5
+ /** Your Reportify API key */
6
+ apiKey: string;
7
+ /** Base URL for the API (default: https://api.reportify.cn) */
8
+ baseUrl?: string;
9
+ /** Request timeout in milliseconds (default: 30000) */
10
+ timeout?: number;
11
+ }
12
+ interface Document {
13
+ docId?: string;
14
+ title: string;
15
+ summary: string;
16
+ category: string;
17
+ publishedAt?: number;
18
+ channelId?: string;
19
+ channelName?: string;
20
+ companies?: CompanyInfo[];
21
+ tags?: Record<string, unknown>;
22
+ metadata?: Record<string, unknown>;
23
+ score?: number;
24
+ url?: string;
25
+ }
26
+ interface CompanyInfo {
27
+ name: string;
28
+ industry?: string;
29
+ sector?: string;
30
+ stocks?: StockInfo[];
31
+ }
32
+ interface StockInfo {
33
+ symbol: string;
34
+ market: string;
35
+ ticker: string;
36
+ }
37
+ interface Chunk {
38
+ chunkId: string;
39
+ content: string;
40
+ docId: string;
41
+ score?: number;
42
+ doc?: Document;
43
+ }
44
+ interface PaginatedResponse<T> {
45
+ items: T[];
46
+ total: number;
47
+ page: number;
48
+ pageSize: number;
49
+ }
50
+ interface SearchOptions {
51
+ num?: number;
52
+ categories?: string[];
53
+ symbols?: string[];
54
+ startDate?: string;
55
+ endDate?: string;
56
+ }
57
+ interface CompanyOverview {
58
+ symbol: string;
59
+ name: string;
60
+ description?: string;
61
+ sector?: string;
62
+ industry?: string;
63
+ marketCap?: number;
64
+ employees?: number;
65
+ website?: string;
66
+ [key: string]: unknown;
67
+ }
68
+ interface Shareholder {
69
+ name: string;
70
+ shares: number;
71
+ percentage: number;
72
+ type?: string;
73
+ }
74
+ interface FinancialStatement {
75
+ date: string;
76
+ [key: string]: string | number | null;
77
+ }
78
+ interface PriceData {
79
+ date: string;
80
+ open: number;
81
+ high: number;
82
+ low: number;
83
+ close: number;
84
+ volume: number;
85
+ [key: string]: string | number;
86
+ }
87
+ interface Quote {
88
+ symbol: string;
89
+ price: number;
90
+ change: number;
91
+ changePercent: number;
92
+ volume?: number;
93
+ marketCap?: number;
94
+ timestamp?: number;
95
+ }
96
+ interface EarningsEvent {
97
+ symbol: string;
98
+ companyName: string;
99
+ date: string;
100
+ time?: string;
101
+ epsEstimate?: number;
102
+ epsActual?: number;
103
+ [key: string]: unknown;
104
+ }
105
+ interface IPOEvent {
106
+ symbol?: string;
107
+ companyName: string;
108
+ status: string;
109
+ listingDate?: string;
110
+ priceRange?: string;
111
+ [key: string]: unknown;
112
+ }
113
+ type Period = 'annual' | 'quarterly';
114
+ type Interval = '1d' | '1w' | '1m';
115
+ type PriceAdjust = 'forward' | 'backward' | 'none';
116
+ type Market = 'us' | 'hk' | 'cn';
117
+ type IPOStatus = 'Filing' | 'Hearing' | 'Priced';
118
+ interface TimelineOptions {
119
+ num?: number;
120
+ }
121
+ interface KBSearchOptions {
122
+ folderIds?: string[];
123
+ docIds?: string[];
124
+ startDate?: string;
125
+ endDate?: string;
126
+ num?: number;
127
+ }
128
+ declare class ReportifyError extends Error {
129
+ statusCode?: number;
130
+ constructor(message: string, statusCode?: number);
131
+ }
132
+ declare class AuthenticationError extends ReportifyError {
133
+ constructor(message?: string);
134
+ }
135
+ declare class RateLimitError extends ReportifyError {
136
+ constructor(message?: string);
137
+ }
138
+ declare class NotFoundError extends ReportifyError {
139
+ constructor(message?: string);
140
+ }
141
+ declare class APIError extends ReportifyError {
142
+ constructor(message: string, statusCode?: number);
143
+ }
144
+
145
+ /**
146
+ * Stock Module
147
+ *
148
+ * Provides access to stock market data including prices, financial statements,
149
+ * and company information.
150
+ */
151
+
152
+ declare class StockModule {
153
+ private client;
154
+ constructor(client: Reportify);
155
+ /**
156
+ * Get company overview including business description, sector, and key metrics
157
+ *
158
+ * @param symbol - Stock symbol (e.g., "US:AAPL", "HK:0700")
159
+ */
160
+ overview(symbol: string): Promise<CompanyOverview>;
161
+ /**
162
+ * Get list of major shareholders
163
+ *
164
+ * @param symbol - Stock symbol
165
+ */
166
+ shareholders(symbol: string): Promise<Shareholder[]>;
167
+ /**
168
+ * Get income statement data
169
+ *
170
+ * @param symbol - Stock symbol
171
+ * @param options.period - "annual" or "quarterly"
172
+ * @param options.limit - Number of periods to return
173
+ */
174
+ incomeStatement(symbol: string, options?: {
175
+ period?: Period;
176
+ limit?: number;
177
+ }): Promise<FinancialStatement[]>;
178
+ /**
179
+ * Get balance sheet data
180
+ *
181
+ * @param symbol - Stock symbol
182
+ * @param options.period - "annual" or "quarterly"
183
+ * @param options.limit - Number of periods to return
184
+ */
185
+ balanceSheet(symbol: string, options?: {
186
+ period?: Period;
187
+ limit?: number;
188
+ }): Promise<FinancialStatement[]>;
189
+ /**
190
+ * Get cash flow statement data
191
+ *
192
+ * @param symbol - Stock symbol
193
+ * @param options.period - "annual" or "quarterly"
194
+ * @param options.limit - Number of periods to return
195
+ */
196
+ cashflowStatement(symbol: string, options?: {
197
+ period?: Period;
198
+ limit?: number;
199
+ }): Promise<FinancialStatement[]>;
200
+ /**
201
+ * Get revenue breakdown by segment, product, or region
202
+ *
203
+ * @param symbol - Stock symbol
204
+ * @param options.breakdownType - Type of breakdown
205
+ */
206
+ revenueBreakdown(symbol: string, options?: {
207
+ breakdownType?: 'segment' | 'product' | 'region';
208
+ }): Promise<FinancialStatement[]>;
209
+ /**
210
+ * Get historical stock prices
211
+ *
212
+ * @param symbol - Stock symbol
213
+ * @param options - Query options
214
+ */
215
+ prices(symbol: string, options?: {
216
+ startDate?: string;
217
+ endDate?: string;
218
+ limit?: number;
219
+ }): Promise<PriceData[]>;
220
+ /**
221
+ * Get K-line (candlestick) data
222
+ *
223
+ * @param symbol - Stock symbol
224
+ * @param options - Query options
225
+ */
226
+ kline(symbol: string, options?: {
227
+ interval?: Interval;
228
+ adjust?: PriceAdjust;
229
+ startDate?: string;
230
+ endDate?: string;
231
+ limit?: number;
232
+ }): Promise<PriceData[]>;
233
+ /**
234
+ * Get real-time stock quotes
235
+ *
236
+ * @param symbols - Single symbol or array of symbols
237
+ */
238
+ quote(symbols: string | string[]): Promise<Quote[]>;
239
+ /**
240
+ * Get stock index prices
241
+ *
242
+ * @param symbol - Index symbol
243
+ * @param options - Query options
244
+ */
245
+ indexPrices(symbol: string, options?: {
246
+ startDate?: string;
247
+ endDate?: string;
248
+ limit?: number;
249
+ }): Promise<PriceData[]>;
250
+ /**
251
+ * Screen stocks based on various criteria
252
+ */
253
+ screener(options?: {
254
+ market?: string;
255
+ sector?: string;
256
+ minMarketCap?: number;
257
+ maxMarketCap?: number;
258
+ minPe?: number;
259
+ maxPe?: number;
260
+ limit?: number;
261
+ }): Promise<CompanyOverview[]>;
262
+ /**
263
+ * Get earnings announcement calendar
264
+ */
265
+ earningsCalendar(options?: {
266
+ area?: Market;
267
+ startDate?: string;
268
+ endDate?: string;
269
+ symbol?: string;
270
+ }): Promise<EarningsEvent[]>;
271
+ /**
272
+ * Get Hong Kong IPO calendar
273
+ */
274
+ ipoCalendarHK(status?: IPOStatus): Promise<IPOEvent[]>;
275
+ private normalizeArrayResponse;
276
+ }
277
+
278
+ /**
279
+ * Timeline Module
280
+ *
281
+ * Provides access to timeline feeds based on user's followed entities.
282
+ */
283
+
284
+ declare class TimelineModule {
285
+ private client;
286
+ constructor(client: Reportify);
287
+ /**
288
+ * Get timeline for followed companies
289
+ *
290
+ * Returns recent content related to companies the user is following.
291
+ *
292
+ * @param options.num - Number of items to return (default: 10, max: 100)
293
+ */
294
+ companies(options?: TimelineOptions): Promise<Document[]>;
295
+ /**
296
+ * Get timeline for followed topics
297
+ *
298
+ * Returns recent content related to custom topics the user is following.
299
+ *
300
+ * @param options.num - Number of items to return
301
+ */
302
+ topics(options?: TimelineOptions): Promise<Document[]>;
303
+ /**
304
+ * Get timeline for followed professional institutes
305
+ *
306
+ * Returns recent content from research institutions, banks, etc.
307
+ *
308
+ * @param options.num - Number of items to return
309
+ */
310
+ institutes(options?: TimelineOptions): Promise<Document[]>;
311
+ /**
312
+ * Get timeline for followed public media
313
+ *
314
+ * Returns recent content from public media accounts.
315
+ *
316
+ * @param options.num - Number of items to return
317
+ */
318
+ publicMedia(options?: TimelineOptions): Promise<Document[]>;
319
+ /**
320
+ * Get timeline for followed social media
321
+ *
322
+ * Returns recent content from social media accounts.
323
+ *
324
+ * @param options.num - Number of items to return
325
+ */
326
+ socialMedia(options?: TimelineOptions): Promise<Document[]>;
327
+ }
328
+
329
+ /**
330
+ * Knowledge Base Module
331
+ *
332
+ * Provides access to user's personal knowledge base for searching
333
+ * uploaded documents.
334
+ */
335
+
336
+ declare class KBModule {
337
+ private client;
338
+ constructor(client: Reportify);
339
+ /**
340
+ * Search user's knowledge base
341
+ *
342
+ * Performs semantic search across documents the user has uploaded.
343
+ *
344
+ * @param query - Search query string
345
+ * @param options - Search options
346
+ *
347
+ * @example
348
+ * ```typescript
349
+ * const results = await client.kb.search('quarterly revenue', { num: 5 });
350
+ * results.forEach(chunk => console.log(chunk.content));
351
+ * ```
352
+ */
353
+ search(query: string, options?: KBSearchOptions): Promise<Chunk[]>;
354
+ }
355
+
356
+ /**
357
+ * Documents Module
358
+ *
359
+ * Provides access to document content, metadata, and summaries.
360
+ */
361
+
362
+ interface DocContent {
363
+ docId: string;
364
+ title: string;
365
+ content?: string;
366
+ chunks?: Chunk[];
367
+ fileUrl?: string;
368
+ mediaUrl?: string;
369
+ [key: string]: unknown;
370
+ }
371
+ interface DocSummary {
372
+ docId: string;
373
+ title: string;
374
+ summary: string;
375
+ keyPoints?: string[];
376
+ [key: string]: unknown;
377
+ }
378
+ interface DocsListOptions {
379
+ symbols?: string[];
380
+ categories?: string[];
381
+ startDate?: string;
382
+ endDate?: string;
383
+ page?: number;
384
+ pageSize?: number;
385
+ }
386
+ interface ChunkSearchOptions {
387
+ symbols?: string[];
388
+ categories?: string[];
389
+ startDate?: string;
390
+ endDate?: string;
391
+ num?: number;
392
+ }
393
+ declare class DocsModule {
394
+ private client;
395
+ constructor(client: Reportify);
396
+ /**
397
+ * Get document content and metadata
398
+ *
399
+ * @param docId - Document ID
400
+ */
401
+ get(docId: string): Promise<DocContent>;
402
+ /**
403
+ * Get document summary
404
+ *
405
+ * @param docId - Document ID
406
+ */
407
+ summary(docId: string): Promise<DocSummary>;
408
+ /**
409
+ * Get raw document content
410
+ *
411
+ * @param docId - Document ID
412
+ */
413
+ rawContent(docId: string): Promise<DocContent>;
414
+ /**
415
+ * List documents with filters
416
+ *
417
+ * @param options - Filter options
418
+ */
419
+ list(options?: DocsListOptions): Promise<PaginatedResponse<Document>>;
420
+ /**
421
+ * Search document chunks semantically
422
+ *
423
+ * @param query - Search query string
424
+ * @param options - Search options
425
+ */
426
+ searchChunks(query: string, options?: ChunkSearchOptions): Promise<Chunk[]>;
427
+ }
428
+
429
+ /**
430
+ * Reportify Client
431
+ *
432
+ * Main client class for interacting with the Reportify API.
433
+ */
434
+
435
+ /**
436
+ * Reportify API Client
437
+ *
438
+ * A user-friendly client for accessing financial data, document search,
439
+ * and knowledge base through the Reportify API.
440
+ *
441
+ * @example
442
+ * ```typescript
443
+ * import { Reportify } from 'reportify-sdk';
444
+ *
445
+ * const client = new Reportify({ apiKey: 'your-api-key' });
446
+ * const docs = await client.search('Tesla earnings', { num: 10 });
447
+ * ```
448
+ */
449
+ declare class Reportify {
450
+ private apiKey;
451
+ private baseUrl;
452
+ private timeout;
453
+ readonly stock: StockModule;
454
+ readonly timeline: TimelineModule;
455
+ readonly kb: KBModule;
456
+ readonly docs: DocsModule;
457
+ constructor(config: ReportifyConfig);
458
+ /**
459
+ * Make an HTTP request to the API
460
+ */
461
+ request<T = unknown>(method: string, path: string, options?: {
462
+ params?: Record<string, unknown>;
463
+ body?: Record<string, unknown>;
464
+ }): Promise<T>;
465
+ /**
466
+ * Make a GET request
467
+ */
468
+ get<T = unknown>(path: string, params?: Record<string, unknown>): Promise<T>;
469
+ /**
470
+ * Make a POST request
471
+ */
472
+ post<T = unknown>(path: string, body?: Record<string, unknown>): Promise<T>;
473
+ /**
474
+ * Search documents across all categories
475
+ *
476
+ * @param query - Search query string
477
+ * @param options - Search options
478
+ * @returns List of matching documents
479
+ *
480
+ * @example
481
+ * ```typescript
482
+ * const docs = await client.search('Tesla earnings', { num: 10 });
483
+ * docs.forEach(doc => console.log(doc.title));
484
+ * ```
485
+ */
486
+ search(query: string, options?: SearchOptions): Promise<Document[]>;
487
+ /**
488
+ * Search news articles
489
+ */
490
+ searchNews(query: string, options?: SearchOptions): Promise<Document[]>;
491
+ /**
492
+ * Search research reports
493
+ */
494
+ searchReports(query: string, options?: SearchOptions): Promise<Document[]>;
495
+ /**
496
+ * Search company filings
497
+ */
498
+ searchFilings(query: string, options?: SearchOptions): Promise<Document[]>;
499
+ /**
500
+ * Search earnings call transcripts
501
+ */
502
+ searchTranscripts(query: string, options?: SearchOptions): Promise<Document[]>;
503
+ }
504
+
505
+ export { APIError, AuthenticationError, type Chunk, type CompanyInfo, type CompanyOverview, DocsModule, type Document, type EarningsEvent, type FinancialStatement, type IPOEvent, type IPOStatus, type Interval, KBModule, type KBSearchOptions, type Market, NotFoundError, type PaginatedResponse, type Period, type PriceAdjust, type PriceData, type Quote, RateLimitError, Reportify, type ReportifyConfig, ReportifyError, type SearchOptions, type Shareholder, type StockInfo, StockModule, TimelineModule, type TimelineOptions };