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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Reportify
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # Reportify SDK for TypeScript/JavaScript
2
+
3
+ TypeScript SDK for Reportify API - Financial data and document search.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install reportify-sdk
9
+ # or
10
+ yarn add reportify-sdk
11
+ # or
12
+ pnpm add reportify-sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { Reportify } from 'reportify-sdk';
19
+
20
+ // Initialize client
21
+ const client = new Reportify({ apiKey: 'your-api-key' });
22
+
23
+ // Search documents
24
+ const docs = await client.search('Tesla earnings', { num: 10 });
25
+ docs.forEach(doc => console.log(doc.title));
26
+ ```
27
+
28
+ ## Features
29
+
30
+ ### Document Search
31
+
32
+ ```typescript
33
+ // General search across all categories
34
+ const docs = await client.search('revenue growth', { num: 10 });
35
+
36
+ // Search specific document types
37
+ const news = await client.searchNews('Apple iPhone', { num: 10 });
38
+ const reports = await client.searchReports('semiconductor analysis', { num: 10 });
39
+ const filings = await client.searchFilings('10-K annual report', { symbols: ['US:AAPL'] });
40
+ const transcripts = await client.searchTranscripts('guidance', { symbols: ['US:TSLA'] });
41
+ ```
42
+
43
+ ### Stock Data
44
+
45
+ ```typescript
46
+ // Financial statements
47
+ const income = await client.stock.incomeStatement('US:AAPL', { period: 'quarterly' });
48
+ const balance = await client.stock.balanceSheet('US:AAPL');
49
+ const cashflow = await client.stock.cashflowStatement('US:AAPL');
50
+
51
+ // Price data
52
+ const prices = await client.stock.prices('US:AAPL', { limit: 30 });
53
+ const kline = await client.stock.kline('US:TSLA', { interval: '1d', limit: 100 });
54
+
55
+ // Real-time quotes
56
+ const quotes = await client.stock.quote(['US:AAPL', 'US:MSFT']);
57
+
58
+ // Company info
59
+ const overview = await client.stock.overview('US:AAPL');
60
+ const shareholders = await client.stock.shareholders('US:AAPL');
61
+
62
+ // Screening and calendar
63
+ const stocks = await client.stock.screener({ market: 'US', minMarketCap: 1e10 });
64
+ const earnings = await client.stock.earningsCalendar({ area: 'us', startDate: '2024-01-01' });
65
+ ```
66
+
67
+ ### Timeline
68
+
69
+ ```typescript
70
+ // Get timeline for followed entities
71
+ const companies = await client.timeline.companies({ num: 20 });
72
+ const topics = await client.timeline.topics({ num: 20 });
73
+ const institutes = await client.timeline.institutes({ num: 20 });
74
+ const publicMedia = await client.timeline.publicMedia({ num: 20 });
75
+ const socialMedia = await client.timeline.socialMedia({ num: 20 });
76
+ ```
77
+
78
+ ### Knowledge Base
79
+
80
+ ```typescript
81
+ // Search user's uploaded documents
82
+ const chunks = await client.kb.search('quarterly revenue', { folderIds: ['folder_id'] });
83
+ ```
84
+
85
+ ### Documents
86
+
87
+ ```typescript
88
+ // Get document content
89
+ const doc = await client.docs.get('doc_id');
90
+ const summary = await client.docs.summary('doc_id');
91
+
92
+ // List and search documents
93
+ const docs = await client.docs.list({ symbols: ['US:AAPL'], pageSize: 10 });
94
+ const chunks = await client.docs.searchChunks('revenue breakdown', { num: 5 });
95
+ ```
96
+
97
+ ## Error Handling
98
+
99
+ ```typescript
100
+ import {
101
+ Reportify,
102
+ AuthenticationError,
103
+ RateLimitError,
104
+ NotFoundError,
105
+ APIError,
106
+ } from 'reportify-sdk';
107
+
108
+ try {
109
+ const docs = await client.search('Tesla');
110
+ } catch (error) {
111
+ if (error instanceof AuthenticationError) {
112
+ console.log('Invalid API key');
113
+ } else if (error instanceof RateLimitError) {
114
+ console.log('Rate limit exceeded, please wait');
115
+ } else if (error instanceof NotFoundError) {
116
+ console.log('Resource not found');
117
+ } else if (error instanceof APIError) {
118
+ console.log(`API error: ${error.message}`);
119
+ }
120
+ }
121
+ ```
122
+
123
+ ## Configuration
124
+
125
+ ```typescript
126
+ const client = new Reportify({
127
+ apiKey: 'your-api-key',
128
+ baseUrl: 'https://api.reportify.cn', // Optional: custom API URL
129
+ timeout: 30000, // Optional: request timeout in milliseconds
130
+ });
131
+ ```
132
+
133
+ ## TypeScript Support
134
+
135
+ This SDK is written in TypeScript and provides full type definitions out of the box.
136
+
137
+ ```typescript
138
+ import type {
139
+ Document,
140
+ CompanyOverview,
141
+ FinancialStatement,
142
+ PriceData,
143
+ Quote,
144
+ } from 'reportify-sdk';
145
+ ```
146
+
147
+ ## License
148
+
149
+ MIT License - see [LICENSE](LICENSE) for details.
@@ -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 };