fmp-node-api 0.0.7 → 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/README.md +155 -51
- package/dist/index.d.mts +3291 -662
- package/dist/index.d.ts +3291 -662
- package/dist/index.js +3532 -681
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3525 -674
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -14,29 +14,36 @@ function normalizeArrayResponse(data) {
|
|
|
14
14
|
}
|
|
15
15
|
function normalizeObjectResponse(data) {
|
|
16
16
|
if (data == null) return {};
|
|
17
|
+
if (Array.isArray(data) && data.length === 0) return {};
|
|
17
18
|
return data;
|
|
18
19
|
}
|
|
19
20
|
var FMPClient = class {
|
|
20
21
|
constructor(config) {
|
|
22
|
+
if (!config.apiKey) {
|
|
23
|
+
throw new Error("API key is required for FMPClient");
|
|
24
|
+
}
|
|
21
25
|
this.apiKey = config.apiKey;
|
|
22
|
-
this.v3Client =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
this.v3Client = axios.create({
|
|
27
|
+
baseURL: "https://financialmodelingprep.com/api/v3",
|
|
28
|
+
timeout: config.timeout || 1e4,
|
|
29
|
+
headers: { "Content-Type": "application/json" }
|
|
30
|
+
});
|
|
31
|
+
this.v4Client = axios.create({
|
|
32
|
+
baseURL: "https://financialmodelingprep.com/api/v4",
|
|
33
|
+
timeout: config.timeout || 1e4,
|
|
34
|
+
headers: { "Content-Type": "application/json" }
|
|
35
|
+
});
|
|
36
|
+
this.stableClient = axios.create({
|
|
37
|
+
baseURL: "https://financialmodelingprep.com/stable",
|
|
38
|
+
timeout: config.timeout || 1e4,
|
|
33
39
|
headers: { "Content-Type": "application/json" }
|
|
34
40
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
[this.v3Client, this.v4Client, this.stableClient].forEach((client) => {
|
|
42
|
+
client.interceptors.request.use((config2) => {
|
|
43
|
+
config2.params = { ...config2.params, apikey: this.apiKey };
|
|
44
|
+
return config2;
|
|
45
|
+
});
|
|
38
46
|
});
|
|
39
|
-
return client;
|
|
40
47
|
}
|
|
41
48
|
/**
|
|
42
49
|
* Standard get method - returns raw API response
|
|
@@ -55,11 +62,13 @@ var FMPClient = class {
|
|
|
55
62
|
return {
|
|
56
63
|
success: true,
|
|
57
64
|
data,
|
|
65
|
+
error: null,
|
|
58
66
|
status: response.status
|
|
59
67
|
};
|
|
60
68
|
} catch (error) {
|
|
61
69
|
return {
|
|
62
70
|
success: false,
|
|
71
|
+
data: null,
|
|
63
72
|
error: error.message || "Unknown error occurred",
|
|
64
73
|
status: error.response?.status || 500
|
|
65
74
|
};
|
|
@@ -78,11 +87,13 @@ var FMPClient = class {
|
|
|
78
87
|
return {
|
|
79
88
|
success: true,
|
|
80
89
|
data,
|
|
90
|
+
error: null,
|
|
81
91
|
status: response.status
|
|
82
92
|
};
|
|
83
93
|
} catch (error) {
|
|
84
94
|
return {
|
|
85
95
|
success: false,
|
|
96
|
+
data: null,
|
|
86
97
|
error: error.message || "Unknown error occurred",
|
|
87
98
|
status: error.response?.status || 500
|
|
88
99
|
};
|
|
@@ -102,137 +113,310 @@ var FMPClient = class {
|
|
|
102
113
|
}
|
|
103
114
|
};
|
|
104
115
|
|
|
105
|
-
// src/shared.ts
|
|
106
|
-
var FMPError = class extends Error {
|
|
107
|
-
constructor(message, status, code) {
|
|
108
|
-
super(message);
|
|
109
|
-
this.status = status;
|
|
110
|
-
this.code = code;
|
|
111
|
-
this.name = "FMPError";
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
116
|
// src/utils/validation.ts
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
var FMPValidation = class {
|
|
118
|
+
/**
|
|
119
|
+
* Validate stock symbol format
|
|
120
|
+
* @param symbol - The symbol to validate
|
|
121
|
+
* @returns True if the symbol format is valid
|
|
122
|
+
*/
|
|
123
|
+
static isValidSymbol(symbol) {
|
|
124
|
+
if (!symbol || typeof symbol !== "string") {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return /^[A-Z]{1,5}$/.test(symbol);
|
|
119
128
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
);
|
|
129
|
+
/**
|
|
130
|
+
* Validate crypto symbol format
|
|
131
|
+
* @param symbol - The crypto symbol to validate
|
|
132
|
+
* @returns True if the crypto symbol format is valid
|
|
133
|
+
*/
|
|
134
|
+
static isValidCryptoSymbol(symbol) {
|
|
135
|
+
if (!symbol || typeof symbol !== "string") {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
return /^[A-Z]{2,10}(USD|EUR|GBP|JPY|CAD|AUD|CHF|CNY)$/.test(symbol);
|
|
130
139
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Validate forex pair format
|
|
142
|
+
* @param symbol - The forex pair to validate
|
|
143
|
+
* @returns True if the forex pair format is valid
|
|
144
|
+
*/
|
|
145
|
+
static isValidForexPair(symbol) {
|
|
146
|
+
if (!symbol || typeof symbol !== "string") {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return /^[A-Z]{3}[A-Z]{3}$/.test(symbol);
|
|
135
150
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Validate date format (YYYY-MM-DD)
|
|
153
|
+
* @param date - The date string to validate
|
|
154
|
+
* @returns True if the date format is valid
|
|
155
|
+
*/
|
|
156
|
+
static isValidDate(date) {
|
|
157
|
+
if (!date || typeof date !== "string") {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
161
|
+
if (!dateRegex.test(date)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
const dateObj = new Date(date);
|
|
165
|
+
return !isNaN(dateObj.getTime()) && dateObj.toISOString().split("T")[0] === date;
|
|
139
166
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Validate date range
|
|
169
|
+
* @param from - Start date
|
|
170
|
+
* @param to - End date
|
|
171
|
+
* @returns True if the date range is valid
|
|
172
|
+
*/
|
|
173
|
+
static isValidDateRange(from, to) {
|
|
174
|
+
if (!this.isValidDate(from) || !this.isValidDate(to)) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
const fromDate = new Date(from);
|
|
178
|
+
const toDate = new Date(to);
|
|
179
|
+
return fromDate <= toDate;
|
|
143
180
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Validate API response structure
|
|
183
|
+
* @param response - The response to validate
|
|
184
|
+
* @returns True if the response has the expected structure
|
|
185
|
+
*/
|
|
186
|
+
static isValidResponse(response) {
|
|
187
|
+
return Boolean(
|
|
188
|
+
response && typeof response === "object" && typeof response.success === "boolean"
|
|
189
|
+
);
|
|
148
190
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Validate API key format
|
|
193
|
+
* @param apiKey - The API key to validate
|
|
194
|
+
* @returns True if the API key format is valid
|
|
195
|
+
*/
|
|
196
|
+
static isValidApiKey(apiKey) {
|
|
197
|
+
if (!apiKey || typeof apiKey !== "string") {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
return /^[a-zA-Z0-9]{32,}$/.test(apiKey);
|
|
153
201
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Validate period parameter
|
|
204
|
+
* @param period - The period to validate
|
|
205
|
+
* @returns True if the period is valid
|
|
206
|
+
*/
|
|
207
|
+
static isValidPeriod(period) {
|
|
208
|
+
if (!period || typeof period !== "string") {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
return ["annual", "quarter", "fy"].includes(period.toLowerCase());
|
|
158
212
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Validate limit parameter
|
|
215
|
+
* @param limit - The limit to validate
|
|
216
|
+
* @returns True if the limit is valid
|
|
217
|
+
*/
|
|
218
|
+
static isValidLimit(limit) {
|
|
219
|
+
return typeof limit === "number" && Number.isInteger(limit) && limit > 0 && limit <= 1e3;
|
|
165
220
|
}
|
|
166
221
|
/**
|
|
167
|
-
* Get
|
|
168
|
-
* @
|
|
169
|
-
* @
|
|
170
|
-
* @returns This endpoint gives you the latest bid and ask prices for a stock, as well as the volume and last trade price in real time.
|
|
222
|
+
* Get validation errors for quote parameters
|
|
223
|
+
* @param params - The parameters to validate
|
|
224
|
+
* @returns Array of validation error messages
|
|
171
225
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
226
|
+
static validateQuoteParams(params) {
|
|
227
|
+
const errors = [];
|
|
228
|
+
if (!params) {
|
|
229
|
+
errors.push("Parameters object is required");
|
|
230
|
+
return errors;
|
|
231
|
+
}
|
|
232
|
+
if (!params.symbol) {
|
|
233
|
+
errors.push("Symbol is required");
|
|
234
|
+
} else if (!this.isValidSymbol(params.symbol) && !this.isValidCryptoSymbol(params.symbol) && !this.isValidForexPair(params.symbol)) {
|
|
235
|
+
errors.push("Invalid symbol format");
|
|
236
|
+
}
|
|
237
|
+
if (params.from && !this.isValidDate(params.from)) {
|
|
238
|
+
errors.push("Invalid from date format (expected YYYY-MM-DD)");
|
|
239
|
+
}
|
|
240
|
+
if (params.to && !this.isValidDate(params.to)) {
|
|
241
|
+
errors.push("Invalid to date format (expected YYYY-MM-DD)");
|
|
242
|
+
}
|
|
243
|
+
if (params.from && params.to && !this.isValidDateRange(params.from, params.to)) {
|
|
244
|
+
errors.push("From date must be before or equal to to date");
|
|
245
|
+
}
|
|
246
|
+
return errors;
|
|
177
247
|
}
|
|
178
248
|
/**
|
|
179
|
-
* Get
|
|
180
|
-
* @
|
|
181
|
-
* @
|
|
182
|
-
* @param from - The start date to get the historical prices for
|
|
183
|
-
* @param to - The end date to get the historical prices for
|
|
184
|
-
* @returns The FMP Daily Chart endpoint provides daily stock data for a specified company, including opening, high, low, and closing prices, with a default limit of 5 years of historical data. To access data beyond this limit, use the from and to parameters for custom date ranges, each with a 5-year limit
|
|
249
|
+
* Get validation errors for financial statement parameters
|
|
250
|
+
* @param params - The parameters to validate
|
|
251
|
+
* @returns Array of validation error messages
|
|
185
252
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
253
|
+
static validateFinancialParams(params) {
|
|
254
|
+
const errors = [];
|
|
255
|
+
if (!params) {
|
|
256
|
+
errors.push("Parameters object is required");
|
|
257
|
+
return errors;
|
|
258
|
+
}
|
|
259
|
+
if (!params.symbol) {
|
|
260
|
+
errors.push("Symbol is required");
|
|
261
|
+
} else if (!this.isValidSymbol(params.symbol)) {
|
|
262
|
+
errors.push("Invalid symbol format");
|
|
263
|
+
}
|
|
264
|
+
if (params.period && !this.isValidPeriod(params.period)) {
|
|
265
|
+
errors.push('Invalid period (must be "annual", "quarter", or "FY")');
|
|
266
|
+
}
|
|
267
|
+
if (params.limit && !this.isValidLimit(params.limit)) {
|
|
268
|
+
errors.push("Invalid limit (must be a positive integer <= 1000)");
|
|
269
|
+
}
|
|
270
|
+
return errors;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Get validation errors for date range parameters
|
|
274
|
+
* @param params - The parameters to validate
|
|
275
|
+
* @returns Array of validation error messages
|
|
276
|
+
*/
|
|
277
|
+
static validateDateRangeParams(params) {
|
|
278
|
+
const errors = [];
|
|
279
|
+
if (!params) {
|
|
280
|
+
errors.push("Parameters object is required");
|
|
281
|
+
return errors;
|
|
282
|
+
}
|
|
283
|
+
if (params.from && !this.isValidDate(params.from)) {
|
|
284
|
+
errors.push("Invalid from date format (expected YYYY-MM-DD)");
|
|
285
|
+
}
|
|
286
|
+
if (params.to && !this.isValidDate(params.to)) {
|
|
287
|
+
errors.push("Invalid to date format (expected YYYY-MM-DD)");
|
|
288
|
+
}
|
|
289
|
+
if (params.from && params.to && !this.isValidDateRange(params.from, params.to)) {
|
|
290
|
+
errors.push("From date must be before or equal to to date");
|
|
291
|
+
}
|
|
292
|
+
return errors;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Validate and throw error if validation fails
|
|
296
|
+
* @param errors - Array of validation errors
|
|
297
|
+
* @param context - Context for the error message
|
|
298
|
+
*/
|
|
299
|
+
static throwIfInvalid(errors, context = "Validation") {
|
|
300
|
+
if (errors.length > 0) {
|
|
301
|
+
throw new Error(`${context} failed: ${errors.join(", ")}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// src/endpoints/stock.ts
|
|
307
|
+
var StockEndpoints = class {
|
|
308
|
+
constructor(client) {
|
|
309
|
+
this.client = client;
|
|
198
310
|
}
|
|
199
311
|
/**
|
|
200
|
-
* Get market
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
312
|
+
* Get current market capitalization for a stock
|
|
313
|
+
*
|
|
314
|
+
* Market capitalization represents the total value of a company's outstanding shares.
|
|
315
|
+
* Calculated by multiplying the current share price by the number of outstanding shares.
|
|
316
|
+
* This metric is crucial for understanding a company's size and market position.
|
|
317
|
+
*
|
|
318
|
+
* @param symbol - The stock symbol to get market cap for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
319
|
+
*
|
|
320
|
+
* @returns Promise resolving to market cap data including symbol, date, and market cap value
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* // Get market cap for Apple
|
|
325
|
+
* const marketCap = await fmp.stock.getMarketCap('AAPL');
|
|
326
|
+
* console.log(`Apple's market cap: $${marketCap.data.marketCap.toLocaleString()}`);
|
|
327
|
+
*
|
|
328
|
+
* // Get market cap for Microsoft
|
|
329
|
+
* const msftCap = await fmp.stock.getMarketCap('MSFT');
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#market-cap-company-information|FMP Market Cap Documentation}
|
|
204
333
|
*/
|
|
205
|
-
async getMarketCap(
|
|
334
|
+
async getMarketCap(symbol) {
|
|
206
335
|
return this.client.getSingle(`/market-capitalization/${symbol}`, "v3");
|
|
207
336
|
}
|
|
208
337
|
/**
|
|
209
|
-
* Get stock splits
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
338
|
+
* Get historical stock splits for a company
|
|
339
|
+
*
|
|
340
|
+
* Stock splits occur when a company increases the number of shares by dividing existing shares.
|
|
341
|
+
* This endpoint provides the complete history of stock splits including dates, ratios, and split types.
|
|
342
|
+
* Useful for adjusting historical price data and understanding corporate actions.
|
|
343
|
+
*
|
|
344
|
+
* @param symbol - The stock symbol to get split history for (e.g., 'AAPL', 'TSLA', 'NVDA')
|
|
345
|
+
*
|
|
346
|
+
* @returns Promise resolving to historical stock splits with dates, labels, and split ratios
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* // Get Apple's split history
|
|
351
|
+
* const splits = await fmp.stock.getStockSplits('AAPL');
|
|
352
|
+
* splits.data.historical.forEach(split => {
|
|
353
|
+
* console.log(`${split.date}: ${split.numerator}:${split.denominator} split`);
|
|
354
|
+
* });
|
|
355
|
+
*
|
|
356
|
+
* // Get Tesla's split history
|
|
357
|
+
* const teslaSplits = await fmp.stock.getStockSplits('TSLA');
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#splits-historical-splits|FMP Stock Splits Documentation}
|
|
213
361
|
*/
|
|
214
|
-
async getStockSplits(
|
|
362
|
+
async getStockSplits(symbol) {
|
|
215
363
|
return this.client.get(`/historical-price-full/stock_split/${symbol}`, "v3");
|
|
216
364
|
}
|
|
217
365
|
/**
|
|
218
|
-
* Get dividend
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
366
|
+
* Get historical dividend payments for a stock
|
|
367
|
+
*
|
|
368
|
+
* Dividends are periodic payments made by companies to shareholders from profits.
|
|
369
|
+
* This endpoint provides the complete dividend history including payment dates, amounts,
|
|
370
|
+
* and important dates like ex-dividend, record, and declaration dates.
|
|
371
|
+
*
|
|
372
|
+
* @param symbol - The stock symbol to get dividend history for (e.g., 'KO', 'JNJ', 'PG')
|
|
373
|
+
*
|
|
374
|
+
* @returns Promise resolving to dividend history with payment details and important dates
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* // Get Coca-Cola's dividend history
|
|
379
|
+
* const dividends = await fmp.stock.getDividendHistory('KO');
|
|
380
|
+
* dividends.data.historical.forEach(dividend => {
|
|
381
|
+
* console.log(`${dividend.date}: $${dividend.dividend} per share`);
|
|
382
|
+
* });
|
|
383
|
+
*
|
|
384
|
+
* // Get Johnson & Johnson's dividend history
|
|
385
|
+
* const jnjDividends = await fmp.stock.getDividendHistory('JNJ');
|
|
386
|
+
* ```
|
|
387
|
+
*
|
|
388
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#dividends-historical-dividends|FMP Dividends Documentation}
|
|
222
389
|
*/
|
|
223
|
-
async getDividendHistory({
|
|
224
|
-
symbol
|
|
225
|
-
}) {
|
|
390
|
+
async getDividendHistory(symbol) {
|
|
226
391
|
return this.client.getSingle(`/historical-price-full/stock_dividend/${symbol}`, "v3");
|
|
227
392
|
}
|
|
228
393
|
/**
|
|
229
|
-
* Get stock
|
|
230
|
-
*
|
|
231
|
-
*
|
|
394
|
+
* Get real-time stock prices for multiple symbols
|
|
395
|
+
*
|
|
396
|
+
* Provides current market prices for stocks with minimal data overhead.
|
|
397
|
+
* Returns basic price information including symbol and current price.
|
|
398
|
+
* Ideal for quick price checks and portfolio monitoring.
|
|
399
|
+
*
|
|
400
|
+
* @param symbols - Array of stock symbols to get real-time prices for
|
|
401
|
+
*
|
|
402
|
+
* @returns Promise resolving to array of real-time price data with symbol and price
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```typescript
|
|
406
|
+
* // Get prices for multiple tech stocks
|
|
407
|
+
* const prices = await fmp.stock.getRealTimePrice([
|
|
408
|
+
* 'AAPL', 'MSFT', 'GOOGL', 'AMZN', 'TSLA'
|
|
409
|
+
* ]);
|
|
410
|
+
*
|
|
411
|
+
* prices.data.forEach(stock => {
|
|
412
|
+
* console.log(`${stock.symbol}: $${stock.price}`);
|
|
413
|
+
* });
|
|
414
|
+
*
|
|
415
|
+
* // Get price for single stock
|
|
416
|
+
* const aaplPrice = await fmp.stock.getRealTimePrice(['AAPL']);
|
|
417
|
+
* ```
|
|
232
418
|
*/
|
|
233
|
-
async getRealTimePrice({
|
|
234
|
-
symbols
|
|
235
|
-
}) {
|
|
419
|
+
async getRealTimePrice(symbols) {
|
|
236
420
|
const url = `stock/real-time-price/${symbols.join(",")}`;
|
|
237
421
|
const result = await this.client.get(url, "v3");
|
|
238
422
|
if (result.success && result.data && !Array.isArray(result.data)) {
|
|
@@ -261,14 +445,38 @@ var StockEndpoints = class {
|
|
|
261
445
|
return { ...result, data: filteredData };
|
|
262
446
|
}
|
|
263
447
|
/**
|
|
264
|
-
* Get
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
448
|
+
* Get comprehensive real-time stock data for multiple symbols
|
|
449
|
+
*
|
|
450
|
+
* Provides detailed real-time market data including bid/ask prices, volume, trade sizes,
|
|
451
|
+
* and timestamps. This endpoint offers much more information than the basic real-time price.
|
|
452
|
+
* Perfect for trading applications, market analysis, and detailed price monitoring.
|
|
453
|
+
*
|
|
454
|
+
* @param symbols - Array of stock symbols to get detailed real-time data for
|
|
455
|
+
*
|
|
456
|
+
* @returns Promise resolving to array of detailed real-time data including bid/ask, volume, and timestamps
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```typescript
|
|
460
|
+
* // Get detailed data for multiple stocks
|
|
461
|
+
* const detailedData = await fmp.stock.getRealTimePriceForMultipleStocks([
|
|
462
|
+
* 'AAPL', 'MSFT', 'GOOGL'
|
|
463
|
+
* ]);
|
|
464
|
+
*
|
|
465
|
+
* detailedData.data.forEach(stock => {
|
|
466
|
+
* console.log(`${stock.symbol}:`);
|
|
467
|
+
* console.log(` Bid: $${stock.bidPrice} (${stock.bidSize} shares)`);
|
|
468
|
+
* console.log(` Ask: $${stock.askPrice} (${stock.askSize} shares)`);
|
|
469
|
+
* console.log(` Last: $${stock.lastSalePrice} (${stock.lastSaleSize} shares)`);
|
|
470
|
+
* console.log(` Volume: ${stock.volume.toLocaleString()}`);
|
|
471
|
+
* });
|
|
472
|
+
*
|
|
473
|
+
* // Get detailed data for single stock
|
|
474
|
+
* const aaplDetailed = await fmp.stock.getRealTimePriceForMultipleStocks(['AAPL']);
|
|
475
|
+
* ```
|
|
476
|
+
*
|
|
477
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#real-time-full-price-quote|FMP Real-Time Full Price Documentation}
|
|
268
478
|
*/
|
|
269
|
-
async getRealTimePriceForMultipleStocks({
|
|
270
|
-
symbols
|
|
271
|
-
}) {
|
|
479
|
+
async getRealTimePriceForMultipleStocks(symbols) {
|
|
272
480
|
const url = `stock/full/real-time-price/${symbols.join(",")}`;
|
|
273
481
|
const result = await this.client.get(url, "v3");
|
|
274
482
|
if (result.success && result.data && !Array.isArray(result.data)) {
|
|
@@ -306,391 +514,643 @@ var FinancialEndpoints = class {
|
|
|
306
514
|
this.client = client;
|
|
307
515
|
}
|
|
308
516
|
/**
|
|
309
|
-
* Get income statement
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
517
|
+
* Get income statement data
|
|
518
|
+
*
|
|
519
|
+
* Provides comprehensive income statement data including revenue, expenses,
|
|
520
|
+
* net income, and earnings per share. Essential for analyzing company
|
|
521
|
+
* profitability, revenue trends, and financial performance over time.
|
|
522
|
+
*
|
|
523
|
+
* @param params - Income statement request parameters
|
|
524
|
+
* @param params.symbol - The stock symbol to get income statement for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
525
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
526
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
527
|
+
*
|
|
528
|
+
* @returns Promise resolving to array of income statement data with financial metrics
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```typescript
|
|
532
|
+
* // Get annual income statements for Apple
|
|
533
|
+
* const incomeStatements = await fmp.financial.getIncomeStatement({ symbol: 'AAPL' });
|
|
534
|
+
* incomeStatements.data.forEach(statement => {
|
|
535
|
+
* console.log(`${statement.date}: Revenue $${statement.revenue.toLocaleString()}, Net Income $${statement.netIncome.toLocaleString()}`);
|
|
536
|
+
* });
|
|
537
|
+
*
|
|
538
|
+
* // Get quarterly income statements for Microsoft
|
|
539
|
+
* const quarterlyIncome = await fmp.financial.getIncomeStatement({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
540
|
+
* ```
|
|
541
|
+
*
|
|
542
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#income-statements-financial-statements|FMP Income Statement Documentation}
|
|
315
543
|
*/
|
|
316
|
-
async getIncomeStatement({
|
|
317
|
-
symbol,
|
|
318
|
-
period = "annual",
|
|
319
|
-
limit = 5
|
|
320
|
-
}) {
|
|
544
|
+
async getIncomeStatement(params) {
|
|
545
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
321
546
|
return this.client.get(`/income-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
322
547
|
}
|
|
323
548
|
/**
|
|
324
|
-
* Get balance sheet
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
549
|
+
* Get balance sheet data
|
|
550
|
+
*
|
|
551
|
+
* Provides comprehensive balance sheet data including assets, liabilities,
|
|
552
|
+
* and shareholder equity. Essential for analyzing company financial position,
|
|
553
|
+
* liquidity, and capital structure.
|
|
554
|
+
*
|
|
555
|
+
* @param params - Balance sheet request parameters
|
|
556
|
+
* @param params.symbol - The stock symbol to get balance sheet for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
557
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
558
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
559
|
+
*
|
|
560
|
+
* @returns Promise resolving to array of balance sheet data with financial position metrics
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```typescript
|
|
564
|
+
* // Get annual balance sheets for Apple
|
|
565
|
+
* const balanceSheets = await fmp.financial.getBalanceSheet({ symbol: 'AAPL' });
|
|
566
|
+
* balanceSheets.data.forEach(sheet => {
|
|
567
|
+
* console.log(`${sheet.date}: Assets $${sheet.totalAssets.toLocaleString()}, Equity $${sheet.totalStockholdersEquity.toLocaleString()}`);
|
|
568
|
+
* });
|
|
569
|
+
*
|
|
570
|
+
* // Get quarterly balance sheets for Microsoft
|
|
571
|
+
* const quarterlyBalance = await fmp.financial.getBalanceSheet({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
572
|
+
* ```
|
|
573
|
+
*
|
|
574
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#balance-sheet-statements-financial-statements|FMP Balance Sheet Documentation}
|
|
330
575
|
*/
|
|
331
|
-
async getBalanceSheet({
|
|
332
|
-
symbol,
|
|
333
|
-
period = "annual",
|
|
334
|
-
limit = 5
|
|
335
|
-
}) {
|
|
576
|
+
async getBalanceSheet(params) {
|
|
577
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
336
578
|
return this.client.get(
|
|
337
579
|
`/balance-sheet-statement/${symbol}?period=${period}&limit=${limit}`,
|
|
338
580
|
"v3"
|
|
339
581
|
);
|
|
340
582
|
}
|
|
341
583
|
/**
|
|
342
|
-
* Get cash flow statement
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
584
|
+
* Get cash flow statement data
|
|
585
|
+
*
|
|
586
|
+
* Provides comprehensive cash flow data including operating, investing,
|
|
587
|
+
* and financing cash flows. Essential for analyzing company cash generation,
|
|
588
|
+
* capital allocation, and financial sustainability.
|
|
589
|
+
*
|
|
590
|
+
* @param params - Cash flow statement request parameters
|
|
591
|
+
* @param params.symbol - The stock symbol to get cash flow statement for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
592
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
593
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
594
|
+
*
|
|
595
|
+
* @returns Promise resolving to array of cash flow statement data with cash flow metrics
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* ```typescript
|
|
599
|
+
* // Get annual cash flow statements for Apple
|
|
600
|
+
* const cashFlows = await fmp.financial.getCashFlowStatement({ symbol: 'AAPL' });
|
|
601
|
+
* cashFlows.data.forEach(flow => {
|
|
602
|
+
* console.log(`${flow.date}: Operating CF $${flow.operatingCashFlow.toLocaleString()}, Free CF $${flow.freeCashFlow.toLocaleString()}`);
|
|
603
|
+
* });
|
|
604
|
+
*
|
|
605
|
+
* // Get quarterly cash flow statements for Microsoft
|
|
606
|
+
* const quarterlyCashFlow = await fmp.financial.getCashFlowStatement({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
607
|
+
* ```
|
|
608
|
+
*
|
|
609
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#cashflow-statements-financial-statements|FMP Cash Flow Statement Documentation}
|
|
348
610
|
*/
|
|
349
|
-
async getCashFlowStatement({
|
|
350
|
-
symbol,
|
|
351
|
-
period = "annual",
|
|
352
|
-
limit = 5
|
|
353
|
-
}) {
|
|
611
|
+
async getCashFlowStatement(params) {
|
|
612
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
354
613
|
return this.client.get(`/cash-flow-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
355
614
|
}
|
|
356
615
|
/**
|
|
357
|
-
* Get key metrics
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
616
|
+
* Get key financial metrics
|
|
617
|
+
*
|
|
618
|
+
* Provides essential financial metrics including revenue, net income,
|
|
619
|
+
* P/E ratio, and other key performance indicators. Essential for
|
|
620
|
+
* fundamental analysis and company valuation.
|
|
621
|
+
*
|
|
622
|
+
* @param params - Key metrics request parameters
|
|
623
|
+
* @param params.symbol - The stock symbol to get key metrics for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
624
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
625
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
626
|
+
*
|
|
627
|
+
* @returns Promise resolving to array of key metrics data with financial indicators
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* ```typescript
|
|
631
|
+
* // Get key metrics for Apple
|
|
632
|
+
* const keyMetrics = await fmp.financial.getKeyMetrics({ symbol: 'AAPL' });
|
|
633
|
+
* keyMetrics.data.forEach(metric => {
|
|
634
|
+
* console.log(`${metric.date}: P/E ${metric.peRatio}, ROE ${metric.roe}%`);
|
|
635
|
+
* });
|
|
636
|
+
*
|
|
637
|
+
* // Get quarterly key metrics for Microsoft
|
|
638
|
+
* const quarterlyMetrics = await fmp.financial.getKeyMetrics({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
639
|
+
* ```
|
|
640
|
+
*
|
|
641
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#key-metrics-statement-analysis|FMP Key Metrics Documentation}
|
|
363
642
|
*/
|
|
364
|
-
async getKeyMetrics({
|
|
365
|
-
symbol,
|
|
366
|
-
period = "annual",
|
|
367
|
-
limit = 5
|
|
368
|
-
}) {
|
|
643
|
+
async getKeyMetrics(params) {
|
|
644
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
369
645
|
return this.client.get(`/key-metrics/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
370
646
|
}
|
|
371
647
|
/**
|
|
372
648
|
* Get financial ratios
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
649
|
+
*
|
|
650
|
+
* Provides comprehensive financial ratios including P/B ratio, ROE,
|
|
651
|
+
* debt-to-equity, and other important ratios. Essential for analyzing
|
|
652
|
+
* company financial health and comparing with peers.
|
|
653
|
+
*
|
|
654
|
+
* @param params - Financial ratios request parameters
|
|
655
|
+
* @param params.symbol - The stock symbol to get financial ratios for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
656
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
657
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
658
|
+
*
|
|
659
|
+
* @returns Promise resolving to array of financial ratios data with ratio metrics
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```typescript
|
|
663
|
+
* // Get financial ratios for Apple
|
|
664
|
+
* const ratios = await fmp.financial.getFinancialRatios({ symbol: 'AAPL' });
|
|
665
|
+
* ratios.data.forEach(ratio => {
|
|
666
|
+
* console.log(`${ratio.date}: P/B ${ratio.priceToBookRatio}, Debt/Equity ${ratio.debtToEquity}`);
|
|
667
|
+
* });
|
|
668
|
+
*
|
|
669
|
+
* // Get quarterly ratios for Microsoft
|
|
670
|
+
* const quarterlyRatios = await fmp.financial.getFinancialRatios({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
671
|
+
* ```
|
|
672
|
+
*
|
|
673
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#ratios-statement-analysis|FMP Financial Ratios Documentation}
|
|
378
674
|
*/
|
|
379
|
-
async getFinancialRatios({
|
|
380
|
-
symbol,
|
|
381
|
-
period = "annual",
|
|
382
|
-
limit = 5
|
|
383
|
-
}) {
|
|
675
|
+
async getFinancialRatios(params) {
|
|
676
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
384
677
|
return this.client.get(`/ratios/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
385
678
|
}
|
|
386
679
|
/**
|
|
387
|
-
* Get enterprise value
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
680
|
+
* Get enterprise value data
|
|
681
|
+
*
|
|
682
|
+
* Provides enterprise value metrics including total enterprise value,
|
|
683
|
+
* market cap, and debt information. Essential for company valuation
|
|
684
|
+
* and comparing companies with different capital structures.
|
|
685
|
+
*
|
|
686
|
+
* @param params - Enterprise value request parameters
|
|
687
|
+
* @param params.symbol - The stock symbol to get enterprise value for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
688
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
689
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
690
|
+
*
|
|
691
|
+
* @returns Promise resolving to array of enterprise value data with valuation metrics
|
|
692
|
+
*
|
|
693
|
+
* @example
|
|
694
|
+
* ```typescript
|
|
695
|
+
* // Get enterprise value for Apple
|
|
696
|
+
* const enterpriseValue = await fmp.financial.getEnterpriseValue({ symbol: 'AAPL' });
|
|
697
|
+
* enterpriseValue.data.forEach(ev => {
|
|
698
|
+
* console.log(`${ev.date}: EV $${ev.enterpriseValue.toLocaleString()}, Market Cap $${ev.marketCapitalization.toLocaleString()}`);
|
|
699
|
+
* });
|
|
700
|
+
*
|
|
701
|
+
* // Get quarterly enterprise value for Microsoft
|
|
702
|
+
* const quarterlyEV = await fmp.financial.getEnterpriseValue({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
703
|
+
* ```
|
|
704
|
+
*
|
|
705
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#enterprise-values-statement-analysis|FMP Enterprise Value Documentation}
|
|
393
706
|
*/
|
|
394
|
-
async getEnterpriseValue({
|
|
395
|
-
symbol,
|
|
396
|
-
period = "annual",
|
|
397
|
-
limit = 5
|
|
398
|
-
}) {
|
|
707
|
+
async getEnterpriseValue(params) {
|
|
708
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
399
709
|
return this.client.get(`/enterprise-value/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
400
710
|
}
|
|
401
711
|
/**
|
|
402
|
-
* Get
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
712
|
+
* Get cash flow growth data
|
|
713
|
+
*
|
|
714
|
+
* Provides cash flow growth rates showing how quickly a company's
|
|
715
|
+
* cash flows are growing over time. Essential for analyzing cash
|
|
716
|
+
* generation trends and financial sustainability.
|
|
717
|
+
*
|
|
718
|
+
* @param params - Cash flow growth request parameters
|
|
719
|
+
* @param params.symbol - The stock symbol to get cash flow growth for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
720
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
721
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
722
|
+
*
|
|
723
|
+
* @returns Promise resolving to array of cash flow growth data with growth metrics
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* ```typescript
|
|
727
|
+
* // Get cash flow growth for Apple
|
|
728
|
+
* const cashFlowGrowth = await fmp.financial.getCashflowGrowth({ symbol: 'AAPL' });
|
|
729
|
+
* cashFlowGrowth.data.forEach(growth => {
|
|
730
|
+
* console.log(`${growth.date}: Operating CF Growth ${growth.operatingCashFlowGrowth}%`);
|
|
731
|
+
* });
|
|
732
|
+
*
|
|
733
|
+
* // Get quarterly cash flow growth for Microsoft
|
|
734
|
+
* const quarterlyGrowth = await fmp.financial.getCashflowGrowth({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
735
|
+
* ```
|
|
736
|
+
*
|
|
737
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#cashflow-growth-statement-analysis|FMP Cash Flow Growth Documentation}
|
|
408
738
|
*/
|
|
409
|
-
async getCashflowGrowth({
|
|
410
|
-
symbol,
|
|
411
|
-
period = "annual",
|
|
412
|
-
limit = 5
|
|
413
|
-
}) {
|
|
739
|
+
async getCashflowGrowth(params) {
|
|
740
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
414
741
|
return this.client.get(
|
|
415
742
|
`/cash-flow-statement-growth/${symbol}?period=${period}&limit=${limit}`,
|
|
416
743
|
"v3"
|
|
417
744
|
);
|
|
418
745
|
}
|
|
419
746
|
/**
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
747
|
+
* Get income growth data
|
|
748
|
+
*
|
|
749
|
+
* Provides income growth rates showing how quickly a company's
|
|
750
|
+
* revenue and net income are growing over time. Essential for
|
|
751
|
+
* analyzing profitability trends and business momentum.
|
|
752
|
+
*
|
|
753
|
+
* @param params - Income growth request parameters
|
|
754
|
+
* @param params.symbol - The stock symbol to get income growth for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
755
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
756
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
757
|
+
*
|
|
758
|
+
* @returns Promise resolving to array of income growth data with growth metrics
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* ```typescript
|
|
762
|
+
* // Get income growth for Apple
|
|
763
|
+
* const incomeGrowth = await fmp.financial.getIncomeGrowth({ symbol: 'AAPL' });
|
|
764
|
+
* incomeGrowth.data.forEach(growth => {
|
|
765
|
+
* console.log(`${growth.date}: Revenue Growth ${growth.revenueGrowth}%, Net Income Growth ${growth.netIncomeGrowth}%`);
|
|
766
|
+
* });
|
|
767
|
+
*
|
|
768
|
+
* // Get quarterly income growth for Microsoft
|
|
769
|
+
* const quarterlyGrowth = await fmp.financial.getIncomeGrowth({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
770
|
+
* ```
|
|
771
|
+
*
|
|
772
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#income-growth-statement-analysis|FMP Income Growth Documentation}
|
|
426
773
|
*/
|
|
427
|
-
async getIncomeGrowth({
|
|
428
|
-
symbol,
|
|
429
|
-
period = "annual",
|
|
430
|
-
limit = 5
|
|
431
|
-
}) {
|
|
774
|
+
async getIncomeGrowth(params) {
|
|
775
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
432
776
|
return this.client.get(
|
|
433
777
|
`/income-statement-growth/${symbol}?period=${period}&limit=${limit}`,
|
|
434
778
|
"v3"
|
|
435
779
|
);
|
|
436
780
|
}
|
|
437
781
|
/**
|
|
438
|
-
* Get balance sheet growth
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
782
|
+
* Get balance sheet growth data
|
|
783
|
+
*
|
|
784
|
+
* Provides balance sheet growth rates showing how quickly a company's
|
|
785
|
+
* assets, liabilities, and equity are growing over time. Essential for
|
|
786
|
+
* analyzing capital structure trends and financial position changes.
|
|
787
|
+
*
|
|
788
|
+
* @param params - Balance sheet growth request parameters
|
|
789
|
+
* @param params.symbol - The stock symbol to get balance sheet growth for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
790
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
791
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
792
|
+
*
|
|
793
|
+
* @returns Promise resolving to array of balance sheet growth data with growth metrics
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```typescript
|
|
797
|
+
* // Get balance sheet growth for Apple
|
|
798
|
+
* const balanceSheetGrowth = await fmp.financial.getBalanceSheetGrowth({ symbol: 'AAPL' });
|
|
799
|
+
* balanceSheetGrowth.data.forEach(growth => {
|
|
800
|
+
* console.log(`${growth.date}: Assets Growth ${growth.totalAssetsGrowth}%, Equity Growth ${growth.totalStockholdersEquityGrowth}%`);
|
|
801
|
+
* });
|
|
802
|
+
*
|
|
803
|
+
* // Get quarterly balance sheet growth for Microsoft
|
|
804
|
+
* const quarterlyGrowth = await fmp.financial.getBalanceSheetGrowth({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
805
|
+
* ```
|
|
806
|
+
*
|
|
807
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#balance-sheet-growth-statement-analysis|FMP Balance Sheet Growth Documentation}
|
|
444
808
|
*/
|
|
445
|
-
async getBalanceSheetGrowth({
|
|
446
|
-
symbol,
|
|
447
|
-
period = "annual",
|
|
448
|
-
limit = 5
|
|
449
|
-
}) {
|
|
809
|
+
async getBalanceSheetGrowth(params) {
|
|
810
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
450
811
|
return this.client.get(
|
|
451
812
|
`/balance-sheet-statement-growth/${symbol}?period=${period}&limit=${limit}`,
|
|
452
813
|
"v3"
|
|
453
814
|
);
|
|
454
815
|
}
|
|
455
816
|
/**
|
|
456
|
-
* Get financial growth
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
817
|
+
* Get financial growth data
|
|
818
|
+
*
|
|
819
|
+
* Provides comprehensive financial growth rates across all key
|
|
820
|
+
* financial metrics. Essential for analyzing overall financial
|
|
821
|
+
* performance trends and business momentum.
|
|
822
|
+
*
|
|
823
|
+
* @param params - Financial growth request parameters
|
|
824
|
+
* @param params.symbol - The stock symbol to get financial growth for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
825
|
+
* @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
|
|
826
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
827
|
+
*
|
|
828
|
+
* @returns Promise resolving to array of financial growth data with comprehensive growth metrics
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* ```typescript
|
|
832
|
+
* // Get financial growth for Apple
|
|
833
|
+
* const financialGrowth = await fmp.financial.getFinancialGrowth({ symbol: 'AAPL' });
|
|
834
|
+
* financialGrowth.data.forEach(growth => {
|
|
835
|
+
* console.log(`${growth.date}: Revenue Growth ${growth.revenueGrowth}%, EPS Growth ${growth.epsGrowth}%`);
|
|
836
|
+
* });
|
|
837
|
+
*
|
|
838
|
+
* // Get quarterly financial growth for Microsoft
|
|
839
|
+
* const quarterlyGrowth = await fmp.financial.getFinancialGrowth({ symbol: 'MSFT', period: 'quarter', limit: 8 });
|
|
840
|
+
* ```
|
|
841
|
+
*
|
|
842
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#financial-growth-statement-analysis|FMP Financial Growth Documentation}
|
|
462
843
|
*/
|
|
463
|
-
async getFinancialGrowth({
|
|
464
|
-
symbol,
|
|
465
|
-
period = "annual",
|
|
466
|
-
limit = 5
|
|
467
|
-
}) {
|
|
844
|
+
async getFinancialGrowth(params) {
|
|
845
|
+
const { symbol, period = "annual", limit = 5 } = params;
|
|
468
846
|
return this.client.get(`/financial-growth/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
469
847
|
}
|
|
470
848
|
/**
|
|
471
|
-
* Get earnings
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
849
|
+
* Get historical earnings data
|
|
850
|
+
*
|
|
851
|
+
* Provides historical and upcoming earnings announcements including
|
|
852
|
+
* dates, estimated EPS, and actual EPS. Essential for analyzing
|
|
853
|
+
* earnings trends and tracking company performance.
|
|
854
|
+
*
|
|
855
|
+
* @param params - Earnings historical request parameters
|
|
856
|
+
* @param params.symbol - The stock symbol to get earnings history for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
857
|
+
* @param params.limit - Number of periods to retrieve (default: 5)
|
|
858
|
+
*
|
|
859
|
+
* @returns Promise resolving to array of historical earnings data with announcement details
|
|
860
|
+
*
|
|
861
|
+
* @example
|
|
862
|
+
* ```typescript
|
|
863
|
+
* // Get earnings history for Apple
|
|
864
|
+
* const earningsHistory = await fmp.financial.getEarningsHistorical({ symbol: 'AAPL', limit: 10 });
|
|
865
|
+
* earningsHistory.data.forEach(earning => {
|
|
866
|
+
* console.log(`${earning.date}: Est. ${earning.estimatedEps}, Actual ${earning.actualEps}`);
|
|
867
|
+
* });
|
|
868
|
+
*
|
|
869
|
+
* // Get earnings history for Microsoft
|
|
870
|
+
* const msftEarnings = await fmp.financial.getEarningsHistorical({ symbol: 'MSFT', limit: 8 });
|
|
871
|
+
* ```
|
|
872
|
+
*
|
|
873
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-historical-earnings|FMP Earnings Historical Documentation}
|
|
476
874
|
*/
|
|
477
|
-
async getEarningsHistorical({
|
|
478
|
-
symbol,
|
|
479
|
-
limit = 5
|
|
480
|
-
}) {
|
|
875
|
+
async getEarningsHistorical(params) {
|
|
876
|
+
const { symbol, limit = 5 } = params;
|
|
481
877
|
return this.client.get(`/historical/earning_calendar/${symbol}?limit=${limit}`, "v3");
|
|
482
878
|
}
|
|
483
879
|
/**
|
|
484
|
-
* Get earnings surprises
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
880
|
+
* Get earnings surprises data
|
|
881
|
+
*
|
|
882
|
+
* Provides earnings announcements that exceeded or fell short of
|
|
883
|
+
* analyst estimates. Essential for analyzing earnings quality and
|
|
884
|
+
* market reactions to earnings releases.
|
|
885
|
+
*
|
|
886
|
+
* @param symbol - The stock symbol to get earnings surprises for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
887
|
+
*
|
|
888
|
+
* @returns Promise resolving to array of earnings surprises data with surprise details
|
|
889
|
+
*
|
|
890
|
+
* @example
|
|
891
|
+
* ```typescript
|
|
892
|
+
* // Get earnings surprises for Apple
|
|
893
|
+
* const earningsSurprises = await fmp.financial.getEarningsSurprises('AAPL');
|
|
894
|
+
* earningsSurprises.data.forEach(surprise => {
|
|
895
|
+
* console.log(`${surprise.date}: Est. ${surprise.estimatedEps}, Actual ${surprise.actualEps}, Surprise ${surprise.surprisePercentage}%`);
|
|
896
|
+
* });
|
|
897
|
+
*
|
|
898
|
+
* // Get earnings surprises for Microsoft
|
|
899
|
+
* const msftSurprises = await fmp.financial.getEarningsSurprises('MSFT');
|
|
900
|
+
* ```
|
|
901
|
+
*
|
|
902
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-surprises-earnings|FMP Earnings Surprises Documentation}
|
|
489
903
|
*/
|
|
490
|
-
async getEarningsSurprises({
|
|
491
|
-
symbol
|
|
492
|
-
}) {
|
|
904
|
+
async getEarningsSurprises(symbol) {
|
|
493
905
|
return this.client.get(`/earnings-surprises/${symbol}`, "v3");
|
|
494
906
|
}
|
|
495
907
|
};
|
|
496
908
|
|
|
497
|
-
// src/endpoints/
|
|
498
|
-
var
|
|
909
|
+
// src/endpoints/etf.ts
|
|
910
|
+
var ETFEndpoints = class {
|
|
499
911
|
constructor(client) {
|
|
500
912
|
this.client = client;
|
|
501
913
|
}
|
|
502
914
|
/**
|
|
503
|
-
* Get
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
915
|
+
* Get available ETF holding dates
|
|
916
|
+
*
|
|
917
|
+
* Provides a list of dates when ETF holdings are updated and available.
|
|
918
|
+
* Useful for determining when the most recent holdings data is available
|
|
919
|
+
* and ensuring you're working with current portfolio information.
|
|
920
|
+
*
|
|
921
|
+
* @param symbol - ETF symbol to get holding dates for (e.g., 'SPY', 'VOO', 'QQQ')
|
|
922
|
+
*
|
|
923
|
+
* @returns Promise resolving to array of available holding dates
|
|
924
|
+
*
|
|
925
|
+
* @example
|
|
926
|
+
* ```typescript
|
|
927
|
+
* // Get holding dates for specific ETF
|
|
928
|
+
* const spyDates = await fmp.etf.getHoldingDates('SPY');
|
|
929
|
+
* spyDates.data.forEach(date => {
|
|
930
|
+
* console.log(`Holdings available: ${date.date}`);
|
|
931
|
+
* });
|
|
932
|
+
*
|
|
933
|
+
* // Get VOO holding dates
|
|
934
|
+
* const vooDates = await fmp.etf.getHoldingDates('VOO');
|
|
935
|
+
* ```
|
|
936
|
+
*
|
|
937
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#etf-holding-dates-etf-holdings|FMP ETF Holding Dates Documentation}
|
|
507
938
|
*/
|
|
508
|
-
async
|
|
509
|
-
|
|
510
|
-
"\u26A0\uFE0F ForexEndpoints.getQuote() is deprecated. Use fmp.quote.getQuote() instead. This method will be removed in version 0.1.0."
|
|
511
|
-
);
|
|
512
|
-
return this.client.get("/quote", "v3", params);
|
|
939
|
+
async getHoldingDates(symbol) {
|
|
940
|
+
return this.client.get("/etf-holdings/portfolio-date", "v4", { symbol });
|
|
513
941
|
}
|
|
514
942
|
/**
|
|
515
|
-
* Get
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
943
|
+
* Get ETF holdings for specific date
|
|
944
|
+
*
|
|
945
|
+
* Provides detailed holdings information for an ETF on a specific date.
|
|
946
|
+
* Includes individual stocks, their weights, shares held, and market values.
|
|
947
|
+
* Essential for understanding ETF composition and portfolio analysis.
|
|
948
|
+
*
|
|
949
|
+
* @param params - ETF holdings request parameters
|
|
950
|
+
* @param params.symbol - The ETF symbol to get holdings for (e.g., 'SPY', 'VOO', 'QQQ')
|
|
951
|
+
* @param params.date - The date to get holdings for in YYYY-MM-DD format
|
|
952
|
+
*
|
|
953
|
+
* @returns Promise resolving to array of ETF holdings with detailed stock information
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
* ```typescript
|
|
957
|
+
* // Get SPY holdings for specific date
|
|
958
|
+
* const holdings = await fmp.etf.getHoldings({ symbol: 'SPY', date: '2024-01-15' });
|
|
959
|
+
* holdings.data.forEach(holding => {
|
|
960
|
+
* console.log(`${holding.asset}: ${holding.weight}% (${holding.sharesNumber} shares)`);
|
|
961
|
+
* });
|
|
962
|
+
*
|
|
963
|
+
* // Get VOO holdings
|
|
964
|
+
* const vooHoldings = await fmp.etf.getHoldings({ symbol: 'VOO', date: '2024-01-15' });
|
|
965
|
+
* ```
|
|
966
|
+
*
|
|
967
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#etf-holdings-etf-holdings|FMP ETF Holdings Documentation}
|
|
521
968
|
*/
|
|
522
|
-
async
|
|
523
|
-
symbol,
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
"\u26A0\uFE0F ForexEndpoints.getHistoricalPrice() is deprecated. Use fmp.quote.getHistoricalPrice() instead. This method will be removed in version 0.1.0."
|
|
529
|
-
);
|
|
530
|
-
const params = {};
|
|
531
|
-
if (from) params.from = from;
|
|
532
|
-
if (to) params.to = to;
|
|
533
|
-
return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
// src/endpoints/crypto.ts
|
|
538
|
-
var CryptoEndpoints = class {
|
|
539
|
-
constructor(client) {
|
|
540
|
-
this.client = client;
|
|
969
|
+
async getHoldings(params) {
|
|
970
|
+
const { symbol, date } = params;
|
|
971
|
+
const queryParams = {};
|
|
972
|
+
if (symbol) queryParams.symbol = symbol;
|
|
973
|
+
if (date) queryParams.date = date;
|
|
974
|
+
return this.client.get("/etf-holdings", "v4", queryParams);
|
|
541
975
|
}
|
|
542
976
|
/**
|
|
543
|
-
* Get
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
977
|
+
* Get ETF holdings and components
|
|
978
|
+
*
|
|
979
|
+
* Provides all stocks held by a specific ETF including assets, share numbers,
|
|
980
|
+
* and weight percentages. Essential for understanding ETF composition and
|
|
981
|
+
* finding which ETFs hold specific stocks.
|
|
982
|
+
*
|
|
983
|
+
* @param symbol - The ETF symbol to get holdings for (e.g., 'SPY', 'VOO', 'QQQ')
|
|
984
|
+
*
|
|
985
|
+
* @returns Promise resolving to array of ETF holdings with stock details
|
|
986
|
+
*
|
|
987
|
+
* @example
|
|
988
|
+
* ```typescript
|
|
989
|
+
* // Get SPY holdings
|
|
990
|
+
* const spyHoldings = await fmp.etf.getHolder('SPY');
|
|
991
|
+
* spyHoldings.data.forEach(holding => {
|
|
992
|
+
* console.log(`${holding.asset}: ${holding.weight}% (${holding.sharesNumber} shares)`);
|
|
993
|
+
* });
|
|
994
|
+
*
|
|
995
|
+
* // Get VOO holdings
|
|
996
|
+
* const vooHoldings = await fmp.etf.getHolder('VOO');
|
|
997
|
+
* ```
|
|
998
|
+
*
|
|
999
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#etf-holder-etf-holdings|FMP ETF Holder Documentation}
|
|
547
1000
|
*/
|
|
548
|
-
async
|
|
549
|
-
|
|
550
|
-
"\u26A0\uFE0F CryptoEndpoints.getQuote() is deprecated. Use fmp.quote.getQuote() instead. This method will be removed in version 0.1.0."
|
|
551
|
-
);
|
|
552
|
-
return this.client.getSingle(`/quote/${symbol}`, "v3");
|
|
1001
|
+
async getHolder(symbol) {
|
|
1002
|
+
return this.client.get(`/etf-holder/${symbol}`, "v3");
|
|
553
1003
|
}
|
|
554
1004
|
/**
|
|
555
|
-
* Get
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
1005
|
+
* Get ETF profile and information
|
|
1006
|
+
*
|
|
1007
|
+
* Provides comprehensive information about an ETF including ticker symbol,
|
|
1008
|
+
* name, expense ratio, assets under management, and other key metrics.
|
|
1009
|
+
* Essential for ETF comparison and due diligence.
|
|
1010
|
+
*
|
|
1011
|
+
* @param symbol - ETF symbol to get profile for (e.g., 'SPY', 'VOO', 'QQQ')
|
|
1012
|
+
*
|
|
1013
|
+
* @returns Promise resolving to ETF profile with detailed information
|
|
1014
|
+
*
|
|
1015
|
+
* @example
|
|
1016
|
+
* ```typescript
|
|
1017
|
+
* // Get SPY profile
|
|
1018
|
+
* const spyProfile = await fmp.etf.getProfile('SPY');
|
|
1019
|
+
* console.log(`SPY AUM: $${spyProfile.data.aum.toLocaleString()}`);
|
|
1020
|
+
* console.log(`Expense Ratio: ${spyProfile.data.expenseRatio}%`);
|
|
1021
|
+
*
|
|
1022
|
+
* // Get VOO profile
|
|
1023
|
+
* const vooProfile = await fmp.etf.getProfile('VOO');
|
|
1024
|
+
* ```
|
|
1025
|
+
*
|
|
1026
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#etf-information-etf-holdings|FMP ETF Information Documentation}
|
|
561
1027
|
*/
|
|
562
|
-
async
|
|
563
|
-
symbol
|
|
564
|
-
from,
|
|
565
|
-
to
|
|
566
|
-
}) {
|
|
567
|
-
console.warn(
|
|
568
|
-
"\u26A0\uFE0F CryptoEndpoints.getHistoricalPrice() is deprecated. Use fmp.quote.getHistoricalPrice() instead. This method will be removed in version 0.1.0."
|
|
569
|
-
);
|
|
570
|
-
const params = {};
|
|
571
|
-
if (from) params.from = from;
|
|
572
|
-
if (to) params.to = to;
|
|
573
|
-
return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", params);
|
|
574
|
-
}
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
// src/endpoints/etf.ts
|
|
578
|
-
var ETFEndpoints = class {
|
|
579
|
-
constructor(client) {
|
|
580
|
-
this.client = client;
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Get ETF holding dates
|
|
584
|
-
* https://site.financialmodelingprep.com/developer/docs#etf-holding-dates-etf-holdings
|
|
585
|
-
* @param symbol - The symbol of the ETF to get the holding dates for
|
|
586
|
-
* @returns The FMP ETF Holding Dates endpoint provides a list of the dates on which ETF holdings are updated. For example, an investor may want to know when an ETF's holdings are updated in order to make sure that they are still aligned with their investment goals.
|
|
587
|
-
*/
|
|
588
|
-
async getHoldingDates({ symbol }) {
|
|
589
|
-
const params = {};
|
|
590
|
-
if (symbol) params.symbol = symbol;
|
|
591
|
-
return this.client.get("/etf-holdings/portfolio-date", "v4", params);
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Get ETF holdings
|
|
595
|
-
* https://site.financialmodelingprep.com/developer/docs#etf-holdings-etf-holdings
|
|
596
|
-
* @param symbol - The symbol of the ETF to get the holdings for
|
|
597
|
-
* @param date - The date to get the holdings for
|
|
598
|
-
* @returns The FMP ETF Holdings endpoint provides a list of all the institutional investors that own shares of an ETF. For example, an investor may want to know which ETF has the highest exposure to a particular industry or sector.
|
|
599
|
-
*/
|
|
600
|
-
async getHoldings({
|
|
601
|
-
symbol,
|
|
602
|
-
date
|
|
603
|
-
}) {
|
|
604
|
-
const params = {};
|
|
605
|
-
if (symbol) params.symbol = symbol;
|
|
606
|
-
if (date) params.date = date;
|
|
607
|
-
return this.client.get("/etf-holdings", "v4", params);
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Get ETF holder
|
|
611
|
-
* https://site.financialmodelingprep.com/developer/docs#etf-holder-etf-holdings
|
|
612
|
-
* @param symbol - The symbol of the ETF to get the holder for
|
|
613
|
-
* @returns This endpoint returns all stocks held by a specific ETF. Assets, share number, and weight are among the fields returned. For example you can get components of SPY, VOO and more.
|
|
614
|
-
*/
|
|
615
|
-
async getHolder({ symbol }) {
|
|
616
|
-
return this.client.get(`/etf-holder/${symbol}`, "v3");
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* Get ETF profile
|
|
620
|
-
* https://site.financialmodelingprep.com/developer/docs#etf-information-etf-holdings
|
|
621
|
-
* @param symbol - The symbol of the ETF to get the profile for
|
|
622
|
-
* @returns The FMP ETF Information endpoint provides basic information about an ETF, such as its ticker symbol, name, expense ratio, and asset under management. For example, an investor may want to compare the expense ratios of different ETFs to find the one that is most cost-effective.
|
|
623
|
-
*/
|
|
624
|
-
async getProfile({ symbol }) {
|
|
625
|
-
const params = {};
|
|
626
|
-
if (symbol) params.symbol = symbol;
|
|
627
|
-
return this.client.getSingle("/etf-info", "v4", params);
|
|
1028
|
+
async getProfile(symbol) {
|
|
1029
|
+
return this.client.getSingle("/etf-info", "v4", { symbol });
|
|
628
1030
|
}
|
|
629
1031
|
/**
|
|
630
|
-
* Get ETF sector weighting
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
1032
|
+
* Get ETF sector weighting and exposure
|
|
1033
|
+
*
|
|
1034
|
+
* Provides a breakdown of an ETF's sector allocation showing the percentage
|
|
1035
|
+
* of assets invested in each sector. Essential for understanding sector
|
|
1036
|
+
* exposure and diversification analysis.
|
|
1037
|
+
*
|
|
1038
|
+
* @param symbol - The ETF symbol to get sector weighting for (e.g., 'SPY', 'VOO', 'QQQ')
|
|
1039
|
+
*
|
|
1040
|
+
* @returns Promise resolving to array of sector weightings with percentage allocations
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* ```typescript
|
|
1044
|
+
* // Get SPY sector weightings
|
|
1045
|
+
* const sectorWeightings = await fmp.etf.getSectorWeighting('SPY');
|
|
1046
|
+
* sectorWeightings.data.forEach(sector => {
|
|
1047
|
+
* console.log(`${sector.sector}: ${sector.weight}%`);
|
|
1048
|
+
* });
|
|
1049
|
+
*
|
|
1050
|
+
* // Get QQQ sector exposure (tech-heavy)
|
|
1051
|
+
* const qqqSectors = await fmp.etf.getSectorWeighting('QQQ');
|
|
1052
|
+
* ```
|
|
1053
|
+
*
|
|
1054
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#etf-sector-weighting-etf-holdings|FMP ETF Sector Weighting Documentation}
|
|
634
1055
|
*/
|
|
635
|
-
async getSectorWeighting(
|
|
1056
|
+
async getSectorWeighting(symbol) {
|
|
636
1057
|
return this.client.get(`/etf-sector-weightings/${symbol}`, "v3");
|
|
637
1058
|
}
|
|
638
1059
|
/**
|
|
639
|
-
* Get ETF country weighting
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
1060
|
+
* Get ETF country weighting and exposure
|
|
1061
|
+
*
|
|
1062
|
+
* Provides a breakdown of an ETF's geographic allocation showing the percentage
|
|
1063
|
+
* of assets invested in each country. Essential for understanding international
|
|
1064
|
+
* exposure and geographic diversification.
|
|
1065
|
+
*
|
|
1066
|
+
* @param symbol - The ETF symbol to get country weighting for (e.g., 'SPY', 'VOO', 'EFA')
|
|
1067
|
+
*
|
|
1068
|
+
* @returns Promise resolving to array of country weightings with percentage allocations
|
|
1069
|
+
*
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```typescript
|
|
1072
|
+
* // Get SPY country weightings
|
|
1073
|
+
* const countryWeightings = await fmp.etf.getCountryWeighting('SPY');
|
|
1074
|
+
* countryWeightings.data.forEach(country => {
|
|
1075
|
+
* console.log(`${country.country}: ${country.weight}%`);
|
|
1076
|
+
* });
|
|
1077
|
+
*
|
|
1078
|
+
* // Get international ETF exposure
|
|
1079
|
+
* const efaCountries = await fmp.etf.getCountryWeighting('EFA');
|
|
1080
|
+
* ```
|
|
1081
|
+
*
|
|
1082
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#etf-country-weighting-etf-holdings|FMP ETF Country Weighting Documentation}
|
|
643
1083
|
*/
|
|
644
|
-
async getCountryWeighting(
|
|
1084
|
+
async getCountryWeighting(symbol) {
|
|
645
1085
|
return this.client.get(`/etf-country-weightings/${symbol}`, "v3");
|
|
646
1086
|
}
|
|
647
1087
|
/**
|
|
648
|
-
* Get ETF
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
1088
|
+
* Get ETF stock exposure and holdings
|
|
1089
|
+
*
|
|
1090
|
+
* Provides detailed exposure information for a specific stock across all ETFs
|
|
1091
|
+
* that hold it. Includes market value, share numbers, and weight percentages.
|
|
1092
|
+
* Useful for finding which ETFs have exposure to specific stocks.
|
|
1093
|
+
*
|
|
1094
|
+
* @param symbol - The stock symbol to get ETF exposure for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
1095
|
+
*
|
|
1096
|
+
* @returns Promise resolving to array of ETF exposures with detailed holding information
|
|
1097
|
+
*
|
|
1098
|
+
* @example
|
|
1099
|
+
* ```typescript
|
|
1100
|
+
* // Find ETFs that hold Apple
|
|
1101
|
+
* const appleExposure = await fmp.etf.getStockExposure('AAPL');
|
|
1102
|
+
* appleExposure.data.forEach(etf => {
|
|
1103
|
+
* console.log(`${etf.etfSymbol}: ${etf.weight}% (${etf.sharesNumber} shares)`);
|
|
1104
|
+
* });
|
|
1105
|
+
*
|
|
1106
|
+
* // Find ETFs that hold Microsoft
|
|
1107
|
+
* const msftExposure = await fmp.etf.getStockExposure('MSFT');
|
|
1108
|
+
* ```
|
|
1109
|
+
*
|
|
1110
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#etf-sector-exposure-etf-holdings|FMP ETF Stock Exposure Documentation}
|
|
652
1111
|
*/
|
|
653
|
-
async getStockExposure(
|
|
1112
|
+
async getStockExposure(symbol) {
|
|
654
1113
|
return this.client.get(`/etf-stock-exposure/${symbol}`, "v3");
|
|
655
1114
|
}
|
|
656
1115
|
};
|
|
657
1116
|
|
|
658
|
-
// src/endpoints/mutual-fund.ts
|
|
659
|
-
var MutualFundEndpoints = class {
|
|
660
|
-
constructor(client) {
|
|
661
|
-
this.client = client;
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Get mutual fund quote
|
|
665
|
-
* @deprecated Use `fmp.quote.getQuote()` instead. This method will be removed in a future release.
|
|
666
|
-
* @param params - Parameters for the mutual fund quote request
|
|
667
|
-
* @returns Mutual fund quote data
|
|
668
|
-
*/
|
|
669
|
-
async getQuote(params) {
|
|
670
|
-
return this.client.get("/quote", "v3", params);
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Get mutual fund holders
|
|
674
|
-
* https://site.financialmodelingprep.com/developer/docs#mutual-fund-holder-mutual-funds-holdings
|
|
675
|
-
* @param symbol - The symbol of the mutual fund to get the holders for
|
|
676
|
-
* @returns Mutual fund holders data
|
|
677
|
-
*/
|
|
678
|
-
async getHolders({ symbol }) {
|
|
679
|
-
return this.client.get(`/mutual-fund-holder/${symbol}`, "v3");
|
|
680
|
-
}
|
|
681
|
-
};
|
|
682
|
-
|
|
683
1117
|
// src/endpoints/economic.ts
|
|
684
1118
|
var EconomicEndpoints = class {
|
|
685
1119
|
constructor(client) {
|
|
686
1120
|
this.client = client;
|
|
687
1121
|
}
|
|
688
1122
|
/**
|
|
689
|
-
* Get treasury rates
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
*
|
|
1123
|
+
* Get treasury rates data
|
|
1124
|
+
*
|
|
1125
|
+
* Provides historical treasury rates for various maturities including
|
|
1126
|
+
* 1-month, 3-month, 6-month, 1-year, 2-year, 3-year, 5-year, 7-year,
|
|
1127
|
+
* 10-year, 20-year, and 30-year treasury bonds. Essential for analyzing
|
|
1128
|
+
* interest rate trends, yield curves, and fixed income investments.
|
|
1129
|
+
*
|
|
1130
|
+
* @param params - Treasury rates request parameters
|
|
1131
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional, defaults to 1 year ago)
|
|
1132
|
+
* @param params.to - End date in YYYY-MM-DD format (optional, defaults to today)
|
|
1133
|
+
*
|
|
1134
|
+
* @returns Promise resolving to array of treasury rates data with yield information
|
|
1135
|
+
*
|
|
1136
|
+
* @example
|
|
1137
|
+
* ```typescript
|
|
1138
|
+
* // Get treasury rates for the last year
|
|
1139
|
+
* const treasuryRates = await fmp.economic.getTreasuryRates({
|
|
1140
|
+
* from: '2023-01-01',
|
|
1141
|
+
* to: '2023-12-31'
|
|
1142
|
+
* });
|
|
1143
|
+
* treasuryRates.data.forEach(rate => {
|
|
1144
|
+
* console.log(`${rate.date}: 10Y ${rate.tenY}%, 2Y ${rate.twoY}%`);
|
|
1145
|
+
* });
|
|
1146
|
+
*
|
|
1147
|
+
* // Get recent treasury rates
|
|
1148
|
+
* const recentRates = await fmp.economic.getTreasuryRates({
|
|
1149
|
+
* from: '2024-01-01'
|
|
1150
|
+
* });
|
|
1151
|
+
* ```
|
|
1152
|
+
*
|
|
1153
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#treasury-rates-economics-data|FMP Treasury Rates Documentation}
|
|
694
1154
|
*/
|
|
695
1155
|
async getTreasuryRates(params) {
|
|
696
1156
|
const { from, to } = params;
|
|
@@ -700,12 +1160,47 @@ var EconomicEndpoints = class {
|
|
|
700
1160
|
return this.client.get("/treasury", "v4", queryParams);
|
|
701
1161
|
}
|
|
702
1162
|
/**
|
|
703
|
-
* Get economic indicators
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
1163
|
+
* Get economic indicators data
|
|
1164
|
+
*
|
|
1165
|
+
* Provides real-time and historical economic data for a wide variety of
|
|
1166
|
+
* economic indicators including GDP, unemployment, inflation, retail sales,
|
|
1167
|
+
* and many others. Essential for macroeconomic analysis and understanding
|
|
1168
|
+
* economic trends and cycles.
|
|
1169
|
+
*
|
|
1170
|
+
* @param params - Economic indicators request parameters
|
|
1171
|
+
* @param params.name - The economic indicator to retrieve
|
|
1172
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional, defaults to 1 year ago)
|
|
1173
|
+
* @param params.to - End date in YYYY-MM-DD format (optional, defaults to today)
|
|
1174
|
+
*
|
|
1175
|
+
* @returns Promise resolving to array of economic indicator data with historical values
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* ```typescript
|
|
1179
|
+
* // Get GDP data for the last year
|
|
1180
|
+
* const gdpData = await fmp.economic.getEconomicIndicators({
|
|
1181
|
+
* name: 'GDP',
|
|
1182
|
+
* from: '2023-01-01',
|
|
1183
|
+
* to: '2023-12-31'
|
|
1184
|
+
* });
|
|
1185
|
+
* gdpData.data.forEach(gdp => {
|
|
1186
|
+
* console.log(`${gdp.date}: GDP $${gdp.value.toLocaleString()} billion`);
|
|
1187
|
+
* });
|
|
1188
|
+
*
|
|
1189
|
+
* // Get unemployment rate data
|
|
1190
|
+
* const unemploymentData = await fmp.economic.getEconomicIndicators({
|
|
1191
|
+
* name: 'unemploymentRate',
|
|
1192
|
+
* from: '2024-01-01'
|
|
1193
|
+
* });
|
|
1194
|
+
*
|
|
1195
|
+
* // Get inflation rate data
|
|
1196
|
+
* const inflationData = await fmp.economic.getEconomicIndicators({
|
|
1197
|
+
* name: 'inflationRate',
|
|
1198
|
+
* from: '2023-01-01',
|
|
1199
|
+
* to: '2023-12-31'
|
|
1200
|
+
* });
|
|
1201
|
+
* ```
|
|
1202
|
+
*
|
|
1203
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#economic-indicators-economics-data|FMP Economic Indicators Documentation}
|
|
709
1204
|
*/
|
|
710
1205
|
async getEconomicIndicators(params) {
|
|
711
1206
|
const { name, from, to } = params;
|
|
@@ -722,51 +1217,290 @@ var MarketEndpoints = class {
|
|
|
722
1217
|
this.client = client;
|
|
723
1218
|
}
|
|
724
1219
|
/**
|
|
725
|
-
* Get market hours
|
|
1220
|
+
* Get current market hours and trading status
|
|
1221
|
+
*
|
|
1222
|
+
* Provides real-time information about market trading hours, including
|
|
1223
|
+
* whether markets are currently open or closed, trading session times,
|
|
1224
|
+
* and upcoming market holidays. Essential for determining trading
|
|
1225
|
+
* availability and market status.
|
|
1226
|
+
*
|
|
1227
|
+
* @returns Promise resolving to market hours data with trading status and session information
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* ```typescript
|
|
1231
|
+
* // Get current market status
|
|
1232
|
+
* const marketHours = await fmp.market.getMarketHours();
|
|
1233
|
+
* console.log(`Market is ${marketHours.data.isTheStockMarketOpen ? 'OPEN' : 'CLOSED'}`);
|
|
1234
|
+
* console.log(`Current time: ${marketHours.data.currentTime}`);
|
|
1235
|
+
* console.log(`Next trading day: ${marketHours.data.nextTradingDay}`);
|
|
1236
|
+
*
|
|
1237
|
+
* // Check if it's a trading day
|
|
1238
|
+
* if (marketHours.data.isTheStockMarketOpen) {
|
|
1239
|
+
* console.log('Markets are currently open for trading');
|
|
1240
|
+
* } else {
|
|
1241
|
+
* console.log('Markets are closed');
|
|
1242
|
+
* }
|
|
1243
|
+
* ```
|
|
1244
|
+
*
|
|
1245
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#market-hours|FMP Market Hours Documentation}
|
|
726
1246
|
*/
|
|
727
1247
|
async getMarketHours() {
|
|
728
1248
|
return this.client.get("/market-hours", "v3");
|
|
729
1249
|
}
|
|
730
1250
|
/**
|
|
731
|
-
* Get market performance
|
|
1251
|
+
* Get overall market performance data
|
|
1252
|
+
*
|
|
1253
|
+
* Provides comprehensive market performance data including major indices,
|
|
1254
|
+
* market breadth, and key performance metrics. Essential for understanding
|
|
1255
|
+
* overall market sentiment, trends, and daily market activity.
|
|
1256
|
+
*
|
|
1257
|
+
* @returns Promise resolving to array of market performance data with indices and metrics
|
|
1258
|
+
*
|
|
1259
|
+
* @example
|
|
1260
|
+
* ```typescript
|
|
1261
|
+
* // Get overall market performance
|
|
1262
|
+
* const marketPerformance = await fmp.market.getMarketPerformance();
|
|
1263
|
+
* marketPerformance.data.forEach(market => {
|
|
1264
|
+
* console.log(`${market.index}: ${market.change} (${market.changesPercentage}%)`);
|
|
1265
|
+
* console.log(` Open: $${market.open}, High: $${market.dayHigh}, Low: $${market.dayLow}`);
|
|
1266
|
+
* });
|
|
1267
|
+
*
|
|
1268
|
+
* // Find specific indices
|
|
1269
|
+
* const sp500 = marketPerformance.data.find(market => market.index === 'S&P 500');
|
|
1270
|
+
* console.log(`S&P 500 performance: ${sp500?.changesPercentage}%`);
|
|
1271
|
+
*
|
|
1272
|
+
* // Check market sentiment
|
|
1273
|
+
* const gainers = marketPerformance.data.filter(market => market.changesPercentage > 0);
|
|
1274
|
+
* const losers = marketPerformance.data.filter(market => market.changesPercentage < 0);
|
|
1275
|
+
* console.log(`Gaining indices: ${gainers.length}, Losing indices: ${losers.length}`);
|
|
1276
|
+
* ```
|
|
1277
|
+
*
|
|
1278
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#market-performance|FMP Market Performance Documentation}
|
|
732
1279
|
*/
|
|
733
1280
|
async getMarketPerformance() {
|
|
734
1281
|
return this.client.get("/market-performance", "v3");
|
|
735
1282
|
}
|
|
736
1283
|
/**
|
|
737
|
-
* Get top
|
|
738
|
-
*
|
|
739
|
-
*
|
|
1284
|
+
* Get top gaining stocks for the current trading day
|
|
1285
|
+
*
|
|
1286
|
+
* Provides a list of stocks that have gained the most value during the
|
|
1287
|
+
* current trading session. Essential for identifying momentum stocks,
|
|
1288
|
+
* tracking market movers, and discovering potential investment opportunities.
|
|
1289
|
+
* Useful for day trading, momentum strategies, and market analysis.
|
|
1290
|
+
*
|
|
1291
|
+
* @returns Promise resolving to array of top gaining stocks with price and percentage change data
|
|
1292
|
+
*
|
|
1293
|
+
* @example
|
|
1294
|
+
* ```typescript
|
|
1295
|
+
* // Get top gainers for the day
|
|
1296
|
+
* const gainers = await fmp.market.getGainers();
|
|
1297
|
+
* console.log(`Top ${gainers.data.length} gaining stocks today:`);
|
|
1298
|
+
*
|
|
1299
|
+
* gainers.data.forEach((stock, index) => {
|
|
1300
|
+
* console.log(`${index + 1}. ${stock.symbol} (${stock.name})`);
|
|
1301
|
+
* console.log(` Price: $${stock.price} | Change: +${stock.change} (${stock.changesPercentage}%)`);
|
|
1302
|
+
* console.log(` Volume: ${stock.volume.toLocaleString()}`);
|
|
1303
|
+
* });
|
|
1304
|
+
*
|
|
1305
|
+
* // Find stocks with >10% gains
|
|
1306
|
+
* const bigGainers = gainers.data.filter(stock => stock.changesPercentage > 10);
|
|
1307
|
+
* console.log(`Stocks with >10% gains: ${bigGainers.length}`);
|
|
1308
|
+
*
|
|
1309
|
+
* // Check volume leaders among gainers
|
|
1310
|
+
* const highVolumeGainers = gainers.data.filter(stock => stock.volume > 1000000);
|
|
1311
|
+
* console.log(`High volume gainers (>1M shares): ${highVolumeGainers.length}`);
|
|
1312
|
+
* ```
|
|
1313
|
+
*
|
|
1314
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#market-biggest-gainers-market-overview|FMP Market Biggest Gainers Documentation}
|
|
740
1315
|
*/
|
|
741
1316
|
async getGainers() {
|
|
742
1317
|
return this.client.get("/stock_market/gainers", "v3");
|
|
743
1318
|
}
|
|
744
1319
|
/**
|
|
745
|
-
* Get top
|
|
746
|
-
*
|
|
747
|
-
*
|
|
1320
|
+
* Get top losing stocks for the current trading day
|
|
1321
|
+
*
|
|
1322
|
+
* Provides a list of stocks that have lost the most value during the
|
|
1323
|
+
* current trading session. Essential for identifying underperforming stocks,
|
|
1324
|
+
* tracking market decliners, and discovering potential contrarian opportunities.
|
|
1325
|
+
* Useful for risk management, short selling strategies, and market analysis.
|
|
1326
|
+
*
|
|
1327
|
+
* @returns Promise resolving to array of top losing stocks with price and percentage change data
|
|
1328
|
+
*
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```typescript
|
|
1331
|
+
* // Get top losers for the day
|
|
1332
|
+
* const losers = await fmp.market.getLosers();
|
|
1333
|
+
* console.log(`Top ${losers.data.length} losing stocks today:`);
|
|
1334
|
+
*
|
|
1335
|
+
* losers.data.forEach((stock, index) => {
|
|
1336
|
+
* console.log(`${index + 1}. ${stock.symbol} (${stock.name})`);
|
|
1337
|
+
* console.log(` Price: $${stock.price} | Change: ${stock.change} (${stock.changesPercentage}%)`);
|
|
1338
|
+
* console.log(` Volume: ${stock.volume.toLocaleString()}`);
|
|
1339
|
+
* });
|
|
1340
|
+
*
|
|
1341
|
+
* // Find stocks with >10% losses
|
|
1342
|
+
* const bigLosers = losers.data.filter(stock => stock.changesPercentage < -10);
|
|
1343
|
+
* console.log(`Stocks with >10% losses: ${bigLosers.length}`);
|
|
1344
|
+
*
|
|
1345
|
+
* // Check for potential oversold conditions
|
|
1346
|
+
* const highVolumeLosers = losers.data.filter(stock => stock.volume > 1000000);
|
|
1347
|
+
* console.log(`High volume losers (>1M shares): ${highVolumeLosers.length}`);
|
|
1348
|
+
*
|
|
1349
|
+
* // Look for potential bounce candidates
|
|
1350
|
+
* const oversoldStocks = losers.data.filter(stock =>
|
|
1351
|
+
* stock.changesPercentage < -5 && stock.volume > 500000
|
|
1352
|
+
* );
|
|
1353
|
+
* ```
|
|
1354
|
+
*
|
|
1355
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#market-biggest-losers-market-overview|FMP Market Biggest Losers Documentation}
|
|
748
1356
|
*/
|
|
749
1357
|
async getLosers() {
|
|
750
1358
|
return this.client.get("/stock_market/losers", "v3");
|
|
751
1359
|
}
|
|
752
1360
|
/**
|
|
753
|
-
* Get most
|
|
1361
|
+
* Get most actively traded stocks for the current trading day
|
|
1362
|
+
*
|
|
1363
|
+
* Provides a list of stocks with the highest trading volume during the
|
|
1364
|
+
* current trading session. Essential for identifying stocks with high
|
|
1365
|
+
* liquidity, tracking market interest, and discovering stocks with
|
|
1366
|
+
* significant trading activity. Useful for day trading and liquidity analysis.
|
|
1367
|
+
*
|
|
1368
|
+
* @returns Promise resolving to array of most active stocks with volume and price data
|
|
1369
|
+
*
|
|
1370
|
+
* @example
|
|
1371
|
+
* ```typescript
|
|
1372
|
+
* // Get most active stocks for the day
|
|
1373
|
+
* const mostActive = await fmp.market.getMostActive();
|
|
1374
|
+
* console.log(`Top ${mostActive.data.length} most active stocks today:`);
|
|
1375
|
+
*
|
|
1376
|
+
* mostActive.data.forEach((stock, index) => {
|
|
1377
|
+
* console.log(`${index + 1}. ${stock.symbol} (${stock.name})`);
|
|
1378
|
+
* console.log(` Volume: ${stock.volume.toLocaleString()} shares`);
|
|
1379
|
+
* console.log(` Price: $${stock.price} | Change: ${stock.change} (${stock.changesPercentage}%)`);
|
|
1380
|
+
* console.log(` Avg Volume: ${stock.avgVolume?.toLocaleString() || 'N/A'}`);
|
|
1381
|
+
* });
|
|
1382
|
+
*
|
|
1383
|
+
* // Find stocks with unusual volume (>2x average)
|
|
1384
|
+
* const unusualVolume = mostActive.data.filter(stock =>
|
|
1385
|
+
* stock.avgVolume && stock.volume > stock.avgVolume * 2
|
|
1386
|
+
* );
|
|
1387
|
+
* console.log(`Stocks with unusual volume: ${unusualVolume.length}`);
|
|
1388
|
+
*
|
|
1389
|
+
* // Check for high volume gainers
|
|
1390
|
+
* const highVolumeGainers = mostActive.data.filter(stock =>
|
|
1391
|
+
* stock.changesPercentage > 0 && stock.volume > 1000000
|
|
1392
|
+
* );
|
|
1393
|
+
* console.log(`High volume gainers: ${highVolumeGainers.length}`);
|
|
1394
|
+
*
|
|
1395
|
+
* // Find penny stocks with high volume
|
|
1396
|
+
* const pennyStocks = mostActive.data.filter(stock =>
|
|
1397
|
+
* stock.price < 5 && stock.volume > 500000
|
|
1398
|
+
* );
|
|
1399
|
+
* ```
|
|
1400
|
+
*
|
|
1401
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#market-most-actives|FMP Market Most Actives Documentation}
|
|
754
1402
|
*/
|
|
755
1403
|
async getMostActive() {
|
|
756
1404
|
return this.client.get("/stock_market/actives", "v3");
|
|
757
1405
|
}
|
|
758
1406
|
/**
|
|
759
|
-
* Get sector performance
|
|
760
|
-
*
|
|
761
|
-
*
|
|
1407
|
+
* Get sector performance data for the current trading day
|
|
1408
|
+
*
|
|
1409
|
+
* Provides performance data for all major market sectors including
|
|
1410
|
+
* technology, healthcare, financials, energy, and others. Essential for
|
|
1411
|
+
* sector rotation analysis, identifying leading/lagging sectors, and
|
|
1412
|
+
* understanding market breadth and sector-specific trends.
|
|
1413
|
+
*
|
|
1414
|
+
* @returns Promise resolving to array of sector performance data with percentage changes
|
|
1415
|
+
*
|
|
1416
|
+
* @example
|
|
1417
|
+
* ```typescript
|
|
1418
|
+
* // Get sector performance for the day
|
|
1419
|
+
* const sectorPerformance = await fmp.market.getSectorPerformance();
|
|
1420
|
+
* console.log(`Sector performance for ${sectorPerformance.data.length} sectors:`);
|
|
1421
|
+
*
|
|
1422
|
+
* sectorPerformance.data.forEach(sector => {
|
|
1423
|
+
* const changeColor = sector.changesPercentage >= 0 ? 'green' : 'red';
|
|
1424
|
+
* console.log(`${sector.sector}: ${sector.changesPercentage}%`);
|
|
1425
|
+
* console.log(` Change: ${sector.changesPercentage >= 0 ? '+' : ''}${sector.changesPercentage}%`);
|
|
1426
|
+
* });
|
|
1427
|
+
*
|
|
1428
|
+
* // Find best performing sectors
|
|
1429
|
+
* const topSectors = sectorPerformance.data
|
|
1430
|
+
* .sort((a, b) => b.changesPercentage - a.changesPercentage)
|
|
1431
|
+
* .slice(0, 3);
|
|
1432
|
+
* console.log('Top 3 performing sectors:');
|
|
1433
|
+
* topSectors.forEach((sector, index) => {
|
|
1434
|
+
* console.log(`${index + 1}. ${sector.sector}: ${sector.changesPercentage}%`);
|
|
1435
|
+
* });
|
|
1436
|
+
*
|
|
1437
|
+
* // Find worst performing sectors
|
|
1438
|
+
* const bottomSectors = sectorPerformance.data
|
|
1439
|
+
* .sort((a, b) => a.changesPercentage - b.changesPercentage)
|
|
1440
|
+
* .slice(0, 3);
|
|
1441
|
+
* console.log('Bottom 3 performing sectors:');
|
|
1442
|
+
* bottomSectors.forEach((sector, index) => {
|
|
1443
|
+
* console.log(`${index + 1}. ${sector.sector}: ${sector.changesPercentage}%`);
|
|
1444
|
+
* });
|
|
1445
|
+
*
|
|
1446
|
+
* // Check for sector rotation
|
|
1447
|
+
* const gainingSectors = sectorPerformance.data.filter(sector => sector.changesPercentage > 0);
|
|
1448
|
+
* const losingSectors = sectorPerformance.data.filter(sector => sector.changesPercentage < 0);
|
|
1449
|
+
* console.log(`Sectors gaining: ${gainingSectors.length}, Sectors losing: ${losingSectors.length}`);
|
|
1450
|
+
* ```
|
|
1451
|
+
*
|
|
1452
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#sector-performance-market-overview|FMP Sector Performance Documentation}
|
|
762
1453
|
*/
|
|
763
1454
|
async getSectorPerformance() {
|
|
764
1455
|
return this.client.get("/sector-performance", "v3");
|
|
765
1456
|
}
|
|
766
1457
|
/**
|
|
767
|
-
* Get market indices
|
|
768
|
-
*
|
|
769
|
-
*
|
|
1458
|
+
* Get real-time data for major market indices
|
|
1459
|
+
*
|
|
1460
|
+
* Provides real-time quote data for all major stock market indices including
|
|
1461
|
+
* S&P 500, Dow Jones Industrial Average, NASDAQ Composite, and other global
|
|
1462
|
+
* indices. Essential for tracking overall market performance, understanding
|
|
1463
|
+
* market sentiment, and identifying broad market trends.
|
|
1464
|
+
*
|
|
1465
|
+
* @returns Promise resolving to array of market index data with real-time quotes
|
|
1466
|
+
*
|
|
1467
|
+
* @example
|
|
1468
|
+
* ```typescript
|
|
1469
|
+
* // Get real-time market indices
|
|
1470
|
+
* const marketIndices = await fmp.market.getMarketIndex();
|
|
1471
|
+
* console.log(`Real-time data for ${marketIndices.data.length} major indices:`);
|
|
1472
|
+
*
|
|
1473
|
+
* marketIndices.data.forEach(index => {
|
|
1474
|
+
* console.log(`${index.symbol} (${index.name}):`);
|
|
1475
|
+
* console.log(` Price: $${index.price}`);
|
|
1476
|
+
* console.log(` Change: ${index.change} (${index.changesPercentage}%)`);
|
|
1477
|
+
* console.log(` Day Range: $${index.dayLow} - $${index.dayHigh}`);
|
|
1478
|
+
* console.log(` Volume: ${index.volume?.toLocaleString() || 'N/A'}`);
|
|
1479
|
+
* });
|
|
1480
|
+
*
|
|
1481
|
+
* // Find specific major indices
|
|
1482
|
+
* const sp500 = marketIndices.data.find(index => index.symbol === '^GSPC');
|
|
1483
|
+
* const nasdaq = marketIndices.data.find(index => index.symbol === '^IXIC');
|
|
1484
|
+
* const dowJones = marketIndices.data.find(index => index.symbol === '^DJI');
|
|
1485
|
+
*
|
|
1486
|
+
* console.log(`S&P 500: ${sp500?.price} (${sp500?.changesPercentage}%)`);
|
|
1487
|
+
* console.log(`NASDAQ: ${nasdaq?.price} (${nasdaq?.changesPercentage}%)`);
|
|
1488
|
+
* console.log(`Dow Jones: ${dowJones?.price} (${dowJones?.changesPercentage}%)`);
|
|
1489
|
+
*
|
|
1490
|
+
* // Check market breadth
|
|
1491
|
+
* const gainingIndices = marketIndices.data.filter(index => index.changesPercentage > 0);
|
|
1492
|
+
* const losingIndices = marketIndices.data.filter(index => index.changesPercentage < 0);
|
|
1493
|
+
* console.log(`Indices gaining: ${gainingIndices.length}, Indices losing: ${losingIndices.length}`);
|
|
1494
|
+
*
|
|
1495
|
+
* // Find international indices
|
|
1496
|
+
* const internationalIndices = marketIndices.data.filter(index =>
|
|
1497
|
+
* !index.symbol.startsWith('^') ||
|
|
1498
|
+
* index.name.toLowerCase().includes('europe') ||
|
|
1499
|
+
* index.name.toLowerCase().includes('asia')
|
|
1500
|
+
* );
|
|
1501
|
+
* ```
|
|
1502
|
+
*
|
|
1503
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#market-index-market-overview|FMP Market Index Documentation}
|
|
770
1504
|
*/
|
|
771
1505
|
async getMarketIndex() {
|
|
772
1506
|
return this.client.get("/quotes/index", "v3");
|
|
@@ -779,41 +1513,182 @@ var ListEndpoints = class {
|
|
|
779
1513
|
this.client = client;
|
|
780
1514
|
}
|
|
781
1515
|
/**
|
|
782
|
-
* Get
|
|
783
|
-
*
|
|
784
|
-
*
|
|
1516
|
+
* Get comprehensive list of all available stocks
|
|
1517
|
+
*
|
|
1518
|
+
* Provides a complete list of all stocks available on major exchanges including
|
|
1519
|
+
* NYSE, NASDAQ, and other global markets. Essential for discovering available
|
|
1520
|
+
* symbols, building watchlists, or creating stock screening applications.
|
|
1521
|
+
*
|
|
1522
|
+
* @returns Promise resolving to array of stock data with symbol, name, exchange, and price information
|
|
1523
|
+
*
|
|
1524
|
+
* @example
|
|
1525
|
+
* ```typescript
|
|
1526
|
+
* // Get all available stocks
|
|
1527
|
+
* const stocks = await fmp.list.getStockList();
|
|
1528
|
+
* console.log(`Total stocks available: ${stocks.data.length}`);
|
|
1529
|
+
*
|
|
1530
|
+
* // Find specific stocks
|
|
1531
|
+
* const appleStock = stocks.data.find(stock => stock.symbol === 'AAPL');
|
|
1532
|
+
* console.log(`Apple: ${appleStock?.name} (${appleStock?.exchange})`);
|
|
1533
|
+
*
|
|
1534
|
+
* // Filter by exchange
|
|
1535
|
+
* const nasdaqStocks = stocks.data.filter(stock => stock.exchange === 'NASDAQ');
|
|
1536
|
+
* console.log(`NASDAQ stocks: ${nasdaqStocks.length}`);
|
|
1537
|
+
* ```
|
|
1538
|
+
*
|
|
1539
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#symbol-list-stock-list|FMP Stock List Documentation}
|
|
785
1540
|
*/
|
|
786
1541
|
async getStockList() {
|
|
787
1542
|
return this.client.get("/stock/list");
|
|
788
1543
|
}
|
|
789
1544
|
/**
|
|
790
|
-
* Get
|
|
791
|
-
*
|
|
792
|
-
*
|
|
1545
|
+
* Get comprehensive list of all available ETFs
|
|
1546
|
+
*
|
|
1547
|
+
* Provides a complete list of all Exchange-Traded Funds (ETFs) available for trading.
|
|
1548
|
+
* Includes ETFs from various asset classes including equity, bond, commodity, and
|
|
1549
|
+
* sector-specific funds. Essential for ETF research and portfolio construction.
|
|
1550
|
+
*
|
|
1551
|
+
* @returns Promise resolving to array of ETF data with symbol, name, exchange, and asset class information
|
|
1552
|
+
*
|
|
1553
|
+
* @example
|
|
1554
|
+
* ```typescript
|
|
1555
|
+
* // Get all available ETFs
|
|
1556
|
+
* const etfs = await fmp.list.getETFList();
|
|
1557
|
+
* console.log(`Total ETFs available: ${etfs.data.length}`);
|
|
1558
|
+
*
|
|
1559
|
+
* // Find specific ETFs
|
|
1560
|
+
* const spyETF = etfs.data.find(etf => etf.symbol === 'SPY');
|
|
1561
|
+
* console.log(`SPY: ${spyETF?.name} (${spyETF?.assetClass})`);
|
|
1562
|
+
*
|
|
1563
|
+
* // Filter by asset class
|
|
1564
|
+
* const equityETFs = etfs.data.filter(etf => etf.assetClass === 'Equity');
|
|
1565
|
+
* console.log(`Equity ETFs: ${equityETFs.length}`);
|
|
1566
|
+
*
|
|
1567
|
+
* // Find sector ETFs
|
|
1568
|
+
* const techETFs = etfs.data.filter(etf =>
|
|
1569
|
+
* etf.name.toLowerCase().includes('technology') ||
|
|
1570
|
+
* etf.name.toLowerCase().includes('tech')
|
|
1571
|
+
* );
|
|
1572
|
+
* ```
|
|
1573
|
+
*
|
|
1574
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#exchange-traded-fund-search-stock-list|FMP ETF List Documentation}
|
|
793
1575
|
*/
|
|
794
1576
|
async getETFList() {
|
|
795
1577
|
return this.client.get("/etf/list");
|
|
796
1578
|
}
|
|
797
1579
|
/**
|
|
798
|
-
* Get
|
|
799
|
-
*
|
|
800
|
-
*
|
|
1580
|
+
* Get comprehensive list of all available cryptocurrencies
|
|
1581
|
+
*
|
|
1582
|
+
* Provides a complete list of all cryptocurrencies available for trading.
|
|
1583
|
+
* Includes major cryptocurrencies like Bitcoin, Ethereum, and thousands of altcoins
|
|
1584
|
+
* with their trading pairs against USD and other major currencies.
|
|
1585
|
+
*
|
|
1586
|
+
* @returns Promise resolving to array of cryptocurrency data with symbol, name, and exchange information
|
|
1587
|
+
*
|
|
1588
|
+
* @example
|
|
1589
|
+
* ```typescript
|
|
1590
|
+
* // Get all available cryptocurrencies
|
|
1591
|
+
* const cryptos = await fmp.list.getCryptoList();
|
|
1592
|
+
* console.log(`Total cryptocurrencies available: ${cryptos.data.length}`);
|
|
1593
|
+
*
|
|
1594
|
+
* // Find major cryptocurrencies
|
|
1595
|
+
* const bitcoin = cryptos.data.find(crypto => crypto.symbol === 'BTCUSD');
|
|
1596
|
+
* console.log(`Bitcoin: ${bitcoin?.name} (${bitcoin?.exchange})`);
|
|
1597
|
+
*
|
|
1598
|
+
* const ethereum = cryptos.data.find(crypto => crypto.symbol === 'ETHUSD');
|
|
1599
|
+
* console.log(`Ethereum: ${ethereum?.name} (${ethereum?.exchange})`);
|
|
1600
|
+
*
|
|
1601
|
+
* // Filter by exchange
|
|
1602
|
+
* const binanceCryptos = cryptos.data.filter(crypto => crypto.exchange === 'Binance');
|
|
1603
|
+
* console.log(`Binance cryptocurrencies: ${binanceCryptos.length}`);
|
|
1604
|
+
*
|
|
1605
|
+
* // Find altcoins
|
|
1606
|
+
* const altcoins = cryptos.data.filter(crypto =>
|
|
1607
|
+
* !['BTCUSD', 'ETHUSD', 'USDTUSD', 'USDCUSD'].includes(crypto.symbol)
|
|
1608
|
+
* );
|
|
1609
|
+
* ```
|
|
1610
|
+
*
|
|
1611
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#cryptocurrencies-list-crypto|FMP Cryptocurrency List Documentation}
|
|
801
1612
|
*/
|
|
802
1613
|
async getCryptoList() {
|
|
803
1614
|
return this.client.get("/symbol/available-cryptocurrencies");
|
|
804
1615
|
}
|
|
805
1616
|
/**
|
|
806
|
-
* Get forex
|
|
807
|
-
*
|
|
808
|
-
*
|
|
1617
|
+
* Get comprehensive list of all available forex currency pairs
|
|
1618
|
+
*
|
|
1619
|
+
* Provides a complete list of all foreign exchange currency pairs available for trading.
|
|
1620
|
+
* Includes major, minor, and exotic currency pairs with their base and quote currencies.
|
|
1621
|
+
* Essential for forex trading, currency analysis, and international market research.
|
|
1622
|
+
*
|
|
1623
|
+
* @returns Promise resolving to array of forex data with currency pair symbols and exchange information
|
|
1624
|
+
*
|
|
1625
|
+
* @example
|
|
1626
|
+
* ```typescript
|
|
1627
|
+
* // Get all available forex pairs
|
|
1628
|
+
* const forexPairs = await fmp.list.getForexList();
|
|
1629
|
+
* console.log(`Total forex pairs available: ${forexPairs.data.length}`);
|
|
1630
|
+
*
|
|
1631
|
+
* // Find major currency pairs
|
|
1632
|
+
* const eurUsd = forexPairs.data.find(pair => pair.symbol === 'EURUSD');
|
|
1633
|
+
* console.log(`EUR/USD: ${eurUsd?.name} (${eurUsd?.exchange})`);
|
|
1634
|
+
*
|
|
1635
|
+
* const gbpUsd = forexPairs.data.find(pair => pair.symbol === 'GBPUSD');
|
|
1636
|
+
* console.log(`GBP/USD: ${gbpUsd?.name} (${gbpUsd?.exchange})`);
|
|
1637
|
+
*
|
|
1638
|
+
* // Filter major pairs (USD as quote currency)
|
|
1639
|
+
* const majorPairs = forexPairs.data.filter(pair =>
|
|
1640
|
+
* pair.symbol.endsWith('USD') && pair.symbol.length === 6
|
|
1641
|
+
* );
|
|
1642
|
+
* console.log(`Major pairs: ${majorPairs.length}`);
|
|
1643
|
+
*
|
|
1644
|
+
* // Find exotic pairs
|
|
1645
|
+
* const exoticPairs = forexPairs.data.filter(pair =>
|
|
1646
|
+
* pair.symbol.includes('ZAR') || pair.symbol.includes('TRY') || pair.symbol.includes('BRL')
|
|
1647
|
+
* );
|
|
1648
|
+
* ```
|
|
1649
|
+
*
|
|
1650
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#forex-list-forex|FMP Forex List Documentation}
|
|
809
1651
|
*/
|
|
810
1652
|
async getForexList() {
|
|
811
1653
|
return this.client.get("/symbol/available-forex-currency-pairs");
|
|
812
1654
|
}
|
|
813
1655
|
/**
|
|
814
|
-
* Get available indexes
|
|
815
|
-
*
|
|
816
|
-
*
|
|
1656
|
+
* Get comprehensive list of all available market indexes
|
|
1657
|
+
*
|
|
1658
|
+
* Provides a complete list of all market indexes available for tracking and analysis.
|
|
1659
|
+
* Includes major global indexes like S&P 500, NASDAQ, Dow Jones, as well as
|
|
1660
|
+
* international indexes, sector indexes, and specialized market benchmarks.
|
|
1661
|
+
*
|
|
1662
|
+
* @returns Promise resolving to array of index data with symbol, name, and exchange information
|
|
1663
|
+
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* ```typescript
|
|
1666
|
+
* // Get all available indexes
|
|
1667
|
+
* const indexes = await fmp.list.getAvailableIndexes();
|
|
1668
|
+
* console.log(`Total indexes available: ${indexes.data.length}`);
|
|
1669
|
+
*
|
|
1670
|
+
* // Find major US indexes
|
|
1671
|
+
* const sp500 = indexes.data.find(index => index.symbol === '^GSPC');
|
|
1672
|
+
* console.log(`S&P 500: ${sp500?.name} (${sp500?.exchange})`);
|
|
1673
|
+
*
|
|
1674
|
+
* const nasdaq = indexes.data.find(index => index.symbol === '^IXIC');
|
|
1675
|
+
* console.log(`NASDAQ: ${nasdaq?.name} (${nasdaq?.exchange})`);
|
|
1676
|
+
*
|
|
1677
|
+
* const dowJones = indexes.data.find(index => index.symbol === '^DJI');
|
|
1678
|
+
* console.log(`Dow Jones: ${dowJones?.name} (${dowJones?.exchange})`);
|
|
1679
|
+
*
|
|
1680
|
+
* // Filter by exchange
|
|
1681
|
+
* const nyseIndexes = indexes.data.filter(index => index.exchange === 'NYSE');
|
|
1682
|
+
* console.log(`NYSE indexes: ${nyseIndexes.length}`);
|
|
1683
|
+
*
|
|
1684
|
+
* // Find sector indexes
|
|
1685
|
+
* const techIndexes = indexes.data.filter(index =>
|
|
1686
|
+
* index.name.toLowerCase().includes('technology') ||
|
|
1687
|
+
* index.name.toLowerCase().includes('tech')
|
|
1688
|
+
* );
|
|
1689
|
+
* ```
|
|
1690
|
+
*
|
|
1691
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#available-indexes|FMP Available Indexes Documentation}
|
|
817
1692
|
*/
|
|
818
1693
|
async getAvailableIndexes() {
|
|
819
1694
|
return this.client.get("/symbol/available-indexes");
|
|
@@ -826,82 +1701,244 @@ var CalendarEndpoints = class {
|
|
|
826
1701
|
this.client = client;
|
|
827
1702
|
}
|
|
828
1703
|
/**
|
|
829
|
-
* Get earnings calendar
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
1704
|
+
* Get earnings calendar data
|
|
1705
|
+
*
|
|
1706
|
+
* Provides upcoming earnings announcements for all publicly traded companies
|
|
1707
|
+
* within a specified date range. Essential for tracking earnings season,
|
|
1708
|
+
* market events, and investment timing decisions.
|
|
1709
|
+
*
|
|
1710
|
+
* @param params - Earnings calendar request parameters
|
|
1711
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
|
|
1712
|
+
* @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
|
|
1713
|
+
*
|
|
1714
|
+
* @returns Promise resolving to array of earnings calendar data with announcement details
|
|
1715
|
+
*
|
|
1716
|
+
* @example
|
|
1717
|
+
* ```typescript
|
|
1718
|
+
* // Get earnings calendar for next week
|
|
1719
|
+
* const earningsCalendar = await fmp.calendar.getEarningsCalendar({
|
|
1720
|
+
* from: '2024-01-15',
|
|
1721
|
+
* to: '2024-01-22'
|
|
1722
|
+
* });
|
|
1723
|
+
* earningsCalendar.data.forEach(earning => {
|
|
1724
|
+
* console.log(`${earning.date}: ${earning.symbol} - Est. EPS: ${earning.estimatedEps}`);
|
|
1725
|
+
* });
|
|
1726
|
+
*
|
|
1727
|
+
* // Get earnings calendar for current month
|
|
1728
|
+
* const monthlyEarnings = await fmp.calendar.getEarningsCalendar({
|
|
1729
|
+
* from: '2024-01-01',
|
|
1730
|
+
* to: '2024-01-31'
|
|
1731
|
+
* });
|
|
1732
|
+
* ```
|
|
1733
|
+
*
|
|
1734
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-calendar-earnings|FMP Earnings Calendar Documentation}
|
|
834
1735
|
*/
|
|
835
|
-
async getEarningsCalendar(
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
if (
|
|
839
|
-
|
|
1736
|
+
async getEarningsCalendar(params = {}) {
|
|
1737
|
+
const { from, to } = params;
|
|
1738
|
+
const queryParams = {};
|
|
1739
|
+
if (from) queryParams.from = from;
|
|
1740
|
+
if (to) queryParams.to = to;
|
|
1741
|
+
return this.client.get("/earning_calendar", "v3", queryParams);
|
|
840
1742
|
}
|
|
841
1743
|
/**
|
|
842
|
-
* Get earnings
|
|
843
|
-
*
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
*
|
|
1744
|
+
* Get confirmed earnings calendar data
|
|
1745
|
+
*
|
|
1746
|
+
* Provides confirmed earnings announcements with verified dates and times.
|
|
1747
|
+
* These are earnings announcements that have been officially confirmed
|
|
1748
|
+
* by companies, providing more reliable scheduling information.
|
|
1749
|
+
*
|
|
1750
|
+
* @param params - Confirmed earnings calendar request parameters
|
|
1751
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
|
|
1752
|
+
* @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
|
|
1753
|
+
*
|
|
1754
|
+
* @returns Promise resolving to array of confirmed earnings calendar data
|
|
1755
|
+
*
|
|
1756
|
+
* @example
|
|
1757
|
+
* ```typescript
|
|
1758
|
+
* // Get confirmed earnings for next week
|
|
1759
|
+
* const confirmedEarnings = await fmp.calendar.getEarningsConfirmed({
|
|
1760
|
+
* from: '2024-01-15',
|
|
1761
|
+
* to: '2024-01-22'
|
|
1762
|
+
* });
|
|
1763
|
+
* confirmedEarnings.data.forEach(earning => {
|
|
1764
|
+
* console.log(`${earning.date}: ${earning.symbol} - Confirmed: ${earning.time}`);
|
|
1765
|
+
* });
|
|
1766
|
+
*
|
|
1767
|
+
* // Get confirmed earnings for current month
|
|
1768
|
+
* const monthlyConfirmed = await fmp.calendar.getEarningsConfirmed({
|
|
1769
|
+
* from: '2024-01-01',
|
|
1770
|
+
* to: '2024-01-31'
|
|
1771
|
+
* });
|
|
1772
|
+
* ```
|
|
1773
|
+
*
|
|
1774
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-confirmed-earnings|FMP Earnings Confirmed Documentation}
|
|
847
1775
|
*/
|
|
848
|
-
async getEarningsConfirmed(
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
if (
|
|
852
|
-
|
|
1776
|
+
async getEarningsConfirmed(params = {}) {
|
|
1777
|
+
const { from, to } = params;
|
|
1778
|
+
const queryParams = {};
|
|
1779
|
+
if (from) queryParams.from = from;
|
|
1780
|
+
if (to) queryParams.to = to;
|
|
1781
|
+
return this.client.get("/earning-calendar-confirmed", "v4", queryParams);
|
|
853
1782
|
}
|
|
854
1783
|
/**
|
|
855
|
-
* Get dividends calendar
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
*
|
|
1784
|
+
* Get dividends calendar data
|
|
1785
|
+
*
|
|
1786
|
+
* Provides upcoming dividend payments and ex-dividend dates for all
|
|
1787
|
+
* publicly traded companies within a specified date range. Essential
|
|
1788
|
+
* for dividend investors and income-focused strategies.
|
|
1789
|
+
*
|
|
1790
|
+
* @param params - Dividends calendar request parameters
|
|
1791
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
|
|
1792
|
+
* @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
|
|
1793
|
+
*
|
|
1794
|
+
* @returns Promise resolving to array of dividends calendar data with payment details
|
|
1795
|
+
*
|
|
1796
|
+
* @example
|
|
1797
|
+
* ```typescript
|
|
1798
|
+
* // Get dividends calendar for next week
|
|
1799
|
+
* const dividendsCalendar = await fmp.calendar.getDividendsCalendar({
|
|
1800
|
+
* from: '2024-01-15',
|
|
1801
|
+
* to: '2024-01-22'
|
|
1802
|
+
* });
|
|
1803
|
+
* dividendsCalendar.data.forEach(dividend => {
|
|
1804
|
+
* console.log(`${dividend.date}: ${dividend.symbol} - Amount: $${dividend.amount}`);
|
|
1805
|
+
* });
|
|
1806
|
+
*
|
|
1807
|
+
* // Get dividends calendar for current month
|
|
1808
|
+
* const monthlyDividends = await fmp.calendar.getDividendsCalendar({
|
|
1809
|
+
* from: '2024-01-01',
|
|
1810
|
+
* to: '2024-01-31'
|
|
1811
|
+
* });
|
|
1812
|
+
* ```
|
|
1813
|
+
*
|
|
1814
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#dividends-calendar-dividends|FMP Dividends Calendar Documentation}
|
|
860
1815
|
*/
|
|
861
|
-
async getDividendsCalendar(
|
|
862
|
-
const
|
|
863
|
-
|
|
864
|
-
if (
|
|
865
|
-
|
|
1816
|
+
async getDividendsCalendar(params = {}) {
|
|
1817
|
+
const { from, to } = params;
|
|
1818
|
+
const queryParams = {};
|
|
1819
|
+
if (from) queryParams.from = from;
|
|
1820
|
+
if (to) queryParams.to = to;
|
|
1821
|
+
return this.client.get("/stock_dividend_calendar", "v3", queryParams);
|
|
866
1822
|
}
|
|
867
1823
|
/**
|
|
868
|
-
* Get
|
|
869
|
-
*
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
1824
|
+
* Get economic calendar data
|
|
1825
|
+
*
|
|
1826
|
+
* Provides upcoming economic events, indicators, and data releases
|
|
1827
|
+
* that can impact financial markets. Essential for understanding
|
|
1828
|
+
* market-moving events and economic trends.
|
|
1829
|
+
*
|
|
1830
|
+
* @param params - Economic calendar request parameters
|
|
1831
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
|
|
1832
|
+
* @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
|
|
1833
|
+
*
|
|
1834
|
+
* @returns Promise resolving to array of economic calendar data with event details
|
|
1835
|
+
*
|
|
1836
|
+
* @example
|
|
1837
|
+
* ```typescript
|
|
1838
|
+
* // Get economic calendar for next week
|
|
1839
|
+
* const economicCalendar = await fmp.calendar.getEconomicsCalendar({
|
|
1840
|
+
* from: '2024-01-15',
|
|
1841
|
+
* to: '2024-01-22'
|
|
1842
|
+
* });
|
|
1843
|
+
* economicCalendar.data.forEach(event => {
|
|
1844
|
+
* console.log(`${event.date}: ${event.event} - Country: ${event.country}`);
|
|
1845
|
+
* });
|
|
1846
|
+
*
|
|
1847
|
+
* // Get economic calendar for current month
|
|
1848
|
+
* const monthlyEconomic = await fmp.calendar.getEconomicsCalendar({
|
|
1849
|
+
* from: '2024-01-01',
|
|
1850
|
+
* to: '2024-01-31'
|
|
1851
|
+
* });
|
|
1852
|
+
* ```
|
|
1853
|
+
*
|
|
1854
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#economics-calendar-economics-data|FMP Economic Calendar Documentation}
|
|
873
1855
|
*/
|
|
874
|
-
async getEconomicsCalendar(
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
if (
|
|
878
|
-
|
|
1856
|
+
async getEconomicsCalendar(params = {}) {
|
|
1857
|
+
const { from, to } = params;
|
|
1858
|
+
const queryParams = {};
|
|
1859
|
+
if (from) queryParams.from = from;
|
|
1860
|
+
if (to) queryParams.to = to;
|
|
1861
|
+
return this.client.get("/economic_calendar", "v3", queryParams);
|
|
879
1862
|
}
|
|
880
1863
|
/**
|
|
881
|
-
* Get IPO calendar
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
1864
|
+
* Get IPO calendar data
|
|
1865
|
+
*
|
|
1866
|
+
* Provides upcoming initial public offerings (IPOs) and their details
|
|
1867
|
+
* within a specified date range. Essential for tracking new market
|
|
1868
|
+
* entrants and investment opportunities in newly public companies.
|
|
1869
|
+
*
|
|
1870
|
+
* @param params - IPO calendar request parameters
|
|
1871
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
|
|
1872
|
+
* @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
|
|
1873
|
+
*
|
|
1874
|
+
* @returns Promise resolving to array of IPO calendar data with offering details
|
|
1875
|
+
*
|
|
1876
|
+
* @example
|
|
1877
|
+
* ```typescript
|
|
1878
|
+
* // Get IPO calendar for next week
|
|
1879
|
+
* const ipoCalendar = await fmp.calendar.getIPOCalendar({
|
|
1880
|
+
* from: '2024-01-15',
|
|
1881
|
+
* to: '2024-01-22'
|
|
1882
|
+
* });
|
|
1883
|
+
* ipoCalendar.data.forEach(ipo => {
|
|
1884
|
+
* console.log(`${ipo.date}: ${ipo.symbol} - Price: $${ipo.price}, Shares: ${ipo.shares.toLocaleString()}`);
|
|
1885
|
+
* });
|
|
1886
|
+
*
|
|
1887
|
+
* // Get IPO calendar for current month
|
|
1888
|
+
* const monthlyIPOs = await fmp.calendar.getIPOCalendar({
|
|
1889
|
+
* from: '2024-01-01',
|
|
1890
|
+
* to: '2024-01-31'
|
|
1891
|
+
* });
|
|
1892
|
+
* ```
|
|
1893
|
+
*
|
|
1894
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#ipo-calender-by-ipo-calendar|FMP IPO Calendar Documentation}
|
|
886
1895
|
*/
|
|
887
|
-
async getIPOCalendar(
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
if (
|
|
891
|
-
|
|
1896
|
+
async getIPOCalendar(params = {}) {
|
|
1897
|
+
const { from, to } = params;
|
|
1898
|
+
const queryParams = {};
|
|
1899
|
+
if (from) queryParams.from = from;
|
|
1900
|
+
if (to) queryParams.to = to;
|
|
1901
|
+
return this.client.get("/ipo_calendar", "v3", queryParams);
|
|
892
1902
|
}
|
|
893
1903
|
/**
|
|
894
|
-
* Get stock splits calendar
|
|
895
|
-
*
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
1904
|
+
* Get stock splits calendar data
|
|
1905
|
+
*
|
|
1906
|
+
* Provides upcoming stock splits for publicly traded companies within
|
|
1907
|
+
* a specified date range. Essential for understanding corporate actions
|
|
1908
|
+
* that affect share prices and trading dynamics.
|
|
1909
|
+
*
|
|
1910
|
+
* @param params - Stock splits calendar request parameters
|
|
1911
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
|
|
1912
|
+
* @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
|
|
1913
|
+
*
|
|
1914
|
+
* @returns Promise resolving to array of stock splits calendar data with split details
|
|
1915
|
+
*
|
|
1916
|
+
* @example
|
|
1917
|
+
* ```typescript
|
|
1918
|
+
* // Get stock splits calendar for next week
|
|
1919
|
+
* const splitsCalendar = await fmp.calendar.getSplitsCalendar({
|
|
1920
|
+
* from: '2024-01-15',
|
|
1921
|
+
* to: '2024-01-22'
|
|
1922
|
+
* });
|
|
1923
|
+
* splitsCalendar.data.forEach(split => {
|
|
1924
|
+
* console.log(`${split.date}: ${split.symbol} - Ratio: ${split.numerator}:${split.denominator}`);
|
|
1925
|
+
* });
|
|
1926
|
+
*
|
|
1927
|
+
* // Get stock splits calendar for current month
|
|
1928
|
+
* const monthlySplits = await fmp.calendar.getSplitsCalendar({
|
|
1929
|
+
* from: '2024-01-01',
|
|
1930
|
+
* to: '2024-01-31'
|
|
1931
|
+
* });
|
|
1932
|
+
* ```
|
|
1933
|
+
*
|
|
1934
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#splits-calendar-splits|FMP Stock Splits Calendar Documentation}
|
|
899
1935
|
*/
|
|
900
|
-
async getSplitsCalendar(
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
if (
|
|
904
|
-
|
|
1936
|
+
async getSplitsCalendar(params = {}) {
|
|
1937
|
+
const { from, to } = params;
|
|
1938
|
+
const queryParams = {};
|
|
1939
|
+
if (from) queryParams.from = from;
|
|
1940
|
+
if (to) queryParams.to = to;
|
|
1941
|
+
return this.client.get("/stock_split_calendar", "v3", queryParams);
|
|
905
1942
|
}
|
|
906
1943
|
};
|
|
907
1944
|
|
|
@@ -911,97 +1948,243 @@ var CompanyEndpoints = class {
|
|
|
911
1948
|
this.client = client;
|
|
912
1949
|
}
|
|
913
1950
|
/**
|
|
914
|
-
* Get company profile
|
|
915
|
-
*
|
|
916
|
-
*
|
|
917
|
-
*
|
|
1951
|
+
* Get comprehensive company profile and information
|
|
1952
|
+
*
|
|
1953
|
+
* Provides detailed company information including financial metrics, business description,
|
|
1954
|
+
* headquarters location, and key performance indicators. Essential for fundamental analysis
|
|
1955
|
+
* and understanding a company's business model and market position.
|
|
1956
|
+
*
|
|
1957
|
+
* @param symbol - The stock symbol to get the profile for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
1958
|
+
*
|
|
1959
|
+
* @returns Promise resolving to comprehensive company profile with financial and business information
|
|
1960
|
+
*
|
|
1961
|
+
* @example
|
|
1962
|
+
* ```typescript
|
|
1963
|
+
* // Get Apple's company profile
|
|
1964
|
+
* const profile = await fmp.company.getCompanyProfile('AAPL');
|
|
1965
|
+
* console.log(`Company: ${profile.data.companyName}`);
|
|
1966
|
+
* console.log(`Industry: ${profile.data.industry}`);
|
|
1967
|
+
* console.log(`Market Cap: $${profile.data.mktCap.toLocaleString()}`);
|
|
1968
|
+
* console.log(`Description: ${profile.data.description.substring(0, 100)}...`);
|
|
1969
|
+
*
|
|
1970
|
+
* // Get Microsoft's profile
|
|
1971
|
+
* const msftProfile = await fmp.company.getCompanyProfile('MSFT');
|
|
1972
|
+
* ```
|
|
1973
|
+
*
|
|
1974
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#company-profile-company-information|FMP Company Profile Documentation}
|
|
918
1975
|
*/
|
|
919
|
-
async getCompanyProfile(
|
|
1976
|
+
async getCompanyProfile(symbol) {
|
|
920
1977
|
return this.client.getSingle(`/profile/${symbol}`, "v3");
|
|
921
1978
|
}
|
|
922
1979
|
/**
|
|
923
|
-
* Get executive compensation
|
|
924
|
-
*
|
|
925
|
-
*
|
|
926
|
-
*
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
* Get
|
|
936
|
-
*
|
|
937
|
-
*
|
|
938
|
-
*
|
|
1980
|
+
* Get executive compensation and governance information
|
|
1981
|
+
*
|
|
1982
|
+
* Provides detailed compensation data for company executives including salary, bonuses,
|
|
1983
|
+
* stock options, and other benefits. Essential for governance analysis and understanding
|
|
1984
|
+
* executive pay structures and alignment with shareholder interests.
|
|
1985
|
+
*
|
|
1986
|
+
* @param symbol - The stock symbol to get executive compensation for (e.g., 'AAPL', 'MSFT', 'TSLA')
|
|
1987
|
+
*
|
|
1988
|
+
* @returns Promise resolving to array of executive compensation data with detailed pay information
|
|
1989
|
+
*
|
|
1990
|
+
* @example
|
|
1991
|
+
* ```typescript
|
|
1992
|
+
* // Get Apple's executive compensation
|
|
1993
|
+
* const compensation = await fmp.company.getExecutiveCompensation('AAPL');
|
|
1994
|
+
* compensation.data.forEach(exec => {
|
|
1995
|
+
* console.log(`${exec.name} (${exec.title}):`);
|
|
1996
|
+
* console.log(` Salary: $${exec.salary.toLocaleString()}`);
|
|
1997
|
+
* console.log(` Bonus: $${exec.bonus.toLocaleString()}`);
|
|
1998
|
+
* console.log(` Stock Options: $${exec.stockAwards.toLocaleString()}`);
|
|
1999
|
+
* });
|
|
2000
|
+
*
|
|
2001
|
+
* // Get Tesla's executive compensation
|
|
2002
|
+
* const teslaComp = await fmp.company.getExecutiveCompensation('TSLA');
|
|
2003
|
+
* ```
|
|
2004
|
+
*
|
|
2005
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#executive-compensation-company-information|FMP Executive Compensation Documentation}
|
|
939
2006
|
*/
|
|
940
|
-
async
|
|
941
|
-
|
|
942
|
-
return this.client.get(`/company-notes`, "v4", params);
|
|
2007
|
+
async getExecutiveCompensation(symbol) {
|
|
2008
|
+
return this.client.get(`/governance/executive_compensation`, "v4", { symbol });
|
|
943
2009
|
}
|
|
944
2010
|
/**
|
|
945
|
-
* Get
|
|
946
|
-
*
|
|
947
|
-
*
|
|
948
|
-
*
|
|
2011
|
+
* Get company notes and financial disclosures
|
|
2012
|
+
*
|
|
2013
|
+
* Provides important notes and disclosures from company financial statements.
|
|
2014
|
+
* These notes contain critical information about accounting policies, risks,
|
|
2015
|
+
* contingencies, and other material information that affects financial analysis.
|
|
2016
|
+
*
|
|
2017
|
+
* @param symbol - The stock symbol to get notes for (e.g., 'AAPL', 'MSFT', 'JPM')
|
|
2018
|
+
*
|
|
2019
|
+
* @returns Promise resolving to array of company notes with detailed disclosure information
|
|
2020
|
+
*
|
|
2021
|
+
* @example
|
|
2022
|
+
* ```typescript
|
|
2023
|
+
* // Get Apple's company notes
|
|
2024
|
+
* const notes = await fmp.company.getCompanyNotes('AAPL');
|
|
2025
|
+
* notes.data.forEach(note => {
|
|
2026
|
+
* console.log(`Note ${note.noteNumber}: ${note.noteTitle}`);
|
|
2027
|
+
* console.log(` Content: ${note.noteContent.substring(0, 100)}...`);
|
|
2028
|
+
* });
|
|
2029
|
+
*
|
|
2030
|
+
* // Get JPMorgan's notes
|
|
2031
|
+
* const jpmNotes = await fmp.company.getCompanyNotes('JPM');
|
|
2032
|
+
* ```
|
|
2033
|
+
*
|
|
2034
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#company-notes-company-information|FMP Company Notes Documentation}
|
|
949
2035
|
*/
|
|
950
|
-
async
|
|
951
|
-
symbol
|
|
952
|
-
}) {
|
|
953
|
-
const params = { symbol };
|
|
954
|
-
return this.client.get(`/historical/employee_count`, "v4", params);
|
|
2036
|
+
async getCompanyNotes(symbol) {
|
|
2037
|
+
return this.client.get(`/company-notes`, "v4", { symbol });
|
|
955
2038
|
}
|
|
956
2039
|
/**
|
|
957
|
-
* Get
|
|
958
|
-
*
|
|
959
|
-
*
|
|
960
|
-
*
|
|
2040
|
+
* Get historical employee count data
|
|
2041
|
+
*
|
|
2042
|
+
* Provides historical data on company employee counts over time.
|
|
2043
|
+
* Useful for analyzing company growth, operational efficiency, and workforce trends.
|
|
2044
|
+
* Employee count is often a key indicator of company expansion or contraction.
|
|
2045
|
+
*
|
|
2046
|
+
* @param symbol - The stock symbol to get historical employee count for (e.g., 'AAPL', 'MSFT', 'AMZN')
|
|
2047
|
+
*
|
|
2048
|
+
* @returns Promise resolving to array of historical employee count data with year-by-year information
|
|
2049
|
+
*
|
|
2050
|
+
* @example
|
|
2051
|
+
* ```typescript
|
|
2052
|
+
* // Get Apple's employee count history
|
|
2053
|
+
* const employees = await fmp.company.getHistoricalEmployeeCount('AAPL');
|
|
2054
|
+
* employees.data.forEach(year => {
|
|
2055
|
+
* console.log(`${year.year}: ${year.employeeCount.toLocaleString()} employees`);
|
|
2056
|
+
* });
|
|
2057
|
+
*
|
|
2058
|
+
* // Get Amazon's employee growth
|
|
2059
|
+
* const amazonEmployees = await fmp.company.getHistoricalEmployeeCount('AMZN');
|
|
2060
|
+
* ```
|
|
2061
|
+
*
|
|
2062
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#historical-employee-company-information|FMP Historical Employee Count Documentation}
|
|
961
2063
|
*/
|
|
962
|
-
async
|
|
963
|
-
|
|
964
|
-
return this.client.getSingle(`/shares_float`, "v4", params);
|
|
2064
|
+
async getHistoricalEmployeeCount(symbol) {
|
|
2065
|
+
return this.client.get(`/historical/employee_count`, "v4", { symbol });
|
|
965
2066
|
}
|
|
966
2067
|
/**
|
|
967
|
-
* Get
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
*
|
|
2068
|
+
* Get current shares float information
|
|
2069
|
+
*
|
|
2070
|
+
* Provides the total number of shares that are publicly traded (float) for a company.
|
|
2071
|
+
* The float is calculated by subtracting restricted shares from total outstanding shares.
|
|
2072
|
+
* Important for understanding liquidity, volatility, and trading dynamics.
|
|
2073
|
+
*
|
|
2074
|
+
* @param symbol - The stock symbol to get shares float for (e.g., 'AAPL', 'TSLA', 'NVDA')
|
|
2075
|
+
*
|
|
2076
|
+
* @returns Promise resolving to shares float data with current float information
|
|
2077
|
+
*
|
|
2078
|
+
* @example
|
|
2079
|
+
* ```typescript
|
|
2080
|
+
* // Get Apple's shares float
|
|
2081
|
+
* const float = await fmp.company.getSharesFloat('AAPL');
|
|
2082
|
+
* console.log(`Float: ${float.data.sharesFloat.toLocaleString()} shares`);
|
|
2083
|
+
* console.log(`Outstanding: ${float.data.sharesOutstanding.toLocaleString()} shares`);
|
|
2084
|
+
* console.log(`Restricted: ${float.data.restrictedShares.toLocaleString()} shares`);
|
|
2085
|
+
*
|
|
2086
|
+
* // Get Tesla's float
|
|
2087
|
+
* const teslaFloat = await fmp.company.getSharesFloat('TSLA');
|
|
2088
|
+
* ```
|
|
2089
|
+
*
|
|
2090
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#company-share-float-share-float|FMP Shares Float Documentation}
|
|
971
2091
|
*/
|
|
972
|
-
async
|
|
973
|
-
symbol
|
|
974
|
-
}) {
|
|
975
|
-
const params = { symbol };
|
|
976
|
-
return this.client.get(`/historical/shares_float`, "v4", params);
|
|
2092
|
+
async getSharesFloat(symbol) {
|
|
2093
|
+
return this.client.getSingle(`/shares_float`, "v4", { symbol });
|
|
977
2094
|
}
|
|
978
2095
|
/**
|
|
979
|
-
* Get
|
|
980
|
-
*
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
*
|
|
984
|
-
*
|
|
2096
|
+
* Get historical shares float data
|
|
2097
|
+
*
|
|
2098
|
+
* Provides historical data on company shares float over time.
|
|
2099
|
+
* Useful for analyzing changes in liquidity, share issuance, and corporate actions
|
|
2100
|
+
* that affect the number of publicly traded shares.
|
|
2101
|
+
*
|
|
2102
|
+
* @param symbol - The stock symbol to get historical shares float for (e.g., 'AAPL', 'TSLA', 'NVDA')
|
|
2103
|
+
*
|
|
2104
|
+
* @returns Promise resolving to array of historical shares float data with date-by-date information
|
|
2105
|
+
*
|
|
2106
|
+
* @example
|
|
2107
|
+
* ```typescript
|
|
2108
|
+
* // Get Apple's historical float
|
|
2109
|
+
* const historicalFloat = await fmp.company.getHistoricalSharesFloat('AAPL');
|
|
2110
|
+
* historicalFloat.data.forEach(entry => {
|
|
2111
|
+
* console.log(`${entry.date}: ${entry.sharesFloat.toLocaleString()} shares`);
|
|
2112
|
+
* });
|
|
2113
|
+
*
|
|
2114
|
+
* // Get Tesla's float history
|
|
2115
|
+
* const teslaHistory = await fmp.company.getHistoricalSharesFloat('TSLA');
|
|
2116
|
+
* ```
|
|
2117
|
+
*
|
|
2118
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#company-historical-share-float|FMP Historical Shares Float Documentation}
|
|
985
2119
|
*/
|
|
986
|
-
async
|
|
987
|
-
symbol
|
|
988
|
-
year,
|
|
989
|
-
quarter
|
|
990
|
-
}) {
|
|
991
|
-
const params = { year, quarter };
|
|
992
|
-
return this.client.getSingle(`/earning_call_transcript/${symbol}`, "v3", params);
|
|
2120
|
+
async getHistoricalSharesFloat(symbol) {
|
|
2121
|
+
return this.client.get(`/historical/shares_float`, "v4", { symbol });
|
|
993
2122
|
}
|
|
994
2123
|
/**
|
|
995
|
-
* Get
|
|
996
|
-
*
|
|
997
|
-
*
|
|
998
|
-
*
|
|
2124
|
+
* Get earnings call transcript for specific quarter
|
|
2125
|
+
*
|
|
2126
|
+
* Provides the full transcript of a company's earnings conference call.
|
|
2127
|
+
* Contains detailed Q&A sessions, management commentary, and insights into
|
|
2128
|
+
* company performance, strategy, and future outlook.
|
|
2129
|
+
*
|
|
2130
|
+
* @param params - Earnings call transcript request parameters
|
|
2131
|
+
* @param params.symbol - The stock symbol to get transcript for (e.g., 'AAPL', 'MSFT', 'TSLA')
|
|
2132
|
+
* @param params.year - The year of the earnings call (e.g., 2024)
|
|
2133
|
+
* @param params.quarter - The quarter of the earnings call (1, 2, 3, or 4)
|
|
2134
|
+
*
|
|
2135
|
+
* @returns Promise resolving to earnings call transcript with full text content
|
|
2136
|
+
*
|
|
2137
|
+
* @example
|
|
2138
|
+
* ```typescript
|
|
2139
|
+
* // Get Apple's Q1 2024 earnings call
|
|
2140
|
+
* const transcript = await fmp.company.getEarningsCallTranscript({
|
|
2141
|
+
* symbol: 'AAPL',
|
|
2142
|
+
* year: 2024,
|
|
2143
|
+
* quarter: 1
|
|
2144
|
+
* });
|
|
2145
|
+
* console.log(`Transcript: ${transcript.data[0].content.substring(0, 200)}...`);
|
|
2146
|
+
*
|
|
2147
|
+
* // Get Tesla's Q4 2023 earnings call
|
|
2148
|
+
* const teslaTranscript = await fmp.company.getEarningsCallTranscript({
|
|
2149
|
+
* symbol: 'TSLA',
|
|
2150
|
+
* year: 2023,
|
|
2151
|
+
* quarter: 4
|
|
2152
|
+
* });
|
|
2153
|
+
* ```
|
|
2154
|
+
*
|
|
2155
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-transcript-earnings-transcripts|FMP Earnings Call Transcript Documentation}
|
|
999
2156
|
*/
|
|
1000
|
-
async
|
|
1001
|
-
symbol
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
2157
|
+
async getEarningsCallTranscript(params) {
|
|
2158
|
+
const { symbol, year, quarter } = params;
|
|
2159
|
+
return this.client.getSingle(`/earning_call_transcript/${symbol}`, "v3", { year, quarter });
|
|
2160
|
+
}
|
|
2161
|
+
/**
|
|
2162
|
+
* Get available earnings call transcript dates
|
|
2163
|
+
*
|
|
2164
|
+
* Provides a list of all available earnings call transcript dates for a company.
|
|
2165
|
+
* Useful for discovering which quarters have transcripts available before
|
|
2166
|
+
* requesting the full transcript content.
|
|
2167
|
+
*
|
|
2168
|
+
* @param symbol - The stock symbol to get transcript dates for (e.g., 'AAPL', 'MSFT', 'TSLA')
|
|
2169
|
+
*
|
|
2170
|
+
* @returns Promise resolving to array of available transcript dates with quarter information
|
|
2171
|
+
*
|
|
2172
|
+
* @example
|
|
2173
|
+
* ```typescript
|
|
2174
|
+
* // Get Apple's available transcript dates
|
|
2175
|
+
* const transcriptDates = await fmp.company.getCompanyTranscriptData('AAPL');
|
|
2176
|
+
* transcriptDates.data.forEach(date => {
|
|
2177
|
+
* console.log(`Q${date.quarter} ${date.year}: ${date.date}`);
|
|
2178
|
+
* });
|
|
2179
|
+
*
|
|
2180
|
+
* // Get Microsoft's transcript availability
|
|
2181
|
+
* const msftDates = await fmp.company.getCompanyTranscriptData('MSFT');
|
|
2182
|
+
* ```
|
|
2183
|
+
*
|
|
2184
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#transcript-dates-earnings-transcripts|FMP Company Transcript Data Documentation}
|
|
2185
|
+
*/
|
|
2186
|
+
async getCompanyTranscriptData(symbol) {
|
|
2187
|
+
return this.client.getSingle(`/earning_call_transcript`, "v4", { symbol });
|
|
1005
2188
|
}
|
|
1006
2189
|
};
|
|
1007
2190
|
|
|
@@ -1011,18 +2194,58 @@ var QuoteEndpoints = class {
|
|
|
1011
2194
|
this.client = client;
|
|
1012
2195
|
}
|
|
1013
2196
|
/**
|
|
1014
|
-
* Get quote for any asset type (
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
2197
|
+
* Get real-time quote data for any asset type (stocks, crypto, forex, commodities, ETFs)
|
|
2198
|
+
*
|
|
2199
|
+
* This endpoint provides current market data including price, volume, market cap, and key metrics.
|
|
2200
|
+
* Works with any valid symbol across all supported asset classes.
|
|
2201
|
+
*
|
|
2202
|
+
* @param symbol - The trading symbol (e.g., 'AAPL', 'BTCUSD', 'EURUSD', 'GCUSD', 'SPY')
|
|
2203
|
+
*
|
|
2204
|
+
* @returns Promise resolving to quote data with current price, volume, market cap, and performance metrics
|
|
2205
|
+
*
|
|
2206
|
+
* @example
|
|
2207
|
+
* ```typescript
|
|
2208
|
+
* // Get stock quote
|
|
2209
|
+
* const aaplQuote = await fmp.quote.getQuote('AAPL');
|
|
2210
|
+
*
|
|
2211
|
+
* // Get crypto quote
|
|
2212
|
+
* const btcQuote = await fmp.quote.getQuote('BTCUSD');
|
|
2213
|
+
*
|
|
2214
|
+
* // Get forex quote
|
|
2215
|
+
* const eurQuote = await fmp.quote.getQuote('EURUSD');
|
|
2216
|
+
* ```
|
|
1017
2217
|
*/
|
|
1018
|
-
async getQuote(
|
|
1019
|
-
const { symbol } = params;
|
|
2218
|
+
async getQuote(symbol) {
|
|
1020
2219
|
return this.client.getSingle(`/quote/${symbol}`, "v3");
|
|
1021
2220
|
}
|
|
1022
2221
|
/**
|
|
1023
|
-
* Get historical
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
2222
|
+
* Get historical price data for any asset type with customizable date range
|
|
2223
|
+
*
|
|
2224
|
+
* Retrieves daily OHLCV (Open, High, Low, Close, Volume) data for the specified symbol.
|
|
2225
|
+
* Data includes adjusted close prices, volume, and percentage changes.
|
|
2226
|
+
*
|
|
2227
|
+
* @param params - Historical price request parameters
|
|
2228
|
+
* @param params.symbol - The trading symbol to get historical data for
|
|
2229
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional, defaults to 1 year ago)
|
|
2230
|
+
* @param params.to - End date in YYYY-MM-DD format (optional, defaults to today)
|
|
2231
|
+
*
|
|
2232
|
+
* @returns Promise resolving to historical price data with daily OHLCV information
|
|
2233
|
+
*
|
|
2234
|
+
* @example
|
|
2235
|
+
* ```typescript
|
|
2236
|
+
* // Get last year's data
|
|
2237
|
+
* const history = await fmp.quote.getHistoricalPrice({
|
|
2238
|
+
* symbol: 'AAPL',
|
|
2239
|
+
* from: '2023-01-01',
|
|
2240
|
+
* to: '2023-12-31'
|
|
2241
|
+
* });
|
|
2242
|
+
*
|
|
2243
|
+
* // Get recent data (last 30 days)
|
|
2244
|
+
* const recent = await fmp.quote.getHistoricalPrice({
|
|
2245
|
+
* symbol: 'BTCUSD',
|
|
2246
|
+
* from: '2024-01-01'
|
|
2247
|
+
* });
|
|
2248
|
+
* ```
|
|
1026
2249
|
*/
|
|
1027
2250
|
async getHistoricalPrice(params) {
|
|
1028
2251
|
const { symbol, from, to } = params;
|
|
@@ -1032,18 +2255,66 @@ var QuoteEndpoints = class {
|
|
|
1032
2255
|
return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", queryParams);
|
|
1033
2256
|
}
|
|
1034
2257
|
/**
|
|
1035
|
-
* Get
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
2258
|
+
* Get real-time quotes for multiple symbols in a single request
|
|
2259
|
+
*
|
|
2260
|
+
* Efficiently retrieve quote data for multiple assets across different asset classes.
|
|
2261
|
+
* Useful for portfolio tracking, market monitoring, or batch data collection.
|
|
2262
|
+
*
|
|
2263
|
+
* @param symbols - Array of trading symbols to get quotes for
|
|
2264
|
+
*
|
|
2265
|
+
* @returns Promise resolving to an array of quote data for all requested symbols
|
|
2266
|
+
*
|
|
2267
|
+
* @example
|
|
2268
|
+
* ```typescript
|
|
2269
|
+
* // Get quotes for a mixed portfolio
|
|
2270
|
+
* const quotes = await fmp.quote.getQuotes([
|
|
2271
|
+
* 'AAPL', // Stock
|
|
2272
|
+
* 'BTCUSD', // Crypto
|
|
2273
|
+
* 'EURUSD', // Forex
|
|
2274
|
+
* 'SPY' // ETF
|
|
2275
|
+
* ]);
|
|
2276
|
+
*
|
|
2277
|
+
* // Get quotes for tech stocks
|
|
2278
|
+
* const techQuotes = await fmp.quote.getQuotes([
|
|
2279
|
+
* 'AAPL', 'MSFT', 'GOOGL', 'AMZN', 'TSLA'
|
|
2280
|
+
* ]);
|
|
2281
|
+
* ```
|
|
1038
2282
|
*/
|
|
1039
2283
|
async getQuotes(symbols) {
|
|
1040
2284
|
const symbolsParam = symbols.join(",");
|
|
1041
2285
|
return this.client.get(`/quote/${symbolsParam}`, "v3");
|
|
1042
2286
|
}
|
|
1043
2287
|
/**
|
|
1044
|
-
* Get intraday data
|
|
1045
|
-
*
|
|
1046
|
-
*
|
|
2288
|
+
* Get intraday price data with customizable time intervals
|
|
2289
|
+
*
|
|
2290
|
+
* Retrieves intraday OHLCV data at specified intervals (1min to 4hour).
|
|
2291
|
+
* Perfect for technical analysis, day trading, or short-term price monitoring.
|
|
2292
|
+
*
|
|
2293
|
+
* @param params - Intraday request parameters
|
|
2294
|
+
* @param params.symbol - The trading symbol to get intraday data for
|
|
2295
|
+
* @param params.interval - Time interval: '1min', '5min', '15min', '30min', '1hour', or '4hour'
|
|
2296
|
+
* @param params.from - Start date in YYYY-MM-DD format (optional)
|
|
2297
|
+
* @param params.to - End date in YYYY-MM-DD format (optional)
|
|
2298
|
+
*
|
|
2299
|
+
* @returns Promise resolving to intraday price data with OHLCV information at specified intervals
|
|
2300
|
+
*
|
|
2301
|
+
* @example
|
|
2302
|
+
* ```typescript
|
|
2303
|
+
* // Get 5-minute intraday data for today
|
|
2304
|
+
* const intraday = await fmp.quote.getIntraday({
|
|
2305
|
+
* symbol: 'AAPL',
|
|
2306
|
+
* interval: '5min',
|
|
2307
|
+
* from: '2024-01-15'
|
|
2308
|
+
* });
|
|
2309
|
+
*
|
|
2310
|
+
* // Get 1-hour data for crypto
|
|
2311
|
+
* const cryptoIntraday = await fmp.quote.getIntraday({
|
|
2312
|
+
* symbol: 'BTCUSD',
|
|
2313
|
+
* interval: '1hour',
|
|
2314
|
+
* from: '2024-01-10',
|
|
2315
|
+
* to: '2024-01-15'
|
|
2316
|
+
* });
|
|
2317
|
+
* ```
|
|
1047
2318
|
*/
|
|
1048
2319
|
async getIntraday(params) {
|
|
1049
2320
|
const { symbol, interval, from, to } = params;
|
|
@@ -1060,56 +2331,202 @@ var SenateHouseEndpoints = class {
|
|
|
1060
2331
|
this.client = client;
|
|
1061
2332
|
}
|
|
1062
2333
|
/**
|
|
1063
|
-
* Get senate trading data
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
2334
|
+
* Get senate trading data for a specific stock symbol
|
|
2335
|
+
*
|
|
2336
|
+
* Provides detailed information about senate members' trading activities for a specific stock.
|
|
2337
|
+
* Includes transaction details, amounts, dates, and ownership information for transparency
|
|
2338
|
+
* and compliance with the STOCK Act (Stop Trading on Congressional Knowledge).
|
|
2339
|
+
*
|
|
2340
|
+
* @param params - Senate trading request parameters
|
|
2341
|
+
* @param params.symbol - The stock symbol to get senate trading data for (e.g., 'AAPL', 'MSFT', 'TSLA')
|
|
2342
|
+
*
|
|
2343
|
+
* @returns Promise resolving to array of senate trading data with transaction details
|
|
2344
|
+
*
|
|
2345
|
+
* @example
|
|
2346
|
+
* ```typescript
|
|
2347
|
+
* // Get senate trading data for Apple
|
|
2348
|
+
* const appleSenateTrading = await fmp.senateHouse.getSenateTrading({ symbol: 'AAPL' });
|
|
2349
|
+
* appleSenateTrading.data.forEach(trade => {
|
|
2350
|
+
* console.log(`${trade.firstName} ${trade.lastName} (${trade.office}):`);
|
|
2351
|
+
* console.log(` ${trade.type} ${trade.amount} of ${trade.assetDescription}`);
|
|
2352
|
+
* console.log(` Transaction Date: ${trade.transactionDate}`);
|
|
2353
|
+
* });
|
|
2354
|
+
*
|
|
2355
|
+
* // Get senate trading data for Tesla
|
|
2356
|
+
* const teslaSenateTrading = await fmp.senateHouse.getSenateTrading({ symbol: 'TSLA' });
|
|
2357
|
+
* ```
|
|
2358
|
+
*
|
|
2359
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#senate-trading|FMP Senate Trading Documentation}
|
|
1067
2360
|
*/
|
|
1068
2361
|
async getSenateTrading(params) {
|
|
1069
2362
|
const { symbol } = params;
|
|
1070
2363
|
return this.client.get(`/senate-trading`, "v4", { symbol });
|
|
1071
2364
|
}
|
|
1072
|
-
/**
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
|
-
*
|
|
2365
|
+
/**
|
|
2366
|
+
* Get senate trading RSS feed with pagination
|
|
2367
|
+
*
|
|
2368
|
+
* Provides a paginated RSS feed of all senate trading activities across all stocks.
|
|
2369
|
+
* Useful for monitoring congressional trading activities, compliance tracking,
|
|
2370
|
+
* and transparency reporting. Returns recent trading disclosures from senate members.
|
|
2371
|
+
*
|
|
2372
|
+
* @param params - Senate trading RSS feed request parameters
|
|
2373
|
+
* @param params.page - The page number to retrieve (starts from 0)
|
|
2374
|
+
*
|
|
2375
|
+
* @returns Promise resolving to array of senate trading data from RSS feed
|
|
2376
|
+
*
|
|
2377
|
+
* @example
|
|
2378
|
+
* ```typescript
|
|
2379
|
+
* // Get first page of senate trading RSS feed
|
|
2380
|
+
* const firstPage = await fmp.senateHouse.getSenateTradingRSSFeed({ page: 0 });
|
|
2381
|
+
* console.log(`First page: ${firstPage.data.length} trading activities`);
|
|
2382
|
+
*
|
|
2383
|
+
* // Get second page of senate trading RSS feed
|
|
2384
|
+
* const secondPage = await fmp.senateHouse.getSenateTradingRSSFeed({ page: 1 });
|
|
2385
|
+
* console.log(`Second page: ${secondPage.data.length} trading activities`);
|
|
2386
|
+
*
|
|
2387
|
+
* // Get recent senate trading activities
|
|
2388
|
+
* const recentTrades = await fmp.senateHouse.getSenateTradingRSSFeed({ page: 0 });
|
|
2389
|
+
* recentTrades.data.forEach(trade => {
|
|
2390
|
+
* console.log(`${trade.firstName} ${trade.lastName}: ${trade.type} ${trade.amount}`);
|
|
2391
|
+
* });
|
|
2392
|
+
* ```
|
|
2393
|
+
*
|
|
2394
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#senate-trading-rss-feed-senate|FMP Senate Trading RSS Feed Documentation}
|
|
1076
2395
|
*/
|
|
1077
2396
|
async getSenateTradingRSSFeed(params) {
|
|
1078
2397
|
const { page } = params;
|
|
1079
2398
|
return this.client.get("/senate-trading-rss-feed", "v4", { page });
|
|
1080
2399
|
}
|
|
1081
|
-
/**
|
|
1082
|
-
*
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
2400
|
+
/**
|
|
2401
|
+
* Get senate trading data for a specific senator by name
|
|
2402
|
+
*
|
|
2403
|
+
* Provides detailed trading activities for a specific senate member across all stocks.
|
|
2404
|
+
* Useful for tracking individual senator's trading patterns, compliance monitoring,
|
|
2405
|
+
* and transparency reporting. Returns all trading disclosures for the specified senator.
|
|
2406
|
+
*
|
|
2407
|
+
* @param params - Senate trading by name request parameters
|
|
2408
|
+
* @param params.name - The name of the senator to get trading data for (e.g., 'John Smith', 'Jane Doe')
|
|
2409
|
+
*
|
|
2410
|
+
* @returns Promise resolving to array of senate trading data for the specified senator
|
|
2411
|
+
*
|
|
2412
|
+
* @example
|
|
2413
|
+
* ```typescript
|
|
2414
|
+
* // Get trading data for Senator John Smith
|
|
2415
|
+
* const johnSmithTrades = await fmp.senateHouse.getSenateTradingByName({ name: 'John Smith' });
|
|
2416
|
+
* johnSmithTrades.data.forEach(trade => {
|
|
2417
|
+
* console.log(`${trade.symbol}: ${trade.type} ${trade.amount}`);
|
|
2418
|
+
* console.log(` Transaction Date: ${trade.transactionDate}`);
|
|
2419
|
+
* console.log(` Asset: ${trade.assetDescription}`);
|
|
2420
|
+
* });
|
|
2421
|
+
*
|
|
2422
|
+
* // Get trading data for Senator Jane Doe
|
|
2423
|
+
* const janeDoeTrades = await fmp.senateHouse.getSenateTradingByName({ name: 'Jane Doe' });
|
|
2424
|
+
* console.log(`Jane Doe has ${janeDoeTrades.data.length} trading activities`);
|
|
2425
|
+
* ```
|
|
2426
|
+
*
|
|
2427
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs/stable#senate-trading-by-name|FMP Senate Trading by Name Documentation}
|
|
1085
2428
|
*/
|
|
1086
2429
|
async getSenateTradingByName(params) {
|
|
1087
2430
|
const { name } = params;
|
|
1088
2431
|
return this.client.get("/senate-trades-by-name", "stable", { name });
|
|
1089
2432
|
}
|
|
1090
2433
|
/**
|
|
1091
|
-
* Get house trading data
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
2434
|
+
* Get house trading data for a specific stock symbol
|
|
2435
|
+
*
|
|
2436
|
+
* Provides detailed information about house representatives' trading activities for a specific stock.
|
|
2437
|
+
* Includes transaction details, amounts, dates, and district information for transparency
|
|
2438
|
+
* and compliance with the STOCK Act (Stop Trading on Congressional Knowledge).
|
|
2439
|
+
*
|
|
2440
|
+
* @param params - House trading request parameters
|
|
2441
|
+
* @param params.symbol - The stock symbol to get house trading data for (e.g., 'AAPL', 'MSFT', 'TSLA')
|
|
2442
|
+
*
|
|
2443
|
+
* @returns Promise resolving to array of house trading data with transaction details
|
|
2444
|
+
*
|
|
2445
|
+
* @example
|
|
2446
|
+
* ```typescript
|
|
2447
|
+
* // Get house trading data for Apple
|
|
2448
|
+
* const appleHouseTrading = await fmp.senateHouse.getHouseTrading({ symbol: 'AAPL' });
|
|
2449
|
+
* appleHouseTrading.data.forEach(trade => {
|
|
2450
|
+
* console.log(`${trade.representative} (District ${trade.district}):`);
|
|
2451
|
+
* console.log(` ${trade.type} ${trade.amount} of ${trade.assetDescription}`);
|
|
2452
|
+
* console.log(` Transaction Date: ${trade.transactionDate}`);
|
|
2453
|
+
* });
|
|
2454
|
+
*
|
|
2455
|
+
* // Get house trading data for Microsoft
|
|
2456
|
+
* const msftHouseTrading = await fmp.senateHouse.getHouseTrading({ symbol: 'MSFT' });
|
|
2457
|
+
* console.log(`Microsoft house trading activities: ${msftHouseTrading.data.length}`);
|
|
2458
|
+
* ```
|
|
2459
|
+
*
|
|
2460
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#house-disclosure|FMP House Trading Documentation}
|
|
1095
2461
|
*/
|
|
1096
2462
|
async getHouseTrading(params) {
|
|
1097
2463
|
const { symbol } = params;
|
|
1098
2464
|
return this.client.get("/senate-disclosure", "v4", { symbol });
|
|
1099
2465
|
}
|
|
1100
|
-
/**
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
*
|
|
2466
|
+
/**
|
|
2467
|
+
* Get house trading RSS feed with pagination
|
|
2468
|
+
*
|
|
2469
|
+
* Provides a paginated RSS feed of all house trading activities across all stocks.
|
|
2470
|
+
* Useful for monitoring congressional trading activities, compliance tracking,
|
|
2471
|
+
* and transparency reporting. Returns recent trading disclosures from house representatives.
|
|
2472
|
+
*
|
|
2473
|
+
* @param params - House trading RSS feed request parameters
|
|
2474
|
+
* @param params.page - The page number to retrieve (starts from 0)
|
|
2475
|
+
*
|
|
2476
|
+
* @returns Promise resolving to array of house trading data from RSS feed
|
|
2477
|
+
*
|
|
2478
|
+
* @example
|
|
2479
|
+
* ```typescript
|
|
2480
|
+
* // Get first page of house trading RSS feed
|
|
2481
|
+
* const firstPage = await fmp.senateHouse.getHouseTradingRSSFeed({ page: 0 });
|
|
2482
|
+
* console.log(`First page: ${firstPage.data.length} trading activities`);
|
|
2483
|
+
*
|
|
2484
|
+
* // Get second page of house trading RSS feed
|
|
2485
|
+
* const secondPage = await fmp.senateHouse.getHouseTradingRSSFeed({ page: 1 });
|
|
2486
|
+
* console.log(`Second page: ${secondPage.data.length} trading activities`);
|
|
2487
|
+
*
|
|
2488
|
+
* // Get recent house trading activities
|
|
2489
|
+
* const recentTrades = await fmp.senateHouse.getHouseTradingRSSFeed({ page: 0 });
|
|
2490
|
+
* recentTrades.data.forEach(trade => {
|
|
2491
|
+
* console.log(`${trade.representative} (District ${trade.district}): ${trade.type} ${trade.amount}`);
|
|
2492
|
+
* });
|
|
2493
|
+
* ```
|
|
2494
|
+
*
|
|
2495
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#house-disclosure-rss-feed-senate|FMP House Trading RSS Feed Documentation}
|
|
1104
2496
|
*/
|
|
1105
2497
|
async getHouseTradingRSSFeed(params) {
|
|
1106
2498
|
const { page } = params;
|
|
1107
2499
|
return this.client.get("/senate-disclosure-rss-feed", "v4", { page });
|
|
1108
2500
|
}
|
|
1109
|
-
/**
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
2501
|
+
/**
|
|
2502
|
+
* Get house trading data for a specific representative by name
|
|
2503
|
+
*
|
|
2504
|
+
* Provides detailed trading activities for a specific house representative across all stocks.
|
|
2505
|
+
* Useful for tracking individual representative's trading patterns, compliance monitoring,
|
|
2506
|
+
* and transparency reporting. Returns all trading disclosures for the specified representative.
|
|
2507
|
+
*
|
|
2508
|
+
* @param params - House trading by name request parameters
|
|
2509
|
+
* @param params.name - The name of the representative to get trading data for (e.g., 'John Smith', 'Jane Doe')
|
|
2510
|
+
*
|
|
2511
|
+
* @returns Promise resolving to array of house trading data for the specified representative
|
|
2512
|
+
*
|
|
2513
|
+
* @example
|
|
2514
|
+
* ```typescript
|
|
2515
|
+
* // Get trading data for Representative John Smith
|
|
2516
|
+
* const johnSmithTrades = await fmp.senateHouse.getHouseTradingByName({ name: 'John Smith' });
|
|
2517
|
+
* johnSmithTrades.data.forEach(trade => {
|
|
2518
|
+
* console.log(`${trade.symbol}: ${trade.type} ${trade.amount}`);
|
|
2519
|
+
* console.log(` Transaction Date: ${trade.transactionDate}`);
|
|
2520
|
+
* console.log(` Asset: ${trade.assetDescription}`);
|
|
2521
|
+
* console.log(` District: ${trade.district}`);
|
|
2522
|
+
* });
|
|
2523
|
+
*
|
|
2524
|
+
* // Get trading data for Representative Jane Doe
|
|
2525
|
+
* const janeDoeTrades = await fmp.senateHouse.getHouseTradingByName({ name: 'Jane Doe' });
|
|
2526
|
+
* console.log(`Jane Doe has ${janeDoeTrades.data.length} trading activities`);
|
|
2527
|
+
* ```
|
|
2528
|
+
*
|
|
2529
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs/stable#house-trading-by-name|FMP House Trading by Name Documentation}
|
|
1113
2530
|
*/
|
|
1114
2531
|
async getHouseTradingByName(params) {
|
|
1115
2532
|
const { name } = params;
|
|
@@ -1117,23 +2534,856 @@ var SenateHouseEndpoints = class {
|
|
|
1117
2534
|
}
|
|
1118
2535
|
};
|
|
1119
2536
|
|
|
2537
|
+
// src/endpoints/institutional.ts
|
|
2538
|
+
var InstitutionalEndpoints = class {
|
|
2539
|
+
constructor(client) {
|
|
2540
|
+
this.client = client;
|
|
2541
|
+
}
|
|
2542
|
+
/**
|
|
2543
|
+
* Get Form 13F institutional stock ownership data
|
|
2544
|
+
*
|
|
2545
|
+
* Provides Form 13F institutional stock ownership data for investment
|
|
2546
|
+
* managers with over $100 million in assets under management. Essential
|
|
2547
|
+
* for analyzing institutional investment patterns and holdings.
|
|
2548
|
+
*
|
|
2549
|
+
* @param params - Form 13F request parameters
|
|
2550
|
+
* @param params.cik - Central Index Key (CIK) of the investment manager
|
|
2551
|
+
* @param params.date - Specific date in YYYY-MM-DD format (optional, defaults to most recent filing)
|
|
2552
|
+
*
|
|
2553
|
+
* @returns Promise resolving to array of Form 13F institutional ownership data
|
|
2554
|
+
*
|
|
2555
|
+
* @example
|
|
2556
|
+
* ```typescript
|
|
2557
|
+
* // Get Berkshire Hathaway's Form 13F data
|
|
2558
|
+
* const berkshire13F = await fmp.institutional.getForm13F({
|
|
2559
|
+
* cik: '0001067983'
|
|
2560
|
+
* });
|
|
2561
|
+
* berkshire13F.data.forEach(holding => {
|
|
2562
|
+
* console.log(`${holding.issuerName}: ${holding.value.toLocaleString()} shares, $${holding.value.toLocaleString()}`);
|
|
2563
|
+
* });
|
|
2564
|
+
*
|
|
2565
|
+
* // Get Form 13F data for specific date
|
|
2566
|
+
* const historical13F = await fmp.institutional.getForm13F({
|
|
2567
|
+
* cik: '0001067983',
|
|
2568
|
+
* date: '2023-12-31'
|
|
2569
|
+
* });
|
|
2570
|
+
*
|
|
2571
|
+
* // Get BlackRock's Form 13F data
|
|
2572
|
+
* const blackrock13F = await fmp.institutional.getForm13F({
|
|
2573
|
+
* cik: '0001364742'
|
|
2574
|
+
* });
|
|
2575
|
+
* ```
|
|
2576
|
+
*
|
|
2577
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#form-13f-13f---institutional-stock-ownership|FMP Form 13F Documentation}
|
|
2578
|
+
*/
|
|
2579
|
+
async getForm13F(params) {
|
|
2580
|
+
const { cik, date } = params;
|
|
2581
|
+
const queryParams = {};
|
|
2582
|
+
if (date) queryParams.date = date;
|
|
2583
|
+
return this.client.get(`/form-thirteen/${cik}`, "v3", queryParams);
|
|
2584
|
+
}
|
|
2585
|
+
/**
|
|
2586
|
+
* Get Form 13F filing dates for an investment manager
|
|
2587
|
+
*
|
|
2588
|
+
* Provides available filing dates for Form 13F submissions by a specific
|
|
2589
|
+
* investment manager. Essential for discovering historical filing dates
|
|
2590
|
+
* before requesting detailed Form 13F data.
|
|
2591
|
+
*
|
|
2592
|
+
* @param params - Form 13F dates request parameters
|
|
2593
|
+
* @param params.cik - Central Index Key (CIK) of the investment manager
|
|
2594
|
+
*
|
|
2595
|
+
* @returns Promise resolving to array of available Form 13F filing dates
|
|
2596
|
+
*
|
|
2597
|
+
* @example
|
|
2598
|
+
* ```typescript
|
|
2599
|
+
* // Get Berkshire Hathaway's Form 13F filing dates
|
|
2600
|
+
* const berkshireDates = await fmp.institutional.getForm13FDates({
|
|
2601
|
+
* cik: '0001067983'
|
|
2602
|
+
* });
|
|
2603
|
+
* berkshireDates.data.forEach(date => {
|
|
2604
|
+
* console.log(`Filing date: ${date}`);
|
|
2605
|
+
* });
|
|
2606
|
+
*
|
|
2607
|
+
* // Get BlackRock's filing dates
|
|
2608
|
+
* const blackrockDates = await fmp.institutional.getForm13FDates({
|
|
2609
|
+
* cik: '0001364742'
|
|
2610
|
+
* });
|
|
2611
|
+
* ```
|
|
2612
|
+
*
|
|
2613
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#form-13f-dates-13f---institutional-stock-ownership|FMP Form 13F Dates Documentation}
|
|
2614
|
+
*/
|
|
2615
|
+
async getForm13FDates(params) {
|
|
2616
|
+
const { cik } = params;
|
|
2617
|
+
return this.client.get(`/form-thirteen-date/${cik}`, "v3");
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
* Get institutional holders for a company
|
|
2621
|
+
*
|
|
2622
|
+
* Provides data on institutional investors holding shares in a specific
|
|
2623
|
+
* company. Essential for understanding institutional ownership patterns,
|
|
2624
|
+
* major shareholders, and investment sentiment.
|
|
2625
|
+
*
|
|
2626
|
+
* @param params - Institutional holders request parameters
|
|
2627
|
+
* @param params.symbol - Stock symbol to get institutional holders for
|
|
2628
|
+
*
|
|
2629
|
+
* @returns Promise resolving to array of institutional holders data
|
|
2630
|
+
*
|
|
2631
|
+
* @example
|
|
2632
|
+
* ```typescript
|
|
2633
|
+
* // Get Apple's institutional holders
|
|
2634
|
+
* const appleHolders = await fmp.institutional.getInstitutionalHolders({
|
|
2635
|
+
* symbol: 'AAPL'
|
|
2636
|
+
* });
|
|
2637
|
+
* appleHolders.data.forEach(holder => {
|
|
2638
|
+
* console.log(`${holder.holder}: ${holder.shares.toLocaleString()} shares (${holder.weight}%)`);
|
|
2639
|
+
* });
|
|
2640
|
+
*
|
|
2641
|
+
* // Get Microsoft's institutional holders
|
|
2642
|
+
* const msftHolders = await fmp.institutional.getInstitutionalHolders({
|
|
2643
|
+
* symbol: 'MSFT'
|
|
2644
|
+
* });
|
|
2645
|
+
*
|
|
2646
|
+
* // Get Tesla's institutional holders
|
|
2647
|
+
* const teslaHolders = await fmp.institutional.getInstitutionalHolders({
|
|
2648
|
+
* symbol: 'TSLA'
|
|
2649
|
+
* });
|
|
2650
|
+
* ```
|
|
2651
|
+
*
|
|
2652
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#institutional-holder-13f---institutional-stock-ownership|FMP Institutional Holders Documentation}
|
|
2653
|
+
*/
|
|
2654
|
+
async getInstitutionalHolders(params) {
|
|
2655
|
+
const { symbol } = params;
|
|
2656
|
+
return this.client.get(`/institutional-holder/${symbol}`, "v3");
|
|
2657
|
+
}
|
|
2658
|
+
};
|
|
2659
|
+
|
|
2660
|
+
// src/endpoints/insider.ts
|
|
2661
|
+
var InsiderEndpoints = class {
|
|
2662
|
+
constructor(client) {
|
|
2663
|
+
this.client = client;
|
|
2664
|
+
}
|
|
2665
|
+
/**
|
|
2666
|
+
* Get insider trading RSS feed data
|
|
2667
|
+
*
|
|
2668
|
+
* Provides real-time RSS feed of insider trading activities across all
|
|
2669
|
+
* publicly traded companies. Essential for monitoring insider trading
|
|
2670
|
+
* patterns, corporate governance, and potential market-moving events.
|
|
2671
|
+
*
|
|
2672
|
+
* @param params - RSS feed request parameters
|
|
2673
|
+
* @param params.page - Page number for pagination (default: 0)
|
|
2674
|
+
*
|
|
2675
|
+
* @returns Promise resolving to array of insider trading RSS feed data
|
|
2676
|
+
*
|
|
2677
|
+
* @example
|
|
2678
|
+
* ```typescript
|
|
2679
|
+
* // Get first page of insider trading RSS feed
|
|
2680
|
+
* const rssFeed = await fmp.insider.getInsiderTradingRSS({ page: 0 });
|
|
2681
|
+
* rssFeed.data.forEach(trade => {
|
|
2682
|
+
* console.log(`${trade.date}: ${trade.symbol} - ${trade.insiderName} ${trade.transactionType}`);
|
|
2683
|
+
* });
|
|
2684
|
+
*
|
|
2685
|
+
* // Get second page of RSS feed
|
|
2686
|
+
* const nextPage = await fmp.insider.getInsiderTradingRSS({ page: 1 });
|
|
2687
|
+
* ```
|
|
2688
|
+
*
|
|
2689
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#insider-trades-rss-insider-trading|FMP Insider Trading RSS Documentation}
|
|
2690
|
+
*/
|
|
2691
|
+
async getInsiderTradingRSS(params) {
|
|
2692
|
+
const { page = 0 } = params;
|
|
2693
|
+
return this.client.get(`/insider-trading-rss-feed`, "v4", { page });
|
|
2694
|
+
}
|
|
2695
|
+
/**
|
|
2696
|
+
* Search for insider trades with advanced filtering
|
|
2697
|
+
*
|
|
2698
|
+
* Provides comprehensive insider trading data with multiple filtering options
|
|
2699
|
+
* including symbol, CIK numbers, and transaction types. Essential for detailed
|
|
2700
|
+
* analysis of insider trading patterns and corporate governance.
|
|
2701
|
+
*
|
|
2702
|
+
* @param params - Insider trading search parameters
|
|
2703
|
+
* @param params.symbol - Stock symbol to filter by (optional)
|
|
2704
|
+
* @param params.reportingCik - Reporting CIK to filter by (optional)
|
|
2705
|
+
* @param params.companyCik - Company CIK to filter by (optional)
|
|
2706
|
+
* @param params.transactionType - Transaction type to filter by (optional)
|
|
2707
|
+
* @param params.page - Page number for pagination (default: 0)
|
|
2708
|
+
*
|
|
2709
|
+
* @returns Promise resolving to array of insider trading search results
|
|
2710
|
+
*
|
|
2711
|
+
* @example
|
|
2712
|
+
* ```typescript
|
|
2713
|
+
* // Search for Apple insider trades
|
|
2714
|
+
* const appleTrades = await fmp.insider.searchInsiderTrading({
|
|
2715
|
+
* symbol: 'AAPL',
|
|
2716
|
+
* page: 0
|
|
2717
|
+
* });
|
|
2718
|
+
* appleTrades.data.forEach(trade => {
|
|
2719
|
+
* console.log(`${trade.date}: ${trade.insiderName} - ${trade.transactionType} ${trade.sharesTraded} shares`);
|
|
2720
|
+
* });
|
|
2721
|
+
*
|
|
2722
|
+
* // Search by transaction type
|
|
2723
|
+
* const purchases = await fmp.insider.searchInsiderTrading({
|
|
2724
|
+
* transactionType: 'P-Purchase',
|
|
2725
|
+
* page: 0
|
|
2726
|
+
* });
|
|
2727
|
+
*
|
|
2728
|
+
* // Search by CIK
|
|
2729
|
+
* const cikTrades = await fmp.insider.searchInsiderTrading({
|
|
2730
|
+
* companyCik: '0000320193',
|
|
2731
|
+
* page: 0
|
|
2732
|
+
* });
|
|
2733
|
+
* ```
|
|
2734
|
+
*
|
|
2735
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#insider-trades-search-insider-trading|FMP Insider Trading Search Documentation}
|
|
2736
|
+
*/
|
|
2737
|
+
async searchInsiderTrading(params) {
|
|
2738
|
+
const { symbol, reportingCik, companyCik, transactionType, page = 0 } = params;
|
|
2739
|
+
const queryParams = { page };
|
|
2740
|
+
if (symbol) queryParams.symbol = symbol;
|
|
2741
|
+
if (reportingCik) queryParams.reportingCik = reportingCik;
|
|
2742
|
+
if (companyCik) queryParams.companyCik = companyCik;
|
|
2743
|
+
if (transactionType) queryParams.transactionType = transactionType;
|
|
2744
|
+
return this.client.get(`/insider-trading`, "v4", queryParams);
|
|
2745
|
+
}
|
|
2746
|
+
/**
|
|
2747
|
+
* Get all available transaction types
|
|
2748
|
+
*
|
|
2749
|
+
* Provides a comprehensive list of all insider trading transaction types
|
|
2750
|
+
* used in SEC filings. Essential for understanding different types of
|
|
2751
|
+
* insider trading activities and filtering search results.
|
|
2752
|
+
*
|
|
2753
|
+
* @returns Promise resolving to array of transaction types with descriptions
|
|
2754
|
+
*
|
|
2755
|
+
* @example
|
|
2756
|
+
* ```typescript
|
|
2757
|
+
* // Get all transaction types
|
|
2758
|
+
* const transactionTypes = await fmp.insider.getTransactionTypes();
|
|
2759
|
+
* transactionTypes.data.forEach(type => {
|
|
2760
|
+
* console.log(`${type.code}: ${type.description}`);
|
|
2761
|
+
* });
|
|
2762
|
+
* ```
|
|
2763
|
+
*
|
|
2764
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#transaction-types-insider-trading|FMP Transaction Types Documentation}
|
|
2765
|
+
*/
|
|
2766
|
+
async getTransactionTypes() {
|
|
2767
|
+
return this.client.get(`/insider-trading-transaction-type`, "v4");
|
|
2768
|
+
}
|
|
2769
|
+
/**
|
|
2770
|
+
* Get insiders roster for a specific company
|
|
2771
|
+
*
|
|
2772
|
+
* Provides a list of all insiders (officers, directors, and beneficial owners)
|
|
2773
|
+
* for a specific company. Essential for understanding corporate governance
|
|
2774
|
+
* structure and identifying key personnel.
|
|
2775
|
+
*
|
|
2776
|
+
* @param params - Insiders request parameters
|
|
2777
|
+
* @param params.symbol - Stock symbol to get insiders for
|
|
2778
|
+
*
|
|
2779
|
+
* @returns Promise resolving to array of insiders data for the company
|
|
2780
|
+
*
|
|
2781
|
+
* @example
|
|
2782
|
+
* ```typescript
|
|
2783
|
+
* // Get Apple's insiders roster
|
|
2784
|
+
* const appleInsiders = await fmp.insider.getInsidersBySymbol({ symbol: 'AAPL' });
|
|
2785
|
+
* appleInsiders.data.forEach(insider => {
|
|
2786
|
+
* console.log(`${insider.name} - ${insider.title} (${insider.cik})`);
|
|
2787
|
+
* });
|
|
2788
|
+
*
|
|
2789
|
+
* // Get Microsoft's insiders
|
|
2790
|
+
* const msftInsiders = await fmp.insider.getInsidersBySymbol({ symbol: 'MSFT' });
|
|
2791
|
+
* ```
|
|
2792
|
+
*
|
|
2793
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#insiders-by-symbol-insider-trading|FMP Insiders by Symbol Documentation}
|
|
2794
|
+
*/
|
|
2795
|
+
async getInsidersBySymbol(params) {
|
|
2796
|
+
const { symbol } = params;
|
|
2797
|
+
return this.client.get(`/insider-roaster`, "v4", { symbol });
|
|
2798
|
+
}
|
|
2799
|
+
/**
|
|
2800
|
+
* Get insider trade statistics for a company
|
|
2801
|
+
*
|
|
2802
|
+
* Provides comprehensive statistics on insider trading activity for a
|
|
2803
|
+
* specific company including total trades, volume, and value metrics.
|
|
2804
|
+
* Essential for analyzing insider trading patterns and sentiment.
|
|
2805
|
+
*
|
|
2806
|
+
* @param params - Statistics request parameters
|
|
2807
|
+
* @param params.symbol - Stock symbol to get statistics for
|
|
2808
|
+
*
|
|
2809
|
+
* @returns Promise resolving to array of insider trade statistics data
|
|
2810
|
+
*
|
|
2811
|
+
* @example
|
|
2812
|
+
* ```typescript
|
|
2813
|
+
* // Get Apple's insider trade statistics
|
|
2814
|
+
* const appleStats = await fmp.insider.getInsiderTradeStatistics({ symbol: 'AAPL' });
|
|
2815
|
+
* appleStats.data.forEach(stat => {
|
|
2816
|
+
* console.log(`${stat.insiderName}: ${stat.totalTrades} trades, ${stat.totalShares} shares`);
|
|
2817
|
+
* });
|
|
2818
|
+
*
|
|
2819
|
+
* // Get Microsoft's statistics
|
|
2820
|
+
* const msftStats = await fmp.insider.getInsiderTradeStatistics({ symbol: 'MSFT' });
|
|
2821
|
+
* ```
|
|
2822
|
+
*
|
|
2823
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#insider-trade-statistics-insider-trading|FMP Insider Trade Statistics Documentation}
|
|
2824
|
+
*/
|
|
2825
|
+
async getInsiderTradeStatistics(params) {
|
|
2826
|
+
const { symbol } = params;
|
|
2827
|
+
return this.client.get(`/insider-roaster-statistic`, "v4", { symbol });
|
|
2828
|
+
}
|
|
2829
|
+
/**
|
|
2830
|
+
* Get CIK mapper data
|
|
2831
|
+
*
|
|
2832
|
+
* Provides a mapping between CIK (Central Index Key) numbers and company
|
|
2833
|
+
* names. Essential for converting between CIK numbers and company
|
|
2834
|
+
* identifiers in insider trading analysis.
|
|
2835
|
+
*
|
|
2836
|
+
* @param params - CIK mapper request parameters
|
|
2837
|
+
* @param params.page - Page number for pagination (default: 0)
|
|
2838
|
+
*
|
|
2839
|
+
* @returns Promise resolving to array of CIK mapper data
|
|
2840
|
+
*
|
|
2841
|
+
* @example
|
|
2842
|
+
* ```typescript
|
|
2843
|
+
* // Get first page of CIK mapper
|
|
2844
|
+
* const cikMapper = await fmp.insider.getCikMapper({ page: 0 });
|
|
2845
|
+
* cikMapper.data.forEach(mapping => {
|
|
2846
|
+
* console.log(`CIK: ${mapping.cik} - Company: ${mapping.name}`);
|
|
2847
|
+
* });
|
|
2848
|
+
*
|
|
2849
|
+
* // Get second page
|
|
2850
|
+
* const nextPage = await fmp.insider.getCikMapper({ page: 1 });
|
|
2851
|
+
* ```
|
|
2852
|
+
*
|
|
2853
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#cik-mapper-insider-trading|FMP CIK Mapper Documentation}
|
|
2854
|
+
*/
|
|
2855
|
+
async getCikMapper(params) {
|
|
2856
|
+
const { page = 0 } = params;
|
|
2857
|
+
return this.client.get(`/mapper-cik-name`, "v4", { page });
|
|
2858
|
+
}
|
|
2859
|
+
/**
|
|
2860
|
+
* Get CIK mapper by name search
|
|
2861
|
+
*
|
|
2862
|
+
* Provides CIK numbers and company names matching a search term.
|
|
2863
|
+
* Useful for finding companies by partial name matches and
|
|
2864
|
+
* converting company names to CIK numbers.
|
|
2865
|
+
*
|
|
2866
|
+
* @param params - CIK mapper by name request parameters
|
|
2867
|
+
* @param params.name - Company name or partial name to search for
|
|
2868
|
+
* @param params.page - Page number for pagination (default: 0)
|
|
2869
|
+
*
|
|
2870
|
+
* @returns Promise resolving to array of CIK mapper data matching the search
|
|
2871
|
+
*
|
|
2872
|
+
* @example
|
|
2873
|
+
* ```typescript
|
|
2874
|
+
* // Search for Apple by name
|
|
2875
|
+
* const appleCik = await fmp.insider.getCikMapperByName({
|
|
2876
|
+
* name: 'Apple',
|
|
2877
|
+
* page: 0
|
|
2878
|
+
* });
|
|
2879
|
+
* appleCik.data.forEach(mapping => {
|
|
2880
|
+
* console.log(`CIK: ${mapping.cik} - Company: ${mapping.name}`);
|
|
2881
|
+
* });
|
|
2882
|
+
*
|
|
2883
|
+
* // Search for Microsoft
|
|
2884
|
+
* const msftCik = await fmp.insider.getCikMapperByName({
|
|
2885
|
+
* name: 'Microsoft',
|
|
2886
|
+
* page: 0
|
|
2887
|
+
* });
|
|
2888
|
+
* ```
|
|
2889
|
+
*
|
|
2890
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#cik-mapper-by-name-insider-trading|FMP CIK Mapper by Name Documentation}
|
|
2891
|
+
*/
|
|
2892
|
+
async getCikMapperByName(params) {
|
|
2893
|
+
const { name, page = 0 } = params;
|
|
2894
|
+
return this.client.get(`/mapper-cik-name`, "v4", { name, page });
|
|
2895
|
+
}
|
|
2896
|
+
/**
|
|
2897
|
+
* Get CIK mapper by symbol
|
|
2898
|
+
*
|
|
2899
|
+
* Provides CIK number and company name for a specific stock symbol.
|
|
2900
|
+
* Essential for converting stock symbols to CIK numbers for use
|
|
2901
|
+
* in insider trading searches and analysis.
|
|
2902
|
+
*
|
|
2903
|
+
* @param params - CIK mapper by symbol request parameters
|
|
2904
|
+
* @param params.symbol - Stock symbol to get CIK for
|
|
2905
|
+
*
|
|
2906
|
+
* @returns Promise resolving to CIK mapper data for the symbol
|
|
2907
|
+
*
|
|
2908
|
+
* @example
|
|
2909
|
+
* ```typescript
|
|
2910
|
+
* // Get Apple's CIK by symbol
|
|
2911
|
+
* const appleCik = await fmp.insider.getCikMapperBySymbol({ symbol: 'AAPL' });
|
|
2912
|
+
* console.log(`Apple CIK: ${appleCik.data.cik} - ${appleCik.data.name}`);
|
|
2913
|
+
*
|
|
2914
|
+
* // Get Microsoft's CIK
|
|
2915
|
+
* const msftCik = await fmp.insider.getCikMapperBySymbol({ symbol: 'MSFT' });
|
|
2916
|
+
* ```
|
|
2917
|
+
*
|
|
2918
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#cik-mapper-company-insider-trading|FMP CIK Mapper by Symbol Documentation}
|
|
2919
|
+
*/
|
|
2920
|
+
async getCikMapperBySymbol(params) {
|
|
2921
|
+
const { symbol } = params;
|
|
2922
|
+
return this.client.getSingle(`/mapper-cik-company/${symbol}`, "v4");
|
|
2923
|
+
}
|
|
2924
|
+
/**
|
|
2925
|
+
* Get beneficial ownership acquisitions
|
|
2926
|
+
*
|
|
2927
|
+
* Provides data on acquisitions of beneficial ownership for a specific
|
|
2928
|
+
* company. Essential for tracking significant ownership changes and
|
|
2929
|
+
* corporate governance events.
|
|
2930
|
+
*
|
|
2931
|
+
* @param params - Beneficial ownership request parameters
|
|
2932
|
+
* @param params.symbol - Stock symbol to get beneficial ownership data for
|
|
2933
|
+
*
|
|
2934
|
+
* @returns Promise resolving to array of beneficial ownership acquisition data
|
|
2935
|
+
*
|
|
2936
|
+
* @example
|
|
2937
|
+
* ```typescript
|
|
2938
|
+
* // Get Apple's beneficial ownership acquisitions
|
|
2939
|
+
* const appleOwnership = await fmp.insider.getBeneficialOwnership({ symbol: 'AAPL' });
|
|
2940
|
+
* appleOwnership.data.forEach(acquisition => {
|
|
2941
|
+
* console.log(`${acquisition.date}: ${acquisition.insiderName} acquired ${acquisition.sharesAcquired} shares`);
|
|
2942
|
+
* });
|
|
2943
|
+
*
|
|
2944
|
+
* // Get Microsoft's beneficial ownership
|
|
2945
|
+
* const msftOwnership = await fmp.insider.getBeneficialOwnership({ symbol: 'MSFT' });
|
|
2946
|
+
* ```
|
|
2947
|
+
*
|
|
2948
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#acquisition-of-beneficial-ownership|FMP Beneficial Ownership Documentation}
|
|
2949
|
+
*/
|
|
2950
|
+
async getBeneficialOwnership(params) {
|
|
2951
|
+
const { symbol } = params;
|
|
2952
|
+
return this.client.get(`/insider/ownership/acquisition_of_beneficial_ownership`, "v4", {
|
|
2953
|
+
symbol
|
|
2954
|
+
});
|
|
2955
|
+
}
|
|
2956
|
+
/**
|
|
2957
|
+
* Get fail to deliver data
|
|
2958
|
+
*
|
|
2959
|
+
* Provides fail to deliver data for a specific company, which indicates
|
|
2960
|
+
* when market participants fail to deliver securities on settlement date.
|
|
2961
|
+
* Important for understanding market mechanics and potential short interest.
|
|
2962
|
+
*
|
|
2963
|
+
* @param params - Fail to deliver request parameters
|
|
2964
|
+
* @param params.symbol - Stock symbol to get fail to deliver data for
|
|
2965
|
+
* @param params.page - Page number for pagination (default: 0)
|
|
2966
|
+
*
|
|
2967
|
+
* @returns Promise resolving to array of fail to deliver data
|
|
2968
|
+
*
|
|
2969
|
+
* @example
|
|
2970
|
+
* ```typescript
|
|
2971
|
+
* // Get Apple's fail to deliver data
|
|
2972
|
+
* const appleFailToDeliver = await fmp.insider.getFailToDeliver({
|
|
2973
|
+
* symbol: 'AAPL',
|
|
2974
|
+
* page: 0
|
|
2975
|
+
* });
|
|
2976
|
+
* appleFailToDeliver.data.forEach(entry => {
|
|
2977
|
+
* console.log(`${entry.date}: ${entry.shares} shares failed to deliver`);
|
|
2978
|
+
* });
|
|
2979
|
+
*
|
|
2980
|
+
* // Get Microsoft's fail to deliver data
|
|
2981
|
+
* const msftFailToDeliver = await fmp.insider.getFailToDeliver({
|
|
2982
|
+
* symbol: 'MSFT',
|
|
2983
|
+
* page: 0
|
|
2984
|
+
* });
|
|
2985
|
+
* ```
|
|
2986
|
+
*
|
|
2987
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#fail-to-deliver|FMP Fail to Deliver Documentation}
|
|
2988
|
+
*/
|
|
2989
|
+
async getFailToDeliver(params) {
|
|
2990
|
+
const { symbol, page = 0 } = params;
|
|
2991
|
+
return this.client.get(`/fail_to_deliver`, "v4", { symbol, page });
|
|
2992
|
+
}
|
|
2993
|
+
/**
|
|
2994
|
+
* Get all insider trades for a symbol (convenience method)
|
|
2995
|
+
* @param symbol - The stock symbol to get insider trades for
|
|
2996
|
+
* @param page - Page number for pagination (default: 0)
|
|
2997
|
+
* @returns A list of insider trades for the specified symbol
|
|
2998
|
+
*/
|
|
2999
|
+
async getInsiderTradesBySymbol(symbol, page = 0) {
|
|
3000
|
+
return this.searchInsiderTrading({ symbol, page });
|
|
3001
|
+
}
|
|
3002
|
+
/**
|
|
3003
|
+
* Get insider trades by transaction type (convenience method)
|
|
3004
|
+
* @param transactionType - The transaction type to filter by
|
|
3005
|
+
* @param page - Page number for pagination (default: 0)
|
|
3006
|
+
* @returns A list of insider trades filtered by transaction type
|
|
3007
|
+
*/
|
|
3008
|
+
async getInsiderTradesByType(transactionType, page = 0) {
|
|
3009
|
+
return this.searchInsiderTrading({ transactionType, page });
|
|
3010
|
+
}
|
|
3011
|
+
/**
|
|
3012
|
+
* Get insider trades by reporting CIK (convenience method)
|
|
3013
|
+
* @param reportingCik - The reporting CIK to filter by
|
|
3014
|
+
* @param page - Page number for pagination (default: 0)
|
|
3015
|
+
* @returns A list of insider trades filtered by reporting CIK
|
|
3016
|
+
*/
|
|
3017
|
+
async getInsiderTradesByReportingCik(reportingCik, page = 0) {
|
|
3018
|
+
return this.searchInsiderTrading({ reportingCik, page });
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* Get insider trades by company CIK (convenience method)
|
|
3022
|
+
* @param companyCik - The company CIK to filter by
|
|
3023
|
+
* @param page - Page number for pagination (default: 0)
|
|
3024
|
+
* @returns A list of insider trades filtered by company CIK
|
|
3025
|
+
*/
|
|
3026
|
+
async getInsiderTradesByCompanyCik(companyCik, page = 0) {
|
|
3027
|
+
return this.searchInsiderTrading({ companyCik, page });
|
|
3028
|
+
}
|
|
3029
|
+
};
|
|
3030
|
+
|
|
3031
|
+
// src/endpoints/sec.ts
|
|
3032
|
+
var SECEndpoints = class {
|
|
3033
|
+
constructor(client) {
|
|
3034
|
+
this.client = client;
|
|
3035
|
+
}
|
|
3036
|
+
/**
|
|
3037
|
+
* Get RSS feed of SEC filings
|
|
3038
|
+
*
|
|
3039
|
+
* Provides a real-time feed of SEC filings from publicly traded companies,
|
|
3040
|
+
* including filing types, links to SEC pages, and direct links to filings.
|
|
3041
|
+
* Essential for staying up-to-date on the latest SEC filings for all companies
|
|
3042
|
+
* or for monitoring specific companies' regulatory activities.
|
|
3043
|
+
*
|
|
3044
|
+
* @param params - RSS feed parameters (optional)
|
|
3045
|
+
* @returns Promise resolving to array of RSS feed items with SEC filing information
|
|
3046
|
+
*
|
|
3047
|
+
* @example
|
|
3048
|
+
* ```typescript
|
|
3049
|
+
* // Get all recent SEC filings
|
|
3050
|
+
* const allFilings = await fmp.sec.getRSSFeed();
|
|
3051
|
+
* console.log(`Recent SEC filings: ${allFilings.data.length}`);
|
|
3052
|
+
*
|
|
3053
|
+
* // Get specific filing type
|
|
3054
|
+
* const form4Filings = await fmp.sec.getRSSFeed({ type: '4' });
|
|
3055
|
+
* console.log(`Form 4 filings: ${form4Filings.data.length}`);
|
|
3056
|
+
*
|
|
3057
|
+
* // Get filings with date range
|
|
3058
|
+
* const recentFilings = await fmp.sec.getRSSFeed({
|
|
3059
|
+
* from: '2024-01-01',
|
|
3060
|
+
* to: '2024-01-31'
|
|
3061
|
+
* });
|
|
3062
|
+
* console.log(`Recent filings: ${recentFilings.data.length}`);
|
|
3063
|
+
*
|
|
3064
|
+
* // Get limited results
|
|
3065
|
+
* const limitedFilings = await fmp.sec.getRSSFeed({ limit: 10 });
|
|
3066
|
+
* console.log(`Limited filings: ${limitedFilings.data.length}`);
|
|
3067
|
+
* ```
|
|
3068
|
+
*
|
|
3069
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#rss-feed-securities-and-exchange-commission-(s.e.c)|FMP RSS Feed Documentation}
|
|
3070
|
+
*/
|
|
3071
|
+
async getRSSFeed(params) {
|
|
3072
|
+
return this.client.get("/rss_feed", "v4", params);
|
|
3073
|
+
}
|
|
3074
|
+
/**
|
|
3075
|
+
* Get comprehensive RSS feed of all SEC filings
|
|
3076
|
+
*
|
|
3077
|
+
* Provides a comprehensive real-time feed of all SEC filings from publicly
|
|
3078
|
+
* traded companies in the latest RSS feed format. This endpoint offers the
|
|
3079
|
+
* most complete overview of SEC filings with enhanced metadata and formatting.
|
|
3080
|
+
*
|
|
3081
|
+
* @param params - RSS feed all parameters (optional)
|
|
3082
|
+
* @returns Promise resolving to array of comprehensive RSS feed items with enhanced SEC filing information
|
|
3083
|
+
*
|
|
3084
|
+
* @example
|
|
3085
|
+
* ```typescript
|
|
3086
|
+
* // Get all comprehensive SEC filings
|
|
3087
|
+
* const allFilings = await fmp.sec.getRSSFeedAll();
|
|
3088
|
+
* console.log(`Comprehensive SEC filings: ${allFilings.data.length}`);
|
|
3089
|
+
*
|
|
3090
|
+
* // Get paginated results
|
|
3091
|
+
* const page2Filings = await fmp.sec.getRSSFeedAll({ page: 1 });
|
|
3092
|
+
* console.log(`Page 2 filings: ${page2Filings.data.length}`);
|
|
3093
|
+
*
|
|
3094
|
+
* // Get specific data type
|
|
3095
|
+
* const specificData = await fmp.sec.getRSSFeedAll({ datatype: 'json' });
|
|
3096
|
+
* console.log(`Specific data type filings: ${specificData.data.length}`);
|
|
3097
|
+
* ```
|
|
3098
|
+
*
|
|
3099
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#rss-feed-all-securities-and-exchange-commission-(s.e.c)|FMP RSS Feed All Documentation}
|
|
3100
|
+
*/
|
|
3101
|
+
async getRSSFeedAll(params) {
|
|
3102
|
+
return this.client.get("/rss_feed_all", "v4", params);
|
|
3103
|
+
}
|
|
3104
|
+
/**
|
|
3105
|
+
* Get RSS feed V3 of SEC filings
|
|
3106
|
+
*
|
|
3107
|
+
* Provides a real-time feed of SEC filings from publicly traded companies
|
|
3108
|
+
* in the V3 RSS feed format. This version offers enhanced metadata and
|
|
3109
|
+
* improved structure for better parsing and analysis of SEC filings.
|
|
3110
|
+
*
|
|
3111
|
+
* @param params - RSS feed V3 parameters (optional)
|
|
3112
|
+
* @returns Promise resolving to array of V3 RSS feed items with enhanced SEC filing information
|
|
3113
|
+
*
|
|
3114
|
+
* @example
|
|
3115
|
+
* ```typescript
|
|
3116
|
+
* // Get V3 format SEC filings
|
|
3117
|
+
* const v3Filings = await fmp.sec.getRSSFeedV3();
|
|
3118
|
+
* console.log(`V3 SEC filings: ${v3Filings.data.length}`);
|
|
3119
|
+
*
|
|
3120
|
+
* // Get paginated V3 results
|
|
3121
|
+
* const page2V3 = await fmp.sec.getRSSFeedV3({ page: 1 });
|
|
3122
|
+
* console.log(`Page 2 V3 filings: ${page2V3.data.length}`);
|
|
3123
|
+
*
|
|
3124
|
+
* // Get specific data type
|
|
3125
|
+
* const specificV3 = await fmp.sec.getRSSFeedV3({ datatype: 'json' });
|
|
3126
|
+
* console.log(`Specific V3 data type: ${specificV3.data.length}`);
|
|
3127
|
+
* ```
|
|
3128
|
+
*
|
|
3129
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#rss-feed-v3-securities-and-exchange-commission-(s.e.c)|FMP RSS Feed V3 Documentation}
|
|
3130
|
+
*/
|
|
3131
|
+
async getRSSFeedV3(params) {
|
|
3132
|
+
return this.client.get("/rss_feed", "v3", params);
|
|
3133
|
+
}
|
|
3134
|
+
/**
|
|
3135
|
+
* Get RSS feed of 8-K SEC filings
|
|
3136
|
+
*
|
|
3137
|
+
* Provides a real-time feed specifically for 8-K SEC filings from publicly
|
|
3138
|
+
* traded companies. 8-K filings are used to announce major events that
|
|
3139
|
+
* shareholders should know about, such as earnings releases, mergers,
|
|
3140
|
+
* acquisitions, and other material events.
|
|
3141
|
+
*
|
|
3142
|
+
* @param params - RSS feed 8-K parameters (optional)
|
|
3143
|
+
* @returns Promise resolving to array of 8-K RSS feed items with material event information
|
|
3144
|
+
*
|
|
3145
|
+
* @example
|
|
3146
|
+
* ```typescript
|
|
3147
|
+
* // Get all 8-K filings
|
|
3148
|
+
* const form8KFilings = await fmp.sec.getRSSFeed8K();
|
|
3149
|
+
* console.log(`8-K filings: ${form8KFilings.data.length}`);
|
|
3150
|
+
*
|
|
3151
|
+
* // Get 8-K filings with date range
|
|
3152
|
+
* const recent8K = await fmp.sec.getRSSFeed8K({
|
|
3153
|
+
* from: '2024-01-01',
|
|
3154
|
+
* to: '2024-01-31'
|
|
3155
|
+
* });
|
|
3156
|
+
* console.log(`Recent 8-K filings: ${recent8K.data.length}`);
|
|
3157
|
+
*
|
|
3158
|
+
* // Get 8-K filings with financials
|
|
3159
|
+
* const financial8K = await fmp.sec.getRSSFeed8K({ hasFinancial: true });
|
|
3160
|
+
* console.log(`8-K filings with financials: ${financial8K.data.length}`);
|
|
3161
|
+
*
|
|
3162
|
+
* // Get limited 8-K results
|
|
3163
|
+
* const limited8K = await fmp.sec.getRSSFeed8K({ limit: 10 });
|
|
3164
|
+
* console.log(`Limited 8-K filings: ${limited8K.data.length}`);
|
|
3165
|
+
* ```
|
|
3166
|
+
*
|
|
3167
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#rss-feed-8-k-securities-and-exchange-commission-(s.e.c)|FMP RSS Feed 8-K Documentation}
|
|
3168
|
+
*/
|
|
3169
|
+
async getRSSFeed8K(params) {
|
|
3170
|
+
return this.client.get("/rss_feed_8k", "v4", params);
|
|
3171
|
+
}
|
|
3172
|
+
/**
|
|
3173
|
+
* Get SEC filings for a specific company
|
|
3174
|
+
*
|
|
3175
|
+
* Provides direct access to SEC filings for a specific company, including
|
|
3176
|
+
* filing types, links to SEC pages, and direct links to specific filings.
|
|
3177
|
+
* Essential for monitoring a company's regulatory compliance and staying
|
|
3178
|
+
* informed about important corporate events and disclosures.
|
|
3179
|
+
*
|
|
3180
|
+
* @param symbol - The stock symbol to get SEC filings for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
3181
|
+
* @param params - SEC filings parameters (optional)
|
|
3182
|
+
* @returns Promise resolving to array of SEC filings with detailed filing information
|
|
3183
|
+
*
|
|
3184
|
+
* @example
|
|
3185
|
+
* ```typescript
|
|
3186
|
+
* // Get all SEC filings for Apple
|
|
3187
|
+
* const appleFilings = await fmp.sec.getSECFilings({ symbol: 'AAPL' });
|
|
3188
|
+
* console.log(`Apple SEC filings: ${appleFilings.data.length}`);
|
|
3189
|
+
*
|
|
3190
|
+
* // Get specific filing type for Microsoft
|
|
3191
|
+
* const msftForm4 = await fmp.sec.getSECFilings({
|
|
3192
|
+
* symbol: 'MSFT',
|
|
3193
|
+
* params: { type: '4' }
|
|
3194
|
+
* });
|
|
3195
|
+
* console.log(`Microsoft Form 4 filings: ${msftForm4.data.length}`);
|
|
3196
|
+
* ```
|
|
3197
|
+
*
|
|
3198
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#sec-filings-securities-and-exchange-commission-(s.e.c)|FMP SEC Filings Documentation}
|
|
3199
|
+
*/
|
|
3200
|
+
async getSECFilings({
|
|
3201
|
+
symbol,
|
|
3202
|
+
params
|
|
3203
|
+
}) {
|
|
3204
|
+
return this.client.get(`/sec_filings/${symbol}`, "v3", params);
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Get individual industry classification for a company
|
|
3208
|
+
*
|
|
3209
|
+
* Provides the industry classification for a specific company based on the
|
|
3210
|
+
* Standard Industrial Classification (SIC) system. Essential for understanding
|
|
3211
|
+
* a company's business sector, industry peers, and market positioning.
|
|
3212
|
+
*
|
|
3213
|
+
* @param params - Industry classification parameters
|
|
3214
|
+
* @returns Promise resolving to industry classification data with SIC code and description
|
|
3215
|
+
*
|
|
3216
|
+
* @example
|
|
3217
|
+
* ```typescript
|
|
3218
|
+
* // Get Apple's industry classification by symbol
|
|
3219
|
+
* const appleIndustry = await fmp.sec.getIndividualIndustryClassification({ symbol: 'AAPL' });
|
|
3220
|
+
* console.log(`Apple Industry: ${appleIndustry.data.industryTitle}`);
|
|
3221
|
+
* console.log(`SIC Code: ${appleIndustry.data.sicCode}`);
|
|
3222
|
+
*
|
|
3223
|
+
* // Get industry classification by CIK
|
|
3224
|
+
* const cikIndustry = await fmp.sec.getIndividualIndustryClassification({ cik: 320193 });
|
|
3225
|
+
* console.log(`CIK Industry: ${cikIndustry.data.industryTitle}`);
|
|
3226
|
+
*
|
|
3227
|
+
* // Get industry classification by SIC code
|
|
3228
|
+
* const sicIndustry = await fmp.sec.getIndividualIndustryClassification({ sicCode: 3571 });
|
|
3229
|
+
* console.log(`SIC Industry: ${sicIndustry.data.industryTitle}`);
|
|
3230
|
+
* ```
|
|
3231
|
+
*
|
|
3232
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#individual-industry-classification-standard-industrial-classification|FMP Individual Industry Classification Documentation}
|
|
3233
|
+
*/
|
|
3234
|
+
async getIndividualIndustryClassification(params) {
|
|
3235
|
+
return this.client.getSingle("/standard_industrial_classification", "v4", params);
|
|
3236
|
+
}
|
|
3237
|
+
/**
|
|
3238
|
+
* Get all industry classifications
|
|
3239
|
+
*
|
|
3240
|
+
* Provides a comprehensive overview of all industries classified according
|
|
3241
|
+
* to the Standard Industrial Classification (SIC) system. Essential for
|
|
3242
|
+
* understanding industry categories, sector analysis, and market research.
|
|
3243
|
+
*
|
|
3244
|
+
* @returns Promise resolving to array of all industry classifications with SIC codes and descriptions
|
|
3245
|
+
*
|
|
3246
|
+
* @example
|
|
3247
|
+
* ```typescript
|
|
3248
|
+
* // Get all industry classifications
|
|
3249
|
+
* const allIndustries = await fmp.sec.getAllIndustryClassifications();
|
|
3250
|
+
* console.log(`Total industries: ${allIndustries.data.length}`);
|
|
3251
|
+
*
|
|
3252
|
+
* allIndustries.data.forEach((industry, index) => {
|
|
3253
|
+
* console.log(`${index + 1}. ${industry.industryTitle}`);
|
|
3254
|
+
* console.log(` SIC Code: ${industry.sicCode}`);
|
|
3255
|
+
* });
|
|
3256
|
+
*
|
|
3257
|
+
* // Find specific industry
|
|
3258
|
+
* const techIndustry = allIndustries.data.find(industry =>
|
|
3259
|
+
* industry.industryTitle.toLowerCase().includes('computer')
|
|
3260
|
+
* );
|
|
3261
|
+
* console.log(`Tech Industry: ${techIndustry?.industryTitle}`);
|
|
3262
|
+
* ```
|
|
3263
|
+
*
|
|
3264
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#all-industry-classification-standard-industrial-classification|FMP All Industry Classifications Documentation}
|
|
3265
|
+
*/
|
|
3266
|
+
async getAllIndustryClassifications() {
|
|
3267
|
+
return this.client.get("/standard_industrial_classification/all", "v4");
|
|
3268
|
+
}
|
|
3269
|
+
/**
|
|
3270
|
+
* Get industry classification codes
|
|
3271
|
+
*
|
|
3272
|
+
* Provides detailed information about the Standard Industrial Classification
|
|
3273
|
+
* (SIC) system and helps identify SIC codes for specific industries.
|
|
3274
|
+
* Essential for understanding industry categorization and sector analysis.
|
|
3275
|
+
*
|
|
3276
|
+
* @param params - Industry classification codes parameters
|
|
3277
|
+
* @returns Promise resolving to array of industry classification codes with detailed information
|
|
3278
|
+
*
|
|
3279
|
+
* @example
|
|
3280
|
+
* ```typescript
|
|
3281
|
+
* // Get all industry classification codes
|
|
3282
|
+
* const allCodes = await fmp.sec.getIndustryClassificationCodes({});
|
|
3283
|
+
* console.log(`Total SIC codes: ${allCodes.data.length}`);
|
|
3284
|
+
*
|
|
3285
|
+
* // Search for specific SIC code
|
|
3286
|
+
* const code3571 = await fmp.sec.getIndustryClassificationCodes({ sicCode: 3571 });
|
|
3287
|
+
* console.log(`SIC 3571: ${code3571.data[0]?.industryTitle}`);
|
|
3288
|
+
*
|
|
3289
|
+
* // Search for industry by title
|
|
3290
|
+
* const computerIndustry = await fmp.sec.getIndustryClassificationCodes({ industryTitle: 'Computer' });
|
|
3291
|
+
* console.log(`Computer-related industries: ${computerIndustry.data.length}`);
|
|
3292
|
+
* ```
|
|
3293
|
+
*
|
|
3294
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#industry-classification-codes-standard-industrial-classification|FMP Industry Classification Codes Documentation}
|
|
3295
|
+
*/
|
|
3296
|
+
async getIndustryClassificationCodes(params) {
|
|
3297
|
+
return this.client.get("/standard_industrial_classification_list", "v4", params);
|
|
3298
|
+
}
|
|
3299
|
+
};
|
|
3300
|
+
|
|
3301
|
+
// src/endpoints/mutual-fund.ts
|
|
3302
|
+
var MutualFundEndpoints = class {
|
|
3303
|
+
constructor(client) {
|
|
3304
|
+
this.client = client;
|
|
3305
|
+
}
|
|
3306
|
+
/**
|
|
3307
|
+
* Get mutual fund holders of a specific stock
|
|
3308
|
+
*
|
|
3309
|
+
* Provides data on mutual funds that hold shares in a specific stock.
|
|
3310
|
+
* Essential for understanding mutual fund ownership patterns and
|
|
3311
|
+
* which mutual funds are invested in particular companies.
|
|
3312
|
+
*
|
|
3313
|
+
* @param symbol - The stock symbol to get mutual fund holders for (e.g., 'AAPL', 'MSFT', 'GOOGL')
|
|
3314
|
+
*
|
|
3315
|
+
* @returns Promise resolving to array of mutual fund holders with position details
|
|
3316
|
+
*
|
|
3317
|
+
* @example
|
|
3318
|
+
* ```typescript
|
|
3319
|
+
* // Get mutual funds that hold Apple stock
|
|
3320
|
+
* const appleHolders = await fmp.mutualFund.getHolders('AAPL');
|
|
3321
|
+
* console.log(`${appleHolders.data.length} mutual funds hold AAPL`);
|
|
3322
|
+
*
|
|
3323
|
+
* appleHolders.data.forEach((holder, index) => {
|
|
3324
|
+
* console.log(`${index + 1}. ${holder.holder}`);
|
|
3325
|
+
* console.log(` Shares: ${holder.shares?.toLocaleString() || 'N/A'}`);
|
|
3326
|
+
* console.log(` Weight: ${holder.weightPercent}% | Change: ${holder.change}`);
|
|
3327
|
+
* });
|
|
3328
|
+
*
|
|
3329
|
+
* // Get mutual funds that hold Microsoft stock
|
|
3330
|
+
* const msftHolders = await fmp.mutualFund.getHolders('MSFT');
|
|
3331
|
+
*
|
|
3332
|
+
* // Find top mutual fund holders by shares
|
|
3333
|
+
* const topHolders = msftHolders.data
|
|
3334
|
+
* .sort((a, b) => (b.shares || 0) - (a.shares || 0))
|
|
3335
|
+
* .slice(0, 10);
|
|
3336
|
+
* console.log('Top 10 mutual fund holders by shares:');
|
|
3337
|
+
* topHolders.forEach((holder, index) => {
|
|
3338
|
+
* console.log(`${index + 1}. ${holder.holder}: ${holder.shares.toLocaleString()} shares`);
|
|
3339
|
+
* });
|
|
3340
|
+
*
|
|
3341
|
+
* // Get mutual funds that hold Google stock
|
|
3342
|
+
* const googlHolders = await fmp.mutualFund.getHolders('GOOGL');
|
|
3343
|
+
*
|
|
3344
|
+
* // Analyze mutual fund concentration
|
|
3345
|
+
* const totalShares = googlHolders.data.reduce((sum, holder) => sum + (holder.shares || 0), 0);
|
|
3346
|
+
* console.log(`Total shares held by mutual funds: ${totalShares.toLocaleString()}`);
|
|
3347
|
+
*
|
|
3348
|
+
* googlHolders.data.forEach(holder => {
|
|
3349
|
+
* const percentage = ((holder.shares || 0) / totalShares * 100).toFixed(2);
|
|
3350
|
+
* console.log(`${holder.holder}: ${percentage}% of total mutual fund holdings`);
|
|
3351
|
+
* });
|
|
3352
|
+
* ```
|
|
3353
|
+
*
|
|
3354
|
+
* @see {@link https://site.financialmodelingprep.com/developer/docs#mutual-fund-holder-mutual-funds-holdings|FMP Mutual Fund Holders Documentation}
|
|
3355
|
+
*/
|
|
3356
|
+
async getHolders(symbol) {
|
|
3357
|
+
return this.client.get(`/mutual-fund-holder/${symbol}`, "v3");
|
|
3358
|
+
}
|
|
3359
|
+
};
|
|
3360
|
+
|
|
1120
3361
|
// src/fmp.ts
|
|
1121
3362
|
var FMP = class {
|
|
1122
|
-
constructor(config) {
|
|
1123
|
-
|
|
1124
|
-
|
|
3363
|
+
constructor(config = {}) {
|
|
3364
|
+
const apiKey = config.apiKey || process.env.FMP_API_KEY;
|
|
3365
|
+
if (!apiKey) {
|
|
3366
|
+
throw new Error(
|
|
3367
|
+
"FMP API key is required. Please provide it in the config or set the FMP_API_KEY environment variable."
|
|
3368
|
+
);
|
|
3369
|
+
}
|
|
3370
|
+
if (!FMPValidation.isValidApiKey(apiKey)) {
|
|
3371
|
+
throw new Error("Invalid API key format");
|
|
3372
|
+
}
|
|
3373
|
+
const client = new FMPClient({ ...config, apiKey });
|
|
1125
3374
|
this.stock = new StockEndpoints(client);
|
|
1126
3375
|
this.financial = new FinancialEndpoints(client);
|
|
1127
|
-
this.crypto = new CryptoEndpoints(client);
|
|
1128
3376
|
this.etf = new ETFEndpoints(client);
|
|
3377
|
+
this.economic = new EconomicEndpoints(client);
|
|
1129
3378
|
this.market = new MarketEndpoints(client);
|
|
1130
3379
|
this.list = new ListEndpoints(client);
|
|
1131
3380
|
this.calendar = new CalendarEndpoints(client);
|
|
1132
3381
|
this.company = new CompanyEndpoints(client);
|
|
1133
3382
|
this.quote = new QuoteEndpoints(client);
|
|
1134
3383
|
this.senateHouse = new SenateHouseEndpoints(client);
|
|
1135
|
-
this.
|
|
1136
|
-
this.
|
|
3384
|
+
this.institutional = new InstitutionalEndpoints(client);
|
|
3385
|
+
this.insider = new InsiderEndpoints(client);
|
|
3386
|
+
this.sec = new SECEndpoints(client);
|
|
1137
3387
|
this.mutualFund = new MutualFundEndpoints(client);
|
|
1138
3388
|
}
|
|
1139
3389
|
/**
|
|
@@ -1162,57 +3412,28 @@ var Exchange = /* @__PURE__ */ ((Exchange2) => {
|
|
|
1162
3412
|
return Exchange2;
|
|
1163
3413
|
})(Exchange || {});
|
|
1164
3414
|
|
|
1165
|
-
// src/
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
return
|
|
1186
|
-
}
|
|
1187
|
-
function formatDate(date) {
|
|
1188
|
-
const d = typeof date === "string" ? new Date(date) : date;
|
|
1189
|
-
return d.toISOString().split("T")[0];
|
|
1190
|
-
}
|
|
1191
|
-
function formatReadableDate(date) {
|
|
1192
|
-
const d = typeof date === "string" ? new Date(date) : date;
|
|
1193
|
-
return d.toLocaleDateString("en-US", {
|
|
1194
|
-
year: "numeric",
|
|
1195
|
-
month: "long",
|
|
1196
|
-
day: "numeric"
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
function formatTimestamp(timestamp) {
|
|
1200
|
-
const date = new Date(timestamp * 1e3);
|
|
1201
|
-
return date.toLocaleString("en-US");
|
|
1202
|
-
}
|
|
1203
|
-
function formatNumber(value, decimals = 2) {
|
|
1204
|
-
return value.toFixed(decimals);
|
|
1205
|
-
}
|
|
1206
|
-
function formatVolume(volume) {
|
|
1207
|
-
if (volume >= 1e9) {
|
|
1208
|
-
return `${(volume / 1e9).toFixed(2)}B`;
|
|
1209
|
-
} else if (volume >= 1e6) {
|
|
1210
|
-
return `${(volume / 1e6).toFixed(2)}M`;
|
|
1211
|
-
} else if (volume >= 1e3) {
|
|
1212
|
-
return `${(volume / 1e3).toFixed(2)}K`;
|
|
1213
|
-
}
|
|
1214
|
-
return volume.toString();
|
|
1215
|
-
}
|
|
3415
|
+
// src/types/insider.ts
|
|
3416
|
+
var TransactionType = /* @__PURE__ */ ((TransactionType2) => {
|
|
3417
|
+
TransactionType2["AWARD"] = "A-Award";
|
|
3418
|
+
TransactionType2["CONVERSION"] = "C-Conversion";
|
|
3419
|
+
TransactionType2["RETURN"] = "D-Return";
|
|
3420
|
+
TransactionType2["EXPIRE_SHORT"] = "E-ExpireShort";
|
|
3421
|
+
TransactionType2["IN_KIND"] = "F-InKind";
|
|
3422
|
+
TransactionType2["GIFT"] = "G-Gift";
|
|
3423
|
+
TransactionType2["EXPIRE_LONG"] = "H-ExpireLong";
|
|
3424
|
+
TransactionType2["DISCRETIONARY"] = "I-Discretionary";
|
|
3425
|
+
TransactionType2["OTHER"] = "J-Other";
|
|
3426
|
+
TransactionType2["SMALL"] = "L-Small";
|
|
3427
|
+
TransactionType2["EXEMPT"] = "M-Exempt";
|
|
3428
|
+
TransactionType2["OUT_OF_THE_MONEY"] = "O-OutOfTheMoney";
|
|
3429
|
+
TransactionType2["PURCHASE"] = "P-Purchase";
|
|
3430
|
+
TransactionType2["SALE"] = "S-Sale";
|
|
3431
|
+
TransactionType2["TENDER"] = "U-Tender";
|
|
3432
|
+
TransactionType2["WILL"] = "W-Will";
|
|
3433
|
+
TransactionType2["IN_THE_MONEY"] = "X-InTheMoney";
|
|
3434
|
+
TransactionType2["TRUST"] = "Z-Trust";
|
|
3435
|
+
return TransactionType2;
|
|
3436
|
+
})(TransactionType || {});
|
|
1216
3437
|
|
|
1217
3438
|
// src/utils/constants.ts
|
|
1218
3439
|
var DEFAULT_TIMEOUT = 1e4;
|
|
@@ -1281,6 +3502,636 @@ var HTTP_STATUS = {
|
|
|
1281
3502
|
INTERNAL_SERVER_ERROR: 500
|
|
1282
3503
|
};
|
|
1283
3504
|
|
|
1284
|
-
|
|
3505
|
+
// src/utils/formatting.ts
|
|
3506
|
+
function formatCurrency(value, currency = "USD") {
|
|
3507
|
+
return new Intl.NumberFormat("en-US", {
|
|
3508
|
+
style: "currency",
|
|
3509
|
+
currency
|
|
3510
|
+
}).format(value);
|
|
3511
|
+
}
|
|
3512
|
+
function formatPercentage(value, decimals = 2) {
|
|
3513
|
+
return `${value.toFixed(decimals)}%`;
|
|
3514
|
+
}
|
|
3515
|
+
function formatLargeNumber(value) {
|
|
3516
|
+
if (value >= 1e12) {
|
|
3517
|
+
return `${(value / 1e12).toFixed(2)}T`;
|
|
3518
|
+
} else if (value >= 1e9) {
|
|
3519
|
+
return `${(value / 1e9).toFixed(2)}B`;
|
|
3520
|
+
} else if (value >= 1e6) {
|
|
3521
|
+
return `${(value / 1e6).toFixed(2)}M`;
|
|
3522
|
+
} else if (value >= 1e3) {
|
|
3523
|
+
return `${(value / 1e3).toFixed(2)}K`;
|
|
3524
|
+
}
|
|
3525
|
+
return value.toString();
|
|
3526
|
+
}
|
|
3527
|
+
function formatDate(date) {
|
|
3528
|
+
const d = typeof date === "string" ? new Date(date) : date;
|
|
3529
|
+
return d.toISOString().split("T")[0];
|
|
3530
|
+
}
|
|
3531
|
+
function formatReadableDate(date) {
|
|
3532
|
+
const d = typeof date === "string" ? new Date(date) : date;
|
|
3533
|
+
return d.toLocaleDateString("en-US", {
|
|
3534
|
+
year: "numeric",
|
|
3535
|
+
month: "long",
|
|
3536
|
+
day: "numeric"
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
function formatTimestamp(timestamp) {
|
|
3540
|
+
const date = new Date(timestamp * 1e3);
|
|
3541
|
+
return date.toLocaleString("en-US");
|
|
3542
|
+
}
|
|
3543
|
+
function formatNumber(value, decimals = 2) {
|
|
3544
|
+
return value.toFixed(decimals);
|
|
3545
|
+
}
|
|
3546
|
+
function formatVolume(volume) {
|
|
3547
|
+
if (volume >= 1e9) {
|
|
3548
|
+
return `${(volume / 1e9).toFixed(2)}B`;
|
|
3549
|
+
} else if (volume >= 1e6) {
|
|
3550
|
+
return `${(volume / 1e6).toFixed(2)}M`;
|
|
3551
|
+
} else if (volume >= 1e3) {
|
|
3552
|
+
return `${(volume / 1e3).toFixed(2)}K`;
|
|
3553
|
+
}
|
|
3554
|
+
return volume.toString();
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
// src/utils/helpers.ts
|
|
3558
|
+
var FMPHelpers = class {
|
|
3559
|
+
/**
|
|
3560
|
+
* Get all available endpoint categories from the FMP client
|
|
3561
|
+
* @param fmp - The FMP client instance
|
|
3562
|
+
* @returns Array of endpoint category names
|
|
3563
|
+
*/
|
|
3564
|
+
static getEndpointCategories(fmp) {
|
|
3565
|
+
return Object.keys(fmp).filter(
|
|
3566
|
+
(key) => typeof fmp[key] === "object" && fmp[key] !== null && key !== "constructor"
|
|
3567
|
+
);
|
|
3568
|
+
}
|
|
3569
|
+
/**
|
|
3570
|
+
* Get all methods for a specific endpoint category
|
|
3571
|
+
* @param fmp - The FMP client instance
|
|
3572
|
+
* @param endpoint - The endpoint category name
|
|
3573
|
+
* @returns Array of method names
|
|
3574
|
+
*/
|
|
3575
|
+
static getEndpointMethods(fmp, endpoint) {
|
|
3576
|
+
const endpointObj = fmp[endpoint];
|
|
3577
|
+
if (!endpointObj || typeof endpointObj !== "object") {
|
|
3578
|
+
return [];
|
|
3579
|
+
}
|
|
3580
|
+
return Object.getOwnPropertyNames(endpointObj).filter(
|
|
3581
|
+
(name) => typeof endpointObj[name] === "function" && name !== "constructor"
|
|
3582
|
+
);
|
|
3583
|
+
}
|
|
3584
|
+
/**
|
|
3585
|
+
* Get all available methods across all endpoint categories
|
|
3586
|
+
* @param fmp - The FMP client instance
|
|
3587
|
+
* @returns Object mapping endpoint categories to their methods
|
|
3588
|
+
*/
|
|
3589
|
+
static getAllMethods(fmp) {
|
|
3590
|
+
const methods = {};
|
|
3591
|
+
const categories = this.getEndpointCategories(fmp);
|
|
3592
|
+
categories.forEach((category) => {
|
|
3593
|
+
methods[category] = this.getEndpointMethods(fmp, category);
|
|
3594
|
+
});
|
|
3595
|
+
return methods;
|
|
3596
|
+
}
|
|
3597
|
+
/**
|
|
3598
|
+
* Get a summary of the API structure
|
|
3599
|
+
* @param fmp - The FMP client instance
|
|
3600
|
+
* @returns Summary object with endpoint and method counts
|
|
3601
|
+
*/
|
|
3602
|
+
static getApiSummary(fmp) {
|
|
3603
|
+
const categories = this.getEndpointCategories(fmp);
|
|
3604
|
+
const allMethods = this.getAllMethods(fmp);
|
|
3605
|
+
const totalMethods = Object.values(allMethods).reduce(
|
|
3606
|
+
(sum, methods) => sum + methods.length,
|
|
3607
|
+
0
|
|
3608
|
+
);
|
|
3609
|
+
const methodCounts = {};
|
|
3610
|
+
categories.forEach((category) => {
|
|
3611
|
+
methodCounts[category] = allMethods[category]?.length || 0;
|
|
3612
|
+
});
|
|
3613
|
+
return {
|
|
3614
|
+
totalEndpoints: categories.length,
|
|
3615
|
+
totalMethods,
|
|
3616
|
+
categories,
|
|
3617
|
+
methodCounts
|
|
3618
|
+
};
|
|
3619
|
+
}
|
|
3620
|
+
/**
|
|
3621
|
+
* Check if a specific method exists on an endpoint
|
|
3622
|
+
* @param fmp - The FMP client instance
|
|
3623
|
+
* @param endpoint - The endpoint category name
|
|
3624
|
+
* @param method - The method name
|
|
3625
|
+
* @returns True if the method exists
|
|
3626
|
+
*/
|
|
3627
|
+
static hasMethod(fmp, endpoint, method) {
|
|
3628
|
+
const methods = this.getEndpointMethods(fmp, endpoint);
|
|
3629
|
+
return methods.includes(method);
|
|
3630
|
+
}
|
|
3631
|
+
/**
|
|
3632
|
+
* Get method signature information (basic introspection)
|
|
3633
|
+
* @param fmp - The FMP client instance
|
|
3634
|
+
* @param endpoint - The endpoint category name
|
|
3635
|
+
* @param method - The method name
|
|
3636
|
+
* @returns Method information or null if not found
|
|
3637
|
+
*/
|
|
3638
|
+
static getMethodInfo(fmp, endpoint, method) {
|
|
3639
|
+
const endpointObj = fmp[endpoint];
|
|
3640
|
+
if (!endpointObj || typeof endpointObj !== "object") {
|
|
3641
|
+
return null;
|
|
3642
|
+
}
|
|
3643
|
+
const methodFn = endpointObj[method];
|
|
3644
|
+
if (typeof methodFn !== "function") {
|
|
3645
|
+
return null;
|
|
3646
|
+
}
|
|
3647
|
+
return {
|
|
3648
|
+
name: method,
|
|
3649
|
+
type: "function",
|
|
3650
|
+
async: methodFn.constructor.name === "AsyncFunction"
|
|
3651
|
+
};
|
|
3652
|
+
}
|
|
3653
|
+
};
|
|
3654
|
+
|
|
3655
|
+
// src/utils/utils.ts
|
|
3656
|
+
var FMPUtils = class {
|
|
3657
|
+
/**
|
|
3658
|
+
* Format currency values
|
|
3659
|
+
* @param value - The numeric value to format
|
|
3660
|
+
* @param currency - The currency code (default: USD)
|
|
3661
|
+
* @param locale - The locale for formatting (default: en-US)
|
|
3662
|
+
* @returns Formatted currency string
|
|
3663
|
+
*/
|
|
3664
|
+
static formatCurrency(value, currency = "USD", locale = "en-US") {
|
|
3665
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
3666
|
+
return "N/A";
|
|
3667
|
+
}
|
|
3668
|
+
try {
|
|
3669
|
+
return new Intl.NumberFormat(locale, {
|
|
3670
|
+
style: "currency",
|
|
3671
|
+
currency,
|
|
3672
|
+
minimumFractionDigits: 2,
|
|
3673
|
+
maximumFractionDigits: 2
|
|
3674
|
+
}).format(value);
|
|
3675
|
+
} catch (error) {
|
|
3676
|
+
return `${currency} ${value.toFixed(2)}`;
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
/**
|
|
3680
|
+
* Format percentages
|
|
3681
|
+
* @param value - The percentage value (as decimal, e.g., 0.15 for 15%)
|
|
3682
|
+
* @param decimals - Number of decimal places (default: 2)
|
|
3683
|
+
* @returns Formatted percentage string
|
|
3684
|
+
*/
|
|
3685
|
+
static formatPercentage(value, decimals = 2) {
|
|
3686
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
3687
|
+
return "N/A";
|
|
3688
|
+
}
|
|
3689
|
+
return `${value.toFixed(decimals)}%`;
|
|
3690
|
+
}
|
|
3691
|
+
/**
|
|
3692
|
+
* Format large numbers with abbreviations (K, M, B, T)
|
|
3693
|
+
* @param value - The numeric value to format
|
|
3694
|
+
* @param decimals - Number of decimal places (default: 1)
|
|
3695
|
+
* @returns Formatted number string
|
|
3696
|
+
*/
|
|
3697
|
+
static formatLargeNumber(value, decimals = 1) {
|
|
3698
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
3699
|
+
return "N/A";
|
|
3700
|
+
}
|
|
3701
|
+
const absValue = Math.abs(value);
|
|
3702
|
+
const sign = value < 0 ? "-" : "";
|
|
3703
|
+
if (absValue >= 1e12) {
|
|
3704
|
+
return `${sign}${(absValue / 1e12).toFixed(decimals)}T`;
|
|
3705
|
+
} else if (absValue >= 1e9) {
|
|
3706
|
+
return `${sign}${(absValue / 1e9).toFixed(decimals)}B`;
|
|
3707
|
+
} else if (absValue >= 1e6) {
|
|
3708
|
+
return `${sign}${(absValue / 1e6).toFixed(decimals)}M`;
|
|
3709
|
+
} else if (absValue >= 1e3) {
|
|
3710
|
+
return `${sign}${(absValue / 1e3).toFixed(decimals)}K`;
|
|
3711
|
+
} else {
|
|
3712
|
+
return `${sign}${absValue.toFixed(decimals)}`;
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
/**
|
|
3716
|
+
* Convert date string to Date object
|
|
3717
|
+
* @param dateString - The date string in YYYY-MM-DD format
|
|
3718
|
+
* @returns Date object or null if invalid
|
|
3719
|
+
*/
|
|
3720
|
+
static parseDate(dateString) {
|
|
3721
|
+
if (!dateString || typeof dateString !== "string") {
|
|
3722
|
+
return null;
|
|
3723
|
+
}
|
|
3724
|
+
const [year, month, day] = dateString.split("-").map(Number);
|
|
3725
|
+
if (isNaN(year) || isNaN(month) || isNaN(day)) {
|
|
3726
|
+
return null;
|
|
3727
|
+
}
|
|
3728
|
+
if (month < 1 || month > 12) {
|
|
3729
|
+
return null;
|
|
3730
|
+
}
|
|
3731
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
3732
|
+
if (isNaN(date.getTime())) {
|
|
3733
|
+
return null;
|
|
3734
|
+
}
|
|
3735
|
+
const parsedYear = date.getUTCFullYear();
|
|
3736
|
+
const parsedMonth = date.getUTCMonth() + 1;
|
|
3737
|
+
const parsedDay = date.getUTCDate();
|
|
3738
|
+
if (parsedYear !== year || parsedMonth !== month || parsedDay !== day) {
|
|
3739
|
+
return null;
|
|
3740
|
+
}
|
|
3741
|
+
return date;
|
|
3742
|
+
}
|
|
3743
|
+
/**
|
|
3744
|
+
* Format date to readable string
|
|
3745
|
+
* @param date - Date object or date string
|
|
3746
|
+
* @param format - Format style ('short', 'long', 'iso')
|
|
3747
|
+
* @returns Formatted date string
|
|
3748
|
+
*/
|
|
3749
|
+
static formatDate(date, format = "short") {
|
|
3750
|
+
const dateObj = typeof date === "string" ? this.parseDate(date) : date;
|
|
3751
|
+
if (!dateObj) {
|
|
3752
|
+
return "Invalid Date";
|
|
3753
|
+
}
|
|
3754
|
+
switch (format) {
|
|
3755
|
+
case "long":
|
|
3756
|
+
return dateObj.toLocaleDateString("en-US", {
|
|
3757
|
+
weekday: "long",
|
|
3758
|
+
year: "numeric",
|
|
3759
|
+
month: "long",
|
|
3760
|
+
day: "numeric"
|
|
3761
|
+
});
|
|
3762
|
+
case "iso":
|
|
3763
|
+
return dateObj.toISOString().split("T")[0];
|
|
3764
|
+
case "short":
|
|
3765
|
+
default:
|
|
3766
|
+
return dateObj.toLocaleDateString("en-US", {
|
|
3767
|
+
year: "numeric",
|
|
3768
|
+
month: "short",
|
|
3769
|
+
day: "numeric"
|
|
3770
|
+
});
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
/**
|
|
3774
|
+
* Calculate working days between two dates (excluding weekends)
|
|
3775
|
+
* @param from - Start date
|
|
3776
|
+
* @param to - End date
|
|
3777
|
+
* @returns Number of working days
|
|
3778
|
+
*/
|
|
3779
|
+
static getWorkingDays(from, to) {
|
|
3780
|
+
const startDate = typeof from === "string" ? this.parseDate(from) : from;
|
|
3781
|
+
const endDate = typeof to === "string" ? this.parseDate(to) : to;
|
|
3782
|
+
if (!startDate || !endDate) {
|
|
3783
|
+
return 0;
|
|
3784
|
+
}
|
|
3785
|
+
let workingDays = 0;
|
|
3786
|
+
const currentDate = new Date(startDate);
|
|
3787
|
+
const endDateNormalized = new Date(
|
|
3788
|
+
Date.UTC(endDate.getUTCFullYear(), endDate.getUTCMonth(), endDate.getUTCDate())
|
|
3789
|
+
);
|
|
3790
|
+
while (currentDate <= endDateNormalized) {
|
|
3791
|
+
const dayOfWeek = currentDate.getUTCDay();
|
|
3792
|
+
if (dayOfWeek !== 0 && dayOfWeek !== 6) {
|
|
3793
|
+
workingDays++;
|
|
3794
|
+
}
|
|
3795
|
+
currentDate.setUTCDate(currentDate.getUTCDate() + 1);
|
|
3796
|
+
}
|
|
3797
|
+
return workingDays;
|
|
3798
|
+
}
|
|
3799
|
+
/**
|
|
3800
|
+
* Calculate percentage change between two values
|
|
3801
|
+
* @param oldValue - The original value
|
|
3802
|
+
* @param newValue - The new value
|
|
3803
|
+
* @param decimals - Number of decimal places (default: 2)
|
|
3804
|
+
* @returns Percentage change as a number
|
|
3805
|
+
*/
|
|
3806
|
+
static calculatePercentageChange(oldValue, newValue, decimals = 2) {
|
|
3807
|
+
if (typeof oldValue !== "number" || typeof newValue !== "number" || isNaN(oldValue) || isNaN(newValue) || oldValue === 0) {
|
|
3808
|
+
return 0;
|
|
3809
|
+
}
|
|
3810
|
+
const change = (newValue - oldValue) / oldValue * 100;
|
|
3811
|
+
return Number(change.toFixed(decimals));
|
|
3812
|
+
}
|
|
3813
|
+
/**
|
|
3814
|
+
* Batch API calls with rate limiting
|
|
3815
|
+
* @param calls - Array of async functions to execute
|
|
3816
|
+
* @param delayMs - Delay between calls in milliseconds (default: 100)
|
|
3817
|
+
* @param maxConcurrent - Maximum concurrent calls (default: 1)
|
|
3818
|
+
* @returns Array of results
|
|
3819
|
+
*/
|
|
3820
|
+
static async batchCalls(calls, delayMs = 100, maxConcurrent = 1) {
|
|
3821
|
+
const results = [];
|
|
3822
|
+
if (maxConcurrent === 1) {
|
|
3823
|
+
for (const call of calls) {
|
|
3824
|
+
results.push(await call());
|
|
3825
|
+
if (delayMs > 0) {
|
|
3826
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
} else {
|
|
3830
|
+
const chunks = this.chunkArray(calls, maxConcurrent);
|
|
3831
|
+
for (const chunk of chunks) {
|
|
3832
|
+
const chunkResults = await Promise.all(chunk.map((call) => call()));
|
|
3833
|
+
results.push(...chunkResults);
|
|
3834
|
+
if (delayMs > 0) {
|
|
3835
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
return results;
|
|
3840
|
+
}
|
|
3841
|
+
/**
|
|
3842
|
+
* Split array into chunks
|
|
3843
|
+
* @param array - The array to split
|
|
3844
|
+
* @param chunkSize - Size of each chunk
|
|
3845
|
+
* @returns Array of chunks
|
|
3846
|
+
*/
|
|
3847
|
+
static chunkArray(array, chunkSize) {
|
|
3848
|
+
const chunks = [];
|
|
3849
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
3850
|
+
chunks.push(array.slice(i, i + chunkSize));
|
|
3851
|
+
}
|
|
3852
|
+
return chunks;
|
|
3853
|
+
}
|
|
3854
|
+
/**
|
|
3855
|
+
* Retry a function with exponential backoff
|
|
3856
|
+
* @param fn - The function to retry
|
|
3857
|
+
* @param maxRetries - Maximum number of retries (default: 3)
|
|
3858
|
+
* @param baseDelay - Base delay in milliseconds (default: 1000)
|
|
3859
|
+
* @returns Function result
|
|
3860
|
+
*/
|
|
3861
|
+
static async retryWithBackoff(fn, maxRetries = 3, baseDelay = 1e3) {
|
|
3862
|
+
let lastError;
|
|
3863
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
3864
|
+
try {
|
|
3865
|
+
return await fn();
|
|
3866
|
+
} catch (error) {
|
|
3867
|
+
lastError = error;
|
|
3868
|
+
if (attempt === maxRetries) {
|
|
3869
|
+
throw lastError;
|
|
3870
|
+
}
|
|
3871
|
+
const delay = baseDelay * Math.pow(2, attempt);
|
|
3872
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
throw lastError;
|
|
3876
|
+
}
|
|
3877
|
+
/**
|
|
3878
|
+
* Debounce a function
|
|
3879
|
+
* @param func - The function to debounce
|
|
3880
|
+
* @param wait - Wait time in milliseconds
|
|
3881
|
+
* @returns Debounced function
|
|
3882
|
+
*/
|
|
3883
|
+
static debounce(func, wait) {
|
|
3884
|
+
let timeout;
|
|
3885
|
+
return (...args) => {
|
|
3886
|
+
clearTimeout(timeout);
|
|
3887
|
+
timeout = setTimeout(() => func(...args), wait);
|
|
3888
|
+
};
|
|
3889
|
+
}
|
|
3890
|
+
/**
|
|
3891
|
+
* Throttle a function
|
|
3892
|
+
* @param func - The function to throttle
|
|
3893
|
+
* @param limit - Time limit in milliseconds
|
|
3894
|
+
* @returns Throttled function
|
|
3895
|
+
*/
|
|
3896
|
+
static throttle(func, limit) {
|
|
3897
|
+
let inThrottle;
|
|
3898
|
+
return (...args) => {
|
|
3899
|
+
if (!inThrottle) {
|
|
3900
|
+
func(...args);
|
|
3901
|
+
inThrottle = true;
|
|
3902
|
+
setTimeout(() => inThrottle = false, limit);
|
|
3903
|
+
}
|
|
3904
|
+
};
|
|
3905
|
+
}
|
|
3906
|
+
};
|
|
3907
|
+
|
|
3908
|
+
// src/utils/debug.ts
|
|
3909
|
+
var _FMPDebug = class _FMPDebug {
|
|
3910
|
+
/**
|
|
3911
|
+
* Log API calls for debugging (only in development)
|
|
3912
|
+
* @param endpoint - The endpoint being called
|
|
3913
|
+
* @param params - The parameters passed to the endpoint
|
|
3914
|
+
* @param response - The response received
|
|
3915
|
+
* @param duration - The duration of the call in milliseconds
|
|
3916
|
+
*/
|
|
3917
|
+
static logApiCall(endpoint, params, response, duration) {
|
|
3918
|
+
if (!this.isDevelopment && !this.isDebugEnabled) {
|
|
3919
|
+
return;
|
|
3920
|
+
}
|
|
3921
|
+
const logData = {
|
|
3922
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3923
|
+
endpoint,
|
|
3924
|
+
params,
|
|
3925
|
+
success: response?.success,
|
|
3926
|
+
status: response?.status,
|
|
3927
|
+
duration: duration ? `${duration}ms` : void 0
|
|
3928
|
+
};
|
|
3929
|
+
console.log("\u{1F50D} FMP API Call:", logData);
|
|
3930
|
+
}
|
|
3931
|
+
/**
|
|
3932
|
+
* Log API errors for debugging
|
|
3933
|
+
* @param endpoint - The endpoint that failed
|
|
3934
|
+
* @param params - The parameters that were passed
|
|
3935
|
+
* @param error - The error that occurred
|
|
3936
|
+
*/
|
|
3937
|
+
static logApiError(endpoint, params, error) {
|
|
3938
|
+
if (!this.isDevelopment && !this.isDebugEnabled) {
|
|
3939
|
+
return;
|
|
3940
|
+
}
|
|
3941
|
+
console.error("\u274C FMP API Error:", {
|
|
3942
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3943
|
+
endpoint,
|
|
3944
|
+
params,
|
|
3945
|
+
error: error?.message || error,
|
|
3946
|
+
stack: error?.stack
|
|
3947
|
+
});
|
|
3948
|
+
}
|
|
3949
|
+
/**
|
|
3950
|
+
* Get comprehensive API usage statistics
|
|
3951
|
+
* @param fmp - The FMP client instance
|
|
3952
|
+
* @returns Detailed API statistics
|
|
3953
|
+
*/
|
|
3954
|
+
static getApiStats(fmp) {
|
|
3955
|
+
const summary = FMPHelpers.getApiSummary(fmp);
|
|
3956
|
+
const estimatedApiCalls = Object.values(summary.methodCounts).reduce(
|
|
3957
|
+
(total, count) => total + count * 2,
|
|
3958
|
+
// Assume 2 calls per method on average
|
|
3959
|
+
0
|
|
3960
|
+
);
|
|
3961
|
+
return {
|
|
3962
|
+
...summary,
|
|
3963
|
+
estimatedApiCalls
|
|
3964
|
+
};
|
|
3965
|
+
}
|
|
3966
|
+
/**
|
|
3967
|
+
* Validate API key format and provide feedback
|
|
3968
|
+
* @param apiKey - The API key to validate
|
|
3969
|
+
* @returns Validation result with details
|
|
3970
|
+
*/
|
|
3971
|
+
static validateApiKey(apiKey) {
|
|
3972
|
+
const length = apiKey?.length || 0;
|
|
3973
|
+
const format = apiKey?.match(/^[a-zA-Z0-9]+$/) ? "alphanumeric" : "invalid";
|
|
3974
|
+
const isValid = length >= 32 && format === "alphanumeric";
|
|
3975
|
+
const suggestions = [];
|
|
3976
|
+
if (length < 32) {
|
|
3977
|
+
suggestions.push("API key should be at least 32 characters long");
|
|
3978
|
+
}
|
|
3979
|
+
if (format !== "alphanumeric") {
|
|
3980
|
+
suggestions.push("API key should contain only letters and numbers");
|
|
3981
|
+
}
|
|
3982
|
+
if (!apiKey) {
|
|
3983
|
+
suggestions.push("API key is required");
|
|
3984
|
+
}
|
|
3985
|
+
return {
|
|
3986
|
+
isValid,
|
|
3987
|
+
length,
|
|
3988
|
+
format,
|
|
3989
|
+
suggestions
|
|
3990
|
+
};
|
|
3991
|
+
}
|
|
3992
|
+
/**
|
|
3993
|
+
* Check API key environment variable
|
|
3994
|
+
* @returns Environment check result
|
|
3995
|
+
*/
|
|
3996
|
+
static checkApiKeyEnvironment() {
|
|
3997
|
+
const envVarName = "FMP_API_KEY";
|
|
3998
|
+
const apiKey = process.env[envVarName];
|
|
3999
|
+
const hasEnvVar = !!apiKey;
|
|
4000
|
+
const validation = this.validateApiKey(apiKey || "");
|
|
4001
|
+
const suggestions = [];
|
|
4002
|
+
if (!hasEnvVar) {
|
|
4003
|
+
suggestions.push(`Set ${envVarName} environment variable`);
|
|
4004
|
+
suggestions.push("Add to your .env file: FMP_API_KEY=your_api_key_here");
|
|
4005
|
+
} else if (!validation.isValid) {
|
|
4006
|
+
suggestions.push(...validation.suggestions);
|
|
4007
|
+
}
|
|
4008
|
+
return {
|
|
4009
|
+
hasEnvVar,
|
|
4010
|
+
envVarName,
|
|
4011
|
+
isValid: validation.isValid,
|
|
4012
|
+
suggestions
|
|
4013
|
+
};
|
|
4014
|
+
}
|
|
4015
|
+
/**
|
|
4016
|
+
* Get performance metrics for API calls
|
|
4017
|
+
* @param fmp - The FMP client instance
|
|
4018
|
+
* @returns Performance information
|
|
4019
|
+
*/
|
|
4020
|
+
static getPerformanceInfo() {
|
|
4021
|
+
return {
|
|
4022
|
+
nodeVersion: process.version,
|
|
4023
|
+
platform: process.platform,
|
|
4024
|
+
memoryUsage: process.memoryUsage(),
|
|
4025
|
+
uptime: process.uptime()
|
|
4026
|
+
};
|
|
4027
|
+
}
|
|
4028
|
+
/**
|
|
4029
|
+
* Create a debug configuration object
|
|
4030
|
+
* @param fmp - The FMP client instance
|
|
4031
|
+
* @returns Debug configuration
|
|
4032
|
+
*/
|
|
4033
|
+
static createDebugConfig(fmp) {
|
|
4034
|
+
return {
|
|
4035
|
+
apiStats: this.getApiStats(fmp),
|
|
4036
|
+
envCheck: this.checkApiKeyEnvironment(),
|
|
4037
|
+
performance: this.getPerformanceInfo(),
|
|
4038
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
4039
|
+
};
|
|
4040
|
+
}
|
|
4041
|
+
/**
|
|
4042
|
+
* Print debug information to console
|
|
4043
|
+
* @param fmp - The FMP client instance
|
|
4044
|
+
*/
|
|
4045
|
+
static printDebugInfo(fmp) {
|
|
4046
|
+
if (!this.isDevelopment && !this.isDebugEnabled) {
|
|
4047
|
+
return;
|
|
4048
|
+
}
|
|
4049
|
+
const config = this.createDebugConfig(fmp);
|
|
4050
|
+
console.log("\u{1F527} FMP Debug Information:");
|
|
4051
|
+
console.log("\u{1F4CA} API Stats:", config.apiStats);
|
|
4052
|
+
console.log("\u{1F511} Environment Check:", config.envCheck);
|
|
4053
|
+
console.log("\u26A1 Performance:", config.performance);
|
|
4054
|
+
console.log("\u{1F552} Timestamp:", config.timestamp);
|
|
4055
|
+
}
|
|
4056
|
+
/**
|
|
4057
|
+
* Enable debug mode programmatically
|
|
4058
|
+
*/
|
|
4059
|
+
static enableDebugMode() {
|
|
4060
|
+
process.env.FMP_DEBUG = "true";
|
|
4061
|
+
this.isDebugEnabled = true;
|
|
4062
|
+
console.log("\u{1F527} FMP Debug mode enabled");
|
|
4063
|
+
}
|
|
4064
|
+
/**
|
|
4065
|
+
* Disable debug mode programmatically
|
|
4066
|
+
*/
|
|
4067
|
+
static disableDebugMode() {
|
|
4068
|
+
process.env.FMP_DEBUG = "false";
|
|
4069
|
+
this.isDebugEnabled = false;
|
|
4070
|
+
console.log("\u{1F527} FMP Debug mode disabled");
|
|
4071
|
+
}
|
|
4072
|
+
/**
|
|
4073
|
+
* Check if debug mode is enabled
|
|
4074
|
+
* @returns True if debug mode is enabled
|
|
4075
|
+
*/
|
|
4076
|
+
static isDebugMode() {
|
|
4077
|
+
return this.isDevelopment || this.isDebugEnabled;
|
|
4078
|
+
}
|
|
4079
|
+
/**
|
|
4080
|
+
* Create a debug wrapper for API calls
|
|
4081
|
+
* @param fmp - The FMP client instance
|
|
4082
|
+
* @returns FMP client with debug logging
|
|
4083
|
+
*/
|
|
4084
|
+
static createDebugWrapper(fmp) {
|
|
4085
|
+
if (!this.isDebugMode()) {
|
|
4086
|
+
return fmp;
|
|
4087
|
+
}
|
|
4088
|
+
return new Proxy(fmp, {
|
|
4089
|
+
get(target, prop) {
|
|
4090
|
+
const value = target[prop];
|
|
4091
|
+
if (typeof value === "object" && value !== null) {
|
|
4092
|
+
return new Proxy(value, {
|
|
4093
|
+
get(endpointTarget, methodName) {
|
|
4094
|
+
const method = endpointTarget[methodName];
|
|
4095
|
+
if (typeof method === "function") {
|
|
4096
|
+
return async (...args) => {
|
|
4097
|
+
const startTime = Date.now();
|
|
4098
|
+
const endpoint = `${String(prop)}.${String(methodName)}`;
|
|
4099
|
+
let params;
|
|
4100
|
+
if (methodName === "getQuote" && args.length === 1 && typeof args[0] === "string") {
|
|
4101
|
+
params = { symbol: args[0] };
|
|
4102
|
+
} else if (args.length === 1 && typeof args[0] === "object" && args[0] !== null) {
|
|
4103
|
+
params = args[0];
|
|
4104
|
+
} else {
|
|
4105
|
+
params = args;
|
|
4106
|
+
}
|
|
4107
|
+
try {
|
|
4108
|
+
_FMPDebug.logApiCall(endpoint, params, null);
|
|
4109
|
+
const result = await method.apply(
|
|
4110
|
+
endpointTarget,
|
|
4111
|
+
args
|
|
4112
|
+
);
|
|
4113
|
+
const duration = Date.now() - startTime;
|
|
4114
|
+
_FMPDebug.logApiCall(endpoint, params, result, duration);
|
|
4115
|
+
return result;
|
|
4116
|
+
} catch (error) {
|
|
4117
|
+
_FMPDebug.logApiError(endpoint, params, error);
|
|
4118
|
+
throw error;
|
|
4119
|
+
}
|
|
4120
|
+
};
|
|
4121
|
+
}
|
|
4122
|
+
return method;
|
|
4123
|
+
}
|
|
4124
|
+
});
|
|
4125
|
+
}
|
|
4126
|
+
return value;
|
|
4127
|
+
}
|
|
4128
|
+
});
|
|
4129
|
+
}
|
|
4130
|
+
};
|
|
4131
|
+
_FMPDebug.isDevelopment = process.env.NODE_ENV === "development";
|
|
4132
|
+
_FMPDebug.isDebugEnabled = process.env.FMP_DEBUG === "true";
|
|
4133
|
+
var FMPDebug = _FMPDebug;
|
|
4134
|
+
|
|
4135
|
+
export { COUNTRIES, CalendarEndpoints, CompanyEndpoints, DEFAULT_LIMIT, DEFAULT_TIMEOUT, ERROR_MESSAGES, ETFEndpoints, EXCHANGES, EconomicEndpoints, Exchange, FMP, FMPClient, FMPDebug, FMPHelpers, FMPUtils, FMPValidation, FinancialEndpoints, HTTP_STATUS, InsiderEndpoints, InstitutionalEndpoints, ListEndpoints, MAX_LIMIT, MarketEndpoints, MutualFundEndpoints, PERIODS, Period, QuoteEndpoints, SECEndpoints, SECTORS, SenateHouseEndpoints, StockEndpoints, TransactionType, formatCurrency, formatDate, formatLargeNumber, formatNumber, formatPercentage, formatReadableDate, formatTimestamp, formatVolume };
|
|
1285
4136
|
//# sourceMappingURL=index.mjs.map
|
|
1286
4137
|
//# sourceMappingURL=index.mjs.map
|