UNPKG

sec-edgar-toolkit

Version:

Open source toolkit to facilitate working with the SEC EDGAR database

83 lines 3.17 kB
"use strict"; /** * SEC EDGAR API Client * * This module provides the main SEC EDGAR API client that combines all endpoint * modules into a single, easy-to-use interface. * * Example: * import { EdgarClient } from 'sec-edgar-toolkit'; * * const client = new EdgarClient({ userAgent: 'MyApp/1.0 (contact@example.com)' }); * const company = await client.getCompanyByTicker('AAPL'); * const submissions = await client.getCompanySubmissions(company.cik_str); * * Note: * The SEC requires a User-Agent header with contact information for all API requests. * Please provide accurate contact information in case the SEC needs to reach you * about your usage. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.EdgarClient = void 0; const utils_1 = require("../utils"); const endpoints_1 = require("../endpoints"); const errors_1 = require("../exceptions/errors"); class EdgarClient { constructor(config = {}) { // Get user agent from config or environment variable const userAgent = config.userAgent || process.env.SEC_EDGAR_TOOLKIT_USER_AGENT; if (!userAgent) { throw new errors_1.InvalidUserAgentError(); } if (userAgent.length < 10) { throw new errors_1.InvalidUserAgentError(userAgent); } this.userAgent = userAgent; this.httpClient = new utils_1.HttpClient(userAgent, { rateLimitDelay: config.rateLimitDelay, maxRetries: config.maxRetries, timeout: config.timeout, cache: config.cache !== false ? { ttl: 300000, // 5 minutes default maxSize: 500, } : false, }); // Initialize endpoint modules this.company = new endpoints_1.CompanyEndpoints(this.httpClient); this.filings = new endpoints_1.FilingsEndpoints(this.httpClient); this.xbrl = new endpoints_1.XbrlEndpoints(this.httpClient); } // Convenience methods that delegate to endpoint modules // Company methods async getCompanyTickers(forceRefresh = false) { return this.company.getCompanyTickers(forceRefresh); } async getCompanyByTicker(ticker) { return this.company.getCompanyByTicker(ticker); } async getCompanyByCik(cik) { return this.company.getCompanyByCik(cik); } async searchCompanies(query) { return this.company.searchCompanies(query); } // Filing methods async getCompanySubmissions(cik, options = {}) { return this.filings.getCompanySubmissions(cik, options); } async getFiling(cik, accessionNumber) { return this.filings.getFiling(cik, accessionNumber); } // XBRL methods async getCompanyFacts(cik) { return this.xbrl.getCompanyFacts(cik); } async getCompanyConcept(cik, taxonomy, tag, unit) { return this.xbrl.getCompanyConcept(cik, taxonomy, tag, unit); } async getFrames(taxonomy, tag, unit, year, options = {}) { return this.xbrl.getFrames(taxonomy, tag, unit, year, options); } } exports.EdgarClient = EdgarClient; //# sourceMappingURL=edgar-client.js.map