Skip to content

Commit f75369c

Browse files
authored
feat: add Fundamentals API v1.1 methods (#10)
Adds fundamentalsV1_1() and bulkFundamentalsV1_1() — same params, v1.1 endpoint with improved Earnings::Trend.
1 parent d6490c5 commit f75369c

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

src/api/fundamentals.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ export class FundamentalsApi {
2020
return this.http.get(`/bulk-fundamentals/${encodeURIComponent(exchange)}`, params);
2121
}
2222

23+
/** Company fundamentals v1.1 (extended Earnings::Trend): GET /v1.1/fundamentals/{ticker} */
24+
async fundamentalsV1_1(ticker: Ticker, params: FundamentalsParams = {}): Promise<FundamentalsData> {
25+
return this.http.get(`/v1.1/fundamentals/${encodeURIComponent(ticker)}`, params);
26+
}
27+
28+
/** Bulk fundamentals v1.1 for exchange: GET /v1.1/bulk-fundamentals/{exchange} */
29+
async bulkFundamentalsV1_1(exchange: string, params: BulkFundamentalsParams = {}): Promise<BulkFundamentalsItem[]> {
30+
return this.http.get(`/v1.1/bulk-fundamentals/${encodeURIComponent(exchange)}`, params);
31+
}
32+
2333
/** Company logo (PNG): GET /logo/{symbol} */
2434
async logo(symbol: Ticker): Promise<ArrayBuffer> {
2535
return this.http.getBuffer(`/logo/${encodeURIComponent(symbol)}`);

src/client.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,44 @@ export class EODHDClient {
461461
return this._fundamentals.bulkFundamentals(exchange, params);
462462
}
463463

464+
/**
465+
* Fetch company fundamentals using the v1.1 API (extended Earnings::Trend section).
466+
*
467+
* @param ticker - Symbol with exchange suffix, e.g. `"AAPL.US"`
468+
* @param params - Optional date range, filter, historical toggle
469+
* @returns Fundamentals data object with nested sections
470+
* @throws {@link EODHDError} on API error
471+
* @see https://eodhd.com/financial-apis/stock-etfs-fundamental-data-feeds/
472+
*
473+
* @example
474+
* ```ts
475+
* const fund = await client.fundamentalsV1_1('AAPL.US');
476+
* console.log(fund.Earnings); // extended Trend data
477+
* ```
478+
*/
479+
fundamentalsV1_1(ticker: Ticker, params?: FundamentalsParams): Promise<FundamentalsData> {
480+
return this._fundamentals.fundamentalsV1_1(ticker, params);
481+
}
482+
483+
/**
484+
* Fetch bulk fundamentals v1.1 for all tickers on an exchange (extended Earnings::Trend).
485+
*
486+
* @param exchange - Exchange code, e.g. `"US"`
487+
* @param params - Optional symbols filter
488+
* @returns Array of bulk fundamentals items
489+
* @throws {@link EODHDError} on API error
490+
* @see https://eodhd.com/financial-apis/bulk-fundamentals-api/
491+
*
492+
* @example
493+
* ```ts
494+
* const bulk = await client.bulkFundamentalsV1_1('US', { symbols: 'AAPL,MSFT' });
495+
* console.log(bulk[0].General?.Name);
496+
* ```
497+
*/
498+
bulkFundamentalsV1_1(exchange: string, params?: BulkFundamentalsParams): Promise<BulkFundamentalsItem[]> {
499+
return this._fundamentals.bulkFundamentalsV1_1(exchange, params);
500+
}
501+
464502
// ── News & Sentiment ──
465503

466504
/**

test/client.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,24 @@ describe("EODHDClient", () => {
288288
expect(url).toContain("/bulk-fundamentals/US");
289289
expect(url).toContain("symbols=AAPL%2CMSFT");
290290
});
291+
292+
it("fundamentalsV1_1() calls /v1.1/fundamentals/{ticker}", async () => {
293+
const client = createClient();
294+
await client.fundamentalsV1_1("AAPL.US", { filter: "Earnings" });
295+
296+
const url = getCalledUrl(fetch);
297+
expect(url).toContain("/v1.1/fundamentals/AAPL.US");
298+
expect(url).toContain("filter=Earnings");
299+
});
300+
301+
it("bulkFundamentalsV1_1() calls /v1.1/bulk-fundamentals/{exchange}", async () => {
302+
const client = createClient();
303+
await client.bulkFundamentalsV1_1("US", { symbols: "AAPL,MSFT" });
304+
305+
const url = getCalledUrl(fetch);
306+
expect(url).toContain("/v1.1/bulk-fundamentals/US");
307+
expect(url).toContain("symbols=AAPL%2CMSFT");
308+
});
291309
});
292310

293311
// ── Delegation: News & Sentiment ────────────────────────────────────────

0 commit comments

Comments
 (0)