fmp-node-api 0.1.8 โ 0.2.0-beta.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 +21 -21
- package/README.md +747 -719
- package/dist/index.d.mts +298 -9
- package/dist/index.d.ts +298 -9
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/types-only.d.mts +3071 -385
- package/dist/types-only.d.ts +3071 -385
- package/dist/utils/validation.d.mts +1 -0
- package/dist/utils/validation.d.ts +1 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,719 +1,747 @@
|
|
|
1
|
-
# FMP Node API Wrapper
|
|
2
|
-
|
|
3
|
-
A comprehensive Node.js wrapper for the Financial Modeling Prep (FMP) API with full TypeScript support and organized endpoint structure.
|
|
4
|
-
|
|
5
|
-
> **๐ Visit the [Documentation](https://fmp-node-wrapper-docs.vercel.app/) for detailed information.**
|
|
6
|
-
|
|
7
|
-
> **๐ง For development information, contributing guidelines, and project details, visit the [main repository](https://github.com/e-roy/fmp-node-wrapper).**
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- ๐ **Complete TypeScript Support** - Full type safety for all API responses
|
|
12
|
-
- ๐ฆ **Organized Structure** - Clean separation of concerns with dedicated modules
|
|
13
|
-
- ๐ง **Easy to Use** - Simple, intuitive API with minimal boilerplate
|
|
14
|
-
- ๐ **Comprehensive Coverage** - Support for all FMP stable endpoints
|
|
15
|
-
- ๐ก๏ธ **Input Validation** - Built-in validation for all parameters
|
|
16
|
-
- ๐ฏ **Modular Design** - Import only what you need
|
|
17
|
-
- ๐งช **Comprehensive Testing** - Full test suite with 45+ tests covering all endpoints
|
|
18
|
-
- ๐ **Real-time Data** - Access to live market data and financial statements
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install fmp-node-api
|
|
24
|
-
# or
|
|
25
|
-
yarn add fmp-node-api
|
|
26
|
-
# or
|
|
27
|
-
pnpm add fmp-node-api
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
import { FMP } from 'fmp-node-api';
|
|
34
|
-
|
|
35
|
-
// Option 1: Use environment variable (recommended)
|
|
36
|
-
const fmp = new FMP(); // Automatically uses FMP_API_KEY from environment
|
|
37
|
-
|
|
38
|
-
// Option 2: Provide API key directly
|
|
39
|
-
const fmp = new FMP({ apiKey: 'your-api-key' });
|
|
40
|
-
|
|
41
|
-
// Option 3: Provide partial config with environment variable fallback
|
|
42
|
-
const fmp = new FMP({ timeout: 15000 }); // Uses FMP_API_KEY from environment
|
|
43
|
-
|
|
44
|
-
// Get stock quote
|
|
45
|
-
const quote = await fmp.quote.getQuote('AAPL');
|
|
46
|
-
|
|
47
|
-
// Get financial statements
|
|
48
|
-
const incomeStatement = await fmp.financial.getIncomeStatement({
|
|
49
|
-
symbol: 'AAPL',
|
|
50
|
-
period: 'annual',
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Get forex data
|
|
54
|
-
const forexQuote = await fmp.quote.getQuote('EURUSD');
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Configuration
|
|
58
|
-
|
|
59
|
-
The FMP client supports multiple ways to configure your API key:
|
|
60
|
-
|
|
61
|
-
### Environment Variable (Recommended)
|
|
62
|
-
|
|
63
|
-
Set the `FMP_API_KEY` environment variable in your `.env` file or system environment:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
# .env file
|
|
67
|
-
FMP_API_KEY=your-api-key-here
|
|
68
|
-
|
|
69
|
-
# Or set in your system
|
|
70
|
-
export FMP_API_KEY=your-api-key-here
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Then initialize the client without any parameters:
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
import { FMP } from 'fmp-node-api';
|
|
77
|
-
|
|
78
|
-
const fmp = new FMP(); // Automatically uses FMP_API_KEY
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Direct Configuration
|
|
82
|
-
|
|
83
|
-
Provide the API key directly in the constructor:
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
import { FMP } from 'fmp-node-api';
|
|
87
|
-
|
|
88
|
-
const fmp = new FMP({
|
|
89
|
-
apiKey: 'your-api-key-here',
|
|
90
|
-
timeout: 10000, // optional
|
|
91
|
-
});
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Mixed Configuration
|
|
95
|
-
|
|
96
|
-
You can provide partial configuration and let the client fall back to environment variables:
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
import { FMP } from 'fmp-node-api';
|
|
100
|
-
|
|
101
|
-
const fmp = new FMP({
|
|
102
|
-
timeout: 15000, // custom timeout
|
|
103
|
-
// apiKey will be loaded from FMP_API_KEY environment variable
|
|
104
|
-
});
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Configuration Options
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
interface FMPConfig {
|
|
111
|
-
apiKey?: string; // Optional: API key (falls back to FMP_API_KEY env var)
|
|
112
|
-
timeout?: number; // Optional: Request timeout in milliseconds (default: 10000)
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## API Structure
|
|
117
|
-
|
|
118
|
-
The library is organized into logical modules for easy navigation and usage:
|
|
119
|
-
|
|
120
|
-
### Main Client
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
import { FMP } from 'fmp-node-api';
|
|
124
|
-
|
|
125
|
-
// Using environment variable (recommended)
|
|
126
|
-
const fmp = new FMP();
|
|
127
|
-
|
|
128
|
-
// Or with explicit configuration
|
|
129
|
-
const fmp = new FMP({
|
|
130
|
-
apiKey: 'your-api-key',
|
|
131
|
-
timeout: 10000, // optional
|
|
132
|
-
});
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Available Modules
|
|
136
|
-
|
|
137
|
-
- **`fmp.quote`** - Quote data for stocks, forex, crypto, commodities, and ETFs
|
|
138
|
-
- **`fmp.stock`** - Stock market data (market cap, splits, dividends, real-time prices)
|
|
139
|
-
- **`fmp.financial`** - Financial statements (income, balance sheet, cash flow)
|
|
140
|
-
- **`fmp.company`** - Company information and profiles
|
|
141
|
-
- **`fmp.etf`** - ETF data and holdings
|
|
142
|
-
- **`fmp.mutualFund`** - Mutual fund data
|
|
143
|
-
- **`fmp.economic`** - Economic indicators
|
|
144
|
-
- **`fmp.market`** - Market-wide data and performance
|
|
145
|
-
- **`fmp.list`** - Stock lists and indices
|
|
146
|
-
- **`fmp.
|
|
147
|
-
- **`fmp.
|
|
148
|
-
- **`fmp.
|
|
149
|
-
- **`fmp.
|
|
150
|
-
- **`fmp.
|
|
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
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
// Earnings calendar
|
|
288
|
-
const earnings = await fmp.calendar.getEarningsCalendar({
|
|
289
|
-
from: '2024-01-01',
|
|
290
|
-
to: '2024-12-31',
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
// Economic calendar
|
|
294
|
-
const economic = await fmp.calendar.getEconomicCalendar({
|
|
295
|
-
from: '2024-01-01',
|
|
296
|
-
to: '2024-12-31',
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
// Company
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
pnpm test
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
error: null
|
|
385
|
-
status:
|
|
386
|
-
}
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
```typescript
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
##
|
|
426
|
-
|
|
427
|
-
The library
|
|
428
|
-
|
|
429
|
-
```typescript
|
|
430
|
-
import {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const client =
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
pnpm test
|
|
502
|
-
|
|
503
|
-
#
|
|
504
|
-
pnpm test:
|
|
505
|
-
pnpm test:
|
|
506
|
-
|
|
507
|
-
#
|
|
508
|
-
pnpm test:
|
|
509
|
-
pnpm test:
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
#
|
|
533
|
-
|
|
534
|
-
#
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
pnpm
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
pnpm
|
|
567
|
-
|
|
568
|
-
#
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
pnpm
|
|
574
|
-
|
|
575
|
-
#
|
|
576
|
-
pnpm
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
โ
|
|
625
|
-
โ
|
|
626
|
-
โ
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
#
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
#
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
#
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
- **
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
-
|
|
1
|
+
# FMP Node API Wrapper
|
|
2
|
+
|
|
3
|
+
A comprehensive Node.js wrapper for the Financial Modeling Prep (FMP) API with full TypeScript support and organized endpoint structure.
|
|
4
|
+
|
|
5
|
+
> **๐ Visit the [Documentation](https://fmp-node-wrapper-docs.vercel.app/) for detailed information.**
|
|
6
|
+
|
|
7
|
+
> **๐ง For development information, contributing guidelines, and project details, visit the [main repository](https://github.com/e-roy/fmp-node-wrapper).**
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- ๐ **Complete TypeScript Support** - Full type safety for all API responses
|
|
12
|
+
- ๐ฆ **Organized Structure** - Clean separation of concerns with dedicated modules
|
|
13
|
+
- ๐ง **Easy to Use** - Simple, intuitive API with minimal boilerplate
|
|
14
|
+
- ๐ **Comprehensive Coverage** - Support for all FMP stable endpoints
|
|
15
|
+
- ๐ก๏ธ **Input Validation** - Built-in validation for all parameters
|
|
16
|
+
- ๐ฏ **Modular Design** - Import only what you need
|
|
17
|
+
- ๐งช **Comprehensive Testing** - Full test suite with 45+ tests covering all endpoints
|
|
18
|
+
- ๐ **Real-time Data** - Access to live market data and financial statements
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install fmp-node-api
|
|
24
|
+
# or
|
|
25
|
+
yarn add fmp-node-api
|
|
26
|
+
# or
|
|
27
|
+
pnpm add fmp-node-api
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { FMP } from 'fmp-node-api';
|
|
34
|
+
|
|
35
|
+
// Option 1: Use environment variable (recommended)
|
|
36
|
+
const fmp = new FMP(); // Automatically uses FMP_API_KEY from environment
|
|
37
|
+
|
|
38
|
+
// Option 2: Provide API key directly
|
|
39
|
+
const fmp = new FMP({ apiKey: 'your-api-key' });
|
|
40
|
+
|
|
41
|
+
// Option 3: Provide partial config with environment variable fallback
|
|
42
|
+
const fmp = new FMP({ timeout: 15000 }); // Uses FMP_API_KEY from environment
|
|
43
|
+
|
|
44
|
+
// Get stock quote
|
|
45
|
+
const quote = await fmp.quote.getQuote('AAPL');
|
|
46
|
+
|
|
47
|
+
// Get financial statements
|
|
48
|
+
const incomeStatement = await fmp.financial.getIncomeStatement({
|
|
49
|
+
symbol: 'AAPL',
|
|
50
|
+
period: 'annual',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Get forex data
|
|
54
|
+
const forexQuote = await fmp.quote.getQuote('EURUSD');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
The FMP client supports multiple ways to configure your API key:
|
|
60
|
+
|
|
61
|
+
### Environment Variable (Recommended)
|
|
62
|
+
|
|
63
|
+
Set the `FMP_API_KEY` environment variable in your `.env` file or system environment:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# .env file
|
|
67
|
+
FMP_API_KEY=your-api-key-here
|
|
68
|
+
|
|
69
|
+
# Or set in your system
|
|
70
|
+
export FMP_API_KEY=your-api-key-here
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Then initialize the client without any parameters:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { FMP } from 'fmp-node-api';
|
|
77
|
+
|
|
78
|
+
const fmp = new FMP(); // Automatically uses FMP_API_KEY
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Direct Configuration
|
|
82
|
+
|
|
83
|
+
Provide the API key directly in the constructor:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { FMP } from 'fmp-node-api';
|
|
87
|
+
|
|
88
|
+
const fmp = new FMP({
|
|
89
|
+
apiKey: 'your-api-key-here',
|
|
90
|
+
timeout: 10000, // optional
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Mixed Configuration
|
|
95
|
+
|
|
96
|
+
You can provide partial configuration and let the client fall back to environment variables:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { FMP } from 'fmp-node-api';
|
|
100
|
+
|
|
101
|
+
const fmp = new FMP({
|
|
102
|
+
timeout: 15000, // custom timeout
|
|
103
|
+
// apiKey will be loaded from FMP_API_KEY environment variable
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Configuration Options
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
interface FMPConfig {
|
|
111
|
+
apiKey?: string; // Optional: API key (falls back to FMP_API_KEY env var)
|
|
112
|
+
timeout?: number; // Optional: Request timeout in milliseconds (default: 10000)
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## API Structure
|
|
117
|
+
|
|
118
|
+
The library is organized into logical modules for easy navigation and usage:
|
|
119
|
+
|
|
120
|
+
### Main Client
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { FMP } from 'fmp-node-api';
|
|
124
|
+
|
|
125
|
+
// Using environment variable (recommended)
|
|
126
|
+
const fmp = new FMP();
|
|
127
|
+
|
|
128
|
+
// Or with explicit configuration
|
|
129
|
+
const fmp = new FMP({
|
|
130
|
+
apiKey: 'your-api-key',
|
|
131
|
+
timeout: 10000, // optional
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Available Modules
|
|
136
|
+
|
|
137
|
+
- **`fmp.quote`** - Quote data for stocks, forex, crypto, commodities, and ETFs
|
|
138
|
+
- **`fmp.stock`** - Stock market data (market cap, splits, dividends, real-time prices)
|
|
139
|
+
- **`fmp.financial`** - Financial statements (income, balance sheet, cash flow)
|
|
140
|
+
- **`fmp.company`** - Company information and profiles
|
|
141
|
+
- **`fmp.etf`** - ETF data and holdings
|
|
142
|
+
- **`fmp.mutualFund`** - Mutual fund data
|
|
143
|
+
- **`fmp.economic`** - Economic indicators
|
|
144
|
+
- **`fmp.market`** - Market-wide data and performance
|
|
145
|
+
- **`fmp.list`** - Stock lists and indices
|
|
146
|
+
- **`fmp.screener`** - Stock screener with filters and available exchanges/sectors/industries/countries
|
|
147
|
+
- **`fmp.calendar`** - Earnings and economic calendar
|
|
148
|
+
- **`fmp.senateHouse`** - Congressional trading data
|
|
149
|
+
- **`fmp.institutional`** - Form 13F filings and institutional ownership
|
|
150
|
+
- **`fmp.insider`** - Insider trading data
|
|
151
|
+
- **`fmp.sec`** - SEC filings and industry classification
|
|
152
|
+
- **`fmp.news`** - Financial news articles (general, stock, crypto, forex; by symbol or latest)
|
|
153
|
+
|
|
154
|
+
## Usage Examples
|
|
155
|
+
|
|
156
|
+
### Quote Data
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
// Get real-time quote for any asset type
|
|
160
|
+
const quote = await fmp.quote.getQuote('AAPL');
|
|
161
|
+
|
|
162
|
+
// Get multiple quotes
|
|
163
|
+
const quotes = await fmp.quote.getQuotes(['AAPL', 'MSFT', 'GOOGL']);
|
|
164
|
+
|
|
165
|
+
// Get historical prices
|
|
166
|
+
const historical = await fmp.quote.getHistoricalPrice({
|
|
167
|
+
symbol: 'AAPL',
|
|
168
|
+
from: '2024-01-01',
|
|
169
|
+
to: '2024-12-31',
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Get intraday data
|
|
173
|
+
const intraday = await fmp.quote.getIntraday({
|
|
174
|
+
symbol: 'AAPL',
|
|
175
|
+
interval: '1hour',
|
|
176
|
+
from: '2024-01-01',
|
|
177
|
+
to: '2024-01-02',
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Stock Data
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// Get market capitalization
|
|
185
|
+
const marketCap = await fmp.stock.getMarketCap('AAPL');
|
|
186
|
+
|
|
187
|
+
// Get stock splits
|
|
188
|
+
const splits = await fmp.stock.getStockSplits('AAPL');
|
|
189
|
+
|
|
190
|
+
// Get dividend history
|
|
191
|
+
const dividends = await fmp.stock.getDividendHistory('AAPL');
|
|
192
|
+
|
|
193
|
+
// Get real-time price data
|
|
194
|
+
const realTimePrice = await fmp.stock.getRealTimePrice(['AAPL', 'MSFT', 'GOOGL']);
|
|
195
|
+
|
|
196
|
+
// Get full real-time price data
|
|
197
|
+
const fullRealTimeData = await fmp.stock.getRealTimePriceForMultipleStocks([
|
|
198
|
+
'AAPL',
|
|
199
|
+
'MSFT',
|
|
200
|
+
'GOOGL',
|
|
201
|
+
]);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Financial Statements
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
// Get income statement
|
|
208
|
+
const income = await fmp.financial.getIncomeStatement({
|
|
209
|
+
symbol: 'AAPL',
|
|
210
|
+
period: 'annual',
|
|
211
|
+
limit: 10,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// Get balance sheet
|
|
215
|
+
const balance = await fmp.financial.getBalanceSheet({
|
|
216
|
+
symbol: 'AAPL',
|
|
217
|
+
period: 'quarter',
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// Get cash flow statement
|
|
221
|
+
const cashFlow = await fmp.financial.getCashFlowStatement({
|
|
222
|
+
symbol: 'AAPL',
|
|
223
|
+
period: 'annual',
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// Get key metrics
|
|
227
|
+
const metrics = await fmp.financial.getKeyMetrics({ symbol: 'AAPL' });
|
|
228
|
+
|
|
229
|
+
// Get financial ratios
|
|
230
|
+
const ratios = await fmp.financial.getFinancialRatios({ symbol: 'AAPL' });
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Market Data
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
// Get market hours
|
|
237
|
+
const hours = await fmp.market.getMarketHours();
|
|
238
|
+
|
|
239
|
+
// Get market performance
|
|
240
|
+
const performance = await fmp.market.getMarketPerformance();
|
|
241
|
+
|
|
242
|
+
// Get gainers and losers
|
|
243
|
+
const gainers = await fmp.market.getGainers();
|
|
244
|
+
const losers = await fmp.market.getLosers();
|
|
245
|
+
|
|
246
|
+
// Get most active stocks
|
|
247
|
+
const mostActive = await fmp.market.getMostActive();
|
|
248
|
+
|
|
249
|
+
// Get sector performance
|
|
250
|
+
const sectors = await fmp.market.getSectorPerformance();
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Economic Indicators
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
// Get treasury rates
|
|
257
|
+
const treasury = await fmp.economic.getTreasuryRates({
|
|
258
|
+
from: '2024-01-01',
|
|
259
|
+
to: '2024-12-31',
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// Get economic indicators by name (GDP, CPI, federalFunds, unemploymentRate, โฆ)
|
|
263
|
+
const gdp = await fmp.economic.getEconomicIndicators({
|
|
264
|
+
name: 'GDP',
|
|
265
|
+
from: '2024-01-01',
|
|
266
|
+
to: '2024-12-31',
|
|
267
|
+
});
|
|
268
|
+
const cpi = await fmp.economic.getEconomicIndicators({ name: 'CPI' });
|
|
269
|
+
const unemployment = await fmp.economic.getEconomicIndicators({ name: 'unemploymentRate' });
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Other Asset Classes
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
// Forex
|
|
276
|
+
const forexQuote = await fmp.quote.getQuote('EURUSD');
|
|
277
|
+
|
|
278
|
+
// Cryptocurrency
|
|
279
|
+
const cryptoQuote = await fmp.quote.getQuote('BTCUSD');
|
|
280
|
+
|
|
281
|
+
// Symbol lists
|
|
282
|
+
const stocks = await fmp.list.getStockList();
|
|
283
|
+
const etfs = await fmp.list.getETFList();
|
|
284
|
+
const crypto = await fmp.list.getCryptoList();
|
|
285
|
+
const indexes = await fmp.list.getAvailableIndexes();
|
|
286
|
+
|
|
287
|
+
// Earnings calendar
|
|
288
|
+
const earnings = await fmp.calendar.getEarningsCalendar({
|
|
289
|
+
from: '2024-01-01',
|
|
290
|
+
to: '2024-12-31',
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Economic calendar
|
|
294
|
+
const economic = await fmp.calendar.getEconomicCalendar({
|
|
295
|
+
from: '2024-01-01',
|
|
296
|
+
to: '2024-12-31',
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// Company profile
|
|
300
|
+
const companyProfile = await fmp.company.getCompanyProfile('AAPL');
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Stock Screener
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
// Filter stocks by multiple criteria
|
|
307
|
+
const results = await fmp.screener.getScreener({
|
|
308
|
+
marketCapMoreThan: 10000000000,
|
|
309
|
+
sector: 'Technology',
|
|
310
|
+
isActivelyTrading: true,
|
|
311
|
+
limit: 50,
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// Lookups for available filter values
|
|
315
|
+
const exchanges = await fmp.screener.getAvailableExchanges();
|
|
316
|
+
const sectors = await fmp.screener.getAvailableSectors();
|
|
317
|
+
const industries = await fmp.screener.getAvailableIndustries();
|
|
318
|
+
const countries = await fmp.screener.getAvailableCountries();
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### News
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
// Latest news by asset class
|
|
325
|
+
const stockNews = await fmp.news.getStockNews({ from: '2024-01-01', to: '2024-01-31' });
|
|
326
|
+
const cryptoNews = await fmp.news.getCryptoNews({ limit: 50 });
|
|
327
|
+
const forexNews = await fmp.news.getForexNews({ limit: 50 });
|
|
328
|
+
|
|
329
|
+
// FMP-authored articles
|
|
330
|
+
const articles = await fmp.news.getArticles({ page: 1, limit: 20 });
|
|
331
|
+
|
|
332
|
+
// News for specific symbols
|
|
333
|
+
const aaplNews = await fmp.news.getStockNewsBySymbol({ symbols: ['AAPL', 'MSFT'] });
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Testing
|
|
337
|
+
|
|
338
|
+
This package includes comprehensive tests for all endpoints. There are two test scripts available:
|
|
339
|
+
|
|
340
|
+
### Local Development
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
pnpm test
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
- Uses Jest to run all tests
|
|
347
|
+
- **Fully mocked and deterministic** โ no network and no API key required
|
|
348
|
+
- Live API validation is handled separately by `pnpm test:live` (see below)
|
|
349
|
+
|
|
350
|
+
### Running Specific Tests
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# Run only unit tests (client + main FMP class)
|
|
354
|
+
pnpm test:unit
|
|
355
|
+
|
|
356
|
+
# Run tests for specific endpoints
|
|
357
|
+
pnpm test:stock
|
|
358
|
+
pnpm test:financial
|
|
359
|
+
pnpm test:market
|
|
360
|
+
pnpm test:quote
|
|
361
|
+
pnpm test:economic
|
|
362
|
+
pnpm test:list
|
|
363
|
+
pnpm test:calendar
|
|
364
|
+
pnpm test:company
|
|
365
|
+
|
|
366
|
+
# Run all endpoint tests
|
|
367
|
+
pnpm test:endpoints
|
|
368
|
+
|
|
369
|
+
# Inspect one endpoint's raw response against the live API
|
|
370
|
+
pnpm test:endpoint <name>
|
|
371
|
+
|
|
372
|
+
# Validate response shapes against the live API (needs FMP_API_KEY)
|
|
373
|
+
pnpm test:live
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Response Format
|
|
377
|
+
|
|
378
|
+
All API methods return a standardized response format:
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
interface APIResponse<T> {
|
|
382
|
+
success: boolean;
|
|
383
|
+
data: T | null;
|
|
384
|
+
error: string | null;
|
|
385
|
+
status: number;
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Example Response
|
|
390
|
+
|
|
391
|
+
```typescript
|
|
392
|
+
{
|
|
393
|
+
success: true,
|
|
394
|
+
data: {
|
|
395
|
+
symbol: 'AAPL',
|
|
396
|
+
price: 150.25,
|
|
397
|
+
change: 2.15,
|
|
398
|
+
changePercent: 1.45,
|
|
399
|
+
// ... other fields
|
|
400
|
+
},
|
|
401
|
+
error: null,
|
|
402
|
+
status: 200
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## Error Handling
|
|
407
|
+
|
|
408
|
+
```typescript
|
|
409
|
+
try {
|
|
410
|
+
const quote = await fmp.quote.getQuote('INVALID');
|
|
411
|
+
|
|
412
|
+
if (!quote.success) {
|
|
413
|
+
console.error('API Error:', quote.error);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (quote.data) {
|
|
418
|
+
console.log('Quote:', quote.data);
|
|
419
|
+
}
|
|
420
|
+
} catch (error) {
|
|
421
|
+
console.error('Network Error:', error);
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
## Type Safety
|
|
426
|
+
|
|
427
|
+
The library provides full TypeScript support with comprehensive type definitions included in the main package:
|
|
428
|
+
|
|
429
|
+
```typescript
|
|
430
|
+
import { Quote, MarketCap, IncomeStatement } from 'fmp-node-api';
|
|
431
|
+
|
|
432
|
+
// All responses are properly typed
|
|
433
|
+
const quote: APIResponse<Quote> = await fmp.quote.getQuote('AAPL');
|
|
434
|
+
const marketCap: APIResponse<MarketCap> = await fmp.stock.getMarketCap('AAPL');
|
|
435
|
+
const income: APIResponse<IncomeStatement[]> = await fmp.financial.getIncomeStatement({
|
|
436
|
+
symbol: 'AAPL',
|
|
437
|
+
});
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
All API responses and parameters are fully typed for complete type safety.
|
|
441
|
+
|
|
442
|
+
## Utilities
|
|
443
|
+
|
|
444
|
+
The library includes helpful utilities for data formatting and validation:
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
import {
|
|
448
|
+
formatCurrency,
|
|
449
|
+
formatPercentage,
|
|
450
|
+
formatLargeNumber,
|
|
451
|
+
formatDate,
|
|
452
|
+
formatVolume,
|
|
453
|
+
} from 'fmp-node-api';
|
|
454
|
+
|
|
455
|
+
// Format financial data
|
|
456
|
+
const formattedPrice = formatCurrency(150.25); // "$150.25"
|
|
457
|
+
const formattedChange = formatPercentage(1.45); // "1.45%"
|
|
458
|
+
const formattedMarketCap = formatLargeNumber(2500000000); // "2.50B"
|
|
459
|
+
const formattedVolume = formatVolume(1500000); // "1.50M"
|
|
460
|
+
const formattedDate = formatDate('2024-01-15'); // "2024-01-15"
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
## Advanced Usage
|
|
464
|
+
|
|
465
|
+
### Custom Client Configuration
|
|
466
|
+
|
|
467
|
+
```typescript
|
|
468
|
+
import { FMPClient } from 'fmp-node-api';
|
|
469
|
+
|
|
470
|
+
// Using environment variable
|
|
471
|
+
const client = new FMPClient({
|
|
472
|
+
timeout: 15000, // optional, apiKey from FMP_API_KEY env var
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// Or with explicit API key
|
|
476
|
+
const client = new FMPClient({
|
|
477
|
+
apiKey: 'your-api-key',
|
|
478
|
+
timeout: 15000, // optional
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// Use individual endpoint classes
|
|
482
|
+
const stockEndpoints = new StockEndpoints(client);
|
|
483
|
+
const marketCap = await stockEndpoints.getMarketCap('AAPL');
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### Direct API Calls
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
const client = fmp.getClient();
|
|
490
|
+
const response = await client.get('/quote/AAPL');
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
## Testing
|
|
494
|
+
|
|
495
|
+
The library includes a comprehensive test suite with extensive coverage across all endpoints, types, and utilities:
|
|
496
|
+
|
|
497
|
+
### Available Test Scripts
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
# Run all tests
|
|
501
|
+
pnpm test
|
|
502
|
+
|
|
503
|
+
# Run specific test categories
|
|
504
|
+
pnpm test:unit # Unit tests (client, main FMP class)
|
|
505
|
+
pnpm test:endpoints # All endpoint tests (mocked)
|
|
506
|
+
pnpm test:stock # Stock endpoint tests only
|
|
507
|
+
pnpm test:financial # Financial endpoint tests only
|
|
508
|
+
pnpm test:market # Market endpoint tests only
|
|
509
|
+
pnpm test:quote # Quote endpoint tests only
|
|
510
|
+
pnpm test:economic # Economic endpoint tests only
|
|
511
|
+
pnpm test:list # List endpoint tests only
|
|
512
|
+
pnpm test:calendar # Calendar endpoint tests only
|
|
513
|
+
pnpm test:company # Company endpoint tests only
|
|
514
|
+
|
|
515
|
+
# Manual testing with real API calls
|
|
516
|
+
pnpm test:endpoint # Run a specific endpoint against the live API
|
|
517
|
+
|
|
518
|
+
# Development
|
|
519
|
+
pnpm test:watch # Watch mode for development
|
|
520
|
+
pnpm test:coverage # Generate coverage report
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
**Note**: Additional endpoint-specific test scripts (`test:etf`, `test:mutual-fund`, `test:senate-house`, `test:institutional`, `test:insider`, `test:sec`) are also available, both here and at the repo root.
|
|
524
|
+
|
|
525
|
+
### Live API shape check (`test:live`)
|
|
526
|
+
|
|
527
|
+
`test:live` validates real FMP responses against the canonical Zod schemas in `fmp-node-types` โ catching renamed/missing/changed fields and version-mismatch 404s, not just "did it respond". Unlike `test:endpoint` (which prints one endpoint's raw JSON), `test:live` runs many cases and prints a classified summary.
|
|
528
|
+
|
|
529
|
+
Run from the repo root (it builds `fmp-node-types` first so the runner uses fresh schemas):
|
|
530
|
+
|
|
531
|
+
```bash
|
|
532
|
+
pnpm test:live # all seeded cases
|
|
533
|
+
pnpm test:live --category quote,stock # only these categories
|
|
534
|
+
pnpm test:live --endpoint getQuote # cases whose name matches
|
|
535
|
+
pnpm test:live --dry-run # list cases, make NO API calls
|
|
536
|
+
pnpm test:live --category financial --max-calls 10
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Each result is classified:
|
|
540
|
+
|
|
541
|
+
- **PASS** โ response matches the schema
|
|
542
|
+
- **FAIL** โ an expected field is missing or has the wrong (non-null) type
|
|
543
|
+
- **SKIP** โ plan-locked (HTTP 402/403) or rate/quota limited (429)
|
|
544
|
+
- **DRIFT** โ extra top-level fields, or a non-nullable field came back `null`
|
|
545
|
+
|
|
546
|
+
Flags: `--delay <ms>` (default 400) paces calls; `--max-calls <n>` (default 50) caps live calls; `--include-locked` also runs cases marked `planLocked`; `--fail-on-drift` makes DRIFT fail the exit code. The runner is sequential and throttled to stay within limited API plans โ the first full run doubles as a calibration pass: mark any consistently plan-locked endpoints `planLocked: true` in `scripts/live/manifest.ts` so later default runs skip them. Exits non-zero when any case FAILs.
|
|
547
|
+
|
|
548
|
+
> Coverage note: the seeded manifest currently covers the `quote`, `stock`, `financial`, and `market` categories. The classifier logic is unit-tested in `src/__tests__/live/validate.test.ts` (no API key needed).
|
|
549
|
+
|
|
550
|
+
## Development
|
|
551
|
+
|
|
552
|
+
### Prerequisites
|
|
553
|
+
|
|
554
|
+
- Node.js 18+
|
|
555
|
+
- pnpm (recommended) or npm
|
|
556
|
+
- FMP API key
|
|
557
|
+
|
|
558
|
+
### Setup
|
|
559
|
+
|
|
560
|
+
```bash
|
|
561
|
+
# Clone the repository
|
|
562
|
+
git clone <repository-url>
|
|
563
|
+
cd fmp-node-wrapper
|
|
564
|
+
|
|
565
|
+
# Install dependencies
|
|
566
|
+
pnpm install
|
|
567
|
+
|
|
568
|
+
# Set up environment variables
|
|
569
|
+
cp .env.example .env
|
|
570
|
+
# Add your FMP_API_KEY to .env
|
|
571
|
+
|
|
572
|
+
# Build the package
|
|
573
|
+
pnpm build
|
|
574
|
+
|
|
575
|
+
# Run tests
|
|
576
|
+
pnpm test
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### Available Scripts
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
# Build
|
|
583
|
+
pnpm build # Build the package
|
|
584
|
+
pnpm dev # Watch mode for development
|
|
585
|
+
|
|
586
|
+
# Testing
|
|
587
|
+
pnpm test # Run all tests (mocked, deterministic)
|
|
588
|
+
pnpm test:watch # Watch mode
|
|
589
|
+
pnpm test:coverage # Coverage report
|
|
590
|
+
pnpm test:live # Validate response shapes against the live API
|
|
591
|
+
pnpm test:endpoint # Inspect one endpoint's raw response (live)
|
|
592
|
+
pnpm test:unit # Run unit tests
|
|
593
|
+
pnpm test:endpoints # Run all endpoint tests
|
|
594
|
+
pnpm test:stock # Run stock endpoint tests
|
|
595
|
+
pnpm test:financial # Run financial endpoint tests
|
|
596
|
+
pnpm test:market # Run market endpoint tests
|
|
597
|
+
pnpm test:quote # Run quote endpoint tests
|
|
598
|
+
pnpm test:economic # Run economic endpoint tests
|
|
599
|
+
pnpm test:list # Run list endpoint tests
|
|
600
|
+
pnpm test:calendar # Run calendar endpoint tests
|
|
601
|
+
pnpm test:company # Run company endpoint tests
|
|
602
|
+
|
|
603
|
+
# Code Quality
|
|
604
|
+
pnpm lint # Run ESLint
|
|
605
|
+
pnpm lint:fix # Fix linting issues
|
|
606
|
+
pnpm format # Format code with Prettier
|
|
607
|
+
pnpm format:check # Check code formatting
|
|
608
|
+
pnpm type-check # TypeScript type checking
|
|
609
|
+
|
|
610
|
+
# Utilities
|
|
611
|
+
pnpm clean # Clean build artifacts
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
## File Structure
|
|
615
|
+
|
|
616
|
+
```
|
|
617
|
+
src/
|
|
618
|
+
โโโ client.ts # Base HTTP client (v3/v4/stable axios instances)
|
|
619
|
+
โโโ fmp.ts # Main FMP class (wires up all endpoint classes)
|
|
620
|
+
โโโ index.ts # Main exports
|
|
621
|
+
โโโ types-only.ts # Types-only entry point (fmp-node-api/types)
|
|
622
|
+
โโโ shared.ts # Shared error types
|
|
623
|
+
โโโ endpoints/ # API endpoint classes (one per category)
|
|
624
|
+
โ โโโ quote.ts
|
|
625
|
+
โ โโโ stock.ts
|
|
626
|
+
โ โโโ financial.ts
|
|
627
|
+
โ โโโ company.ts
|
|
628
|
+
โ โโโ etf.ts
|
|
629
|
+
โ โโโ mutual-fund.ts
|
|
630
|
+
โ โโโ economic.ts
|
|
631
|
+
โ โโโ market.ts
|
|
632
|
+
โ โโโ list.ts
|
|
633
|
+
โ โโโ screener.ts
|
|
634
|
+
โ โโโ calendar.ts
|
|
635
|
+
โ โโโ senate-house.ts
|
|
636
|
+
โ โโโ institutional.ts
|
|
637
|
+
โ โโโ insider.ts
|
|
638
|
+
โ โโโ sec.ts
|
|
639
|
+
โ โโโ news.ts
|
|
640
|
+
โโโ utils/ # Utility functions
|
|
641
|
+
โ โโโ validation.ts # Input validation
|
|
642
|
+
โ โโโ formatting.ts # Data formatting
|
|
643
|
+
โ โโโ constants.ts # API constants
|
|
644
|
+
โ โโโ helpers.ts # Shared helpers
|
|
645
|
+
โ โโโ debug.ts # Debug logging
|
|
646
|
+
โ โโโ utils.ts # Misc utilities
|
|
647
|
+
โโโ live/ # Live-check classifier (dev-only; not exported/shipped)
|
|
648
|
+
โ โโโ validate.ts # Relaxed validator / classifier (PASS/FAIL/SKIP/DRIFT)
|
|
649
|
+
โโโ __tests__/ # Jest tests (client, fmp, integration, endpoints/, utils/, live/)
|
|
650
|
+
|
|
651
|
+
scripts/
|
|
652
|
+
โโโ test-endpoint.ts # Manual live-API endpoint inspector (raw JSON, one endpoint)
|
|
653
|
+
โโโ live/ # Live-API shape-check tool (pnpm test:live)
|
|
654
|
+
โโโ run.ts # CLI runner (flags, throttle, budget, summary)
|
|
655
|
+
โโโ manifest.ts # Data-driven registry of cases (endpoint + inputs + schema)
|
|
656
|
+
โโโ tsconfig.json # Type-checks the runner (pnpm type-check:live)
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
## Contributing
|
|
660
|
+
|
|
661
|
+
We welcome contributions! This is a community-driven project, and your help is greatly appreciated.
|
|
662
|
+
|
|
663
|
+
### Quick Start
|
|
664
|
+
|
|
665
|
+
1. **Fork the repository**
|
|
666
|
+
2. **Create a feature branch**: `git checkout -b feature/your-feature-name`
|
|
667
|
+
3. **Make your changes** following our development guidelines
|
|
668
|
+
4. **Run quality checks**: `pnpm lint && pnpm test && pnpm type-check`
|
|
669
|
+
5. **Open a Pull Request** with a clear description of your changes
|
|
670
|
+
|
|
671
|
+
### Development Setup
|
|
672
|
+
|
|
673
|
+
```bash
|
|
674
|
+
# Install dependencies
|
|
675
|
+
pnpm install
|
|
676
|
+
|
|
677
|
+
# Set up environment
|
|
678
|
+
cp .env.example .env
|
|
679
|
+
# Add your FMP_API_KEY to .env
|
|
680
|
+
|
|
681
|
+
# Build and test
|
|
682
|
+
pnpm build
|
|
683
|
+
pnpm test
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
### Getting Help
|
|
687
|
+
|
|
688
|
+
- **๐ [Contributing Guide](https://github.com/e-roy/fmp-node-wrapper/blob/main/CONTRIBUTING.md)**: Detailed guidelines and development setup
|
|
689
|
+
- **๐ [Issues](https://github.com/e-roy/fmp-node-wrapper/issues)**: Report bugs or request features
|
|
690
|
+
- **๐ [Documentation](https://fmp-node-wrapper-docs.vercel.app)**: Check the docs first
|
|
691
|
+
|
|
692
|
+
### Before Contributing
|
|
693
|
+
|
|
694
|
+
- [ ] Read the [Contributing Guide](https://github.com/e-roy/fmp-node-wrapper/blob/main/CONTRIBUTING.md)
|
|
695
|
+
- [ ] Check existing issues to avoid duplicates
|
|
696
|
+
- [ ] Test with the latest version of the library
|
|
697
|
+
- [ ] Follow our coding standards and testing requirements
|
|
698
|
+
|
|
699
|
+
## Issues and Support
|
|
700
|
+
|
|
701
|
+
### Reporting Issues
|
|
702
|
+
|
|
703
|
+
Before creating an issue, please:
|
|
704
|
+
|
|
705
|
+
1. **Check existing issues** to avoid duplicates
|
|
706
|
+
2. **Search the documentation** for solutions
|
|
707
|
+
3. **Test with the latest version** of the library
|
|
708
|
+
4. **Provide a minimal reproduction** of the problem
|
|
709
|
+
|
|
710
|
+
### Issue Guidelines
|
|
711
|
+
|
|
712
|
+
- **Be specific**: Provide clear, actionable information
|
|
713
|
+
- **Include examples**: Code examples help reproduce issues
|
|
714
|
+
- **Check versions**: Mention Node.js and library versions
|
|
715
|
+
- **Separate concerns**: Don't mix multiple issues in one report
|
|
716
|
+
|
|
717
|
+
### Support Channels
|
|
718
|
+
|
|
719
|
+
- **๐ [GitHub Issues](https://github.com/e-roy/fmp-node-wrapper/issues)**: For bug reports and feature requests
|
|
720
|
+
- **๐ง [FMP Official Support](https://site.financialmodelingprep.com/developer/docs/stable)**: For issues with the underlying FMP API service
|
|
721
|
+
|
|
722
|
+
## License
|
|
723
|
+
|
|
724
|
+
MIT License - see LICENSE file for details.
|
|
725
|
+
|
|
726
|
+
## Support
|
|
727
|
+
|
|
728
|
+
For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/e-roy/fmp-node-wrapper).
|
|
729
|
+
|
|
730
|
+
## Disclaimer
|
|
731
|
+
|
|
732
|
+
**This package is not affiliated with, endorsed by, or sponsored by Financial Modeling Prep (FMP).** This is an independent, community-developed Node.js wrapper for the FMP API.
|
|
733
|
+
|
|
734
|
+
### Important Legal Information
|
|
735
|
+
|
|
736
|
+
- **No Affiliation**: This library is developed independently and is not officially associated with Financial Modeling Prep
|
|
737
|
+
- **No Warranty**: This software is provided "as is" without any warranties, express or implied
|
|
738
|
+
- **User Responsibility**: Users are responsible for:
|
|
739
|
+
- Complying with FMP's terms of service and API usage limits
|
|
740
|
+
- Obtaining and maintaining valid API keys from Financial Modeling Prep
|
|
741
|
+
- Ensuring their usage complies with applicable laws and regulations
|
|
742
|
+
- **Limitation of Liability**: The developers of this wrapper are not responsible for:
|
|
743
|
+
- Any issues with the underlying FMP API service
|
|
744
|
+
- Data accuracy or availability from the FMP API
|
|
745
|
+
- Any financial losses or damages resulting from the use of this library
|
|
746
|
+
- API rate limiting, downtime, or service interruptions
|
|
747
|
+
- **Official Support**: For official support, documentation, or API issues, please contact Financial Modeling Prep directly at their official channels
|