npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sec-data-fetcher

v1.0.2

Published

An npm library to fetch SEC data from all supported endpoints with rate limiting.

Downloads

13

Readme

SEC Data Fetcher

An npm library to fetch SEC data from all supported endpoints with rate limiting, written in TypeScript.

Features

  • CIK Lookup: Lookup Central Index Key (CIK) using a company's ticker symbol.
  • Company Data: Retrieve company submission data.
  • Reports: Fetch recent filings (e.g., 10-Q, 10-K, 8-K) after a specified date.
  • Company Facts: Get standardized fundamental data.
  • Parse Filings: Parse SEC filings from URLs or strings into structured objects.
  • Rate Limiting: Configurable rate limiting to comply with SEC guidelines.
  • TypeScript Support: Includes types for better TypeScript integration.
  • Customizable User-Agent: Set your own User-Agent string as required by the SEC.

Installation

npm install sec-data-fetcher

Usage

import { SECClient } from 'sec-data-fetcher';

// Initialize the SECClient with your User-Agent
const secClient = new SECClient({
  userAgent: 'Your Company Name [email protected]',
});

(async () => {
  // Lookup CIK
  const cik = await secClient.cikLookup('AAPL');
  console.log('CIK:', cik);

  if (cik) {
    // Get Company Data
    const companyData = await secClient.getCompanyData(cik);
    console.log('Company Data:', companyData);

    // Get Reports
    const reports = await secClient.getReports(cik);
    console.log('Reports:', reports);

    // Parse a filing from URL
    if (reports.length > 0) {
      const filingUrl = `https://www.sec.gov/Archives/edgar/data/${parseInt(
        cik,
        10,
      )}/${reports[0].accessionNumber.replace(/-/g, '')}/${
        reports[0].primaryDocument
      }`;
      const filingObject = await secClient.getObjectFromUrl(filingUrl);
      console.log('Filing Object:', filingObject);
    }
  }
})();

API Reference

SECClient

Constructor

new SECClient(options: SECClientOptions)

Methods

  • cikLookup(ticker: string): Promise<string | null>
  • getCompanyData(cik: string): Promise
  • getReports(cik: string, after?: Date, forms?: string[]): Promise<Filing[]>
  • getCompanyFacts(cik: string): Promise
  • getObjectFromString(content: string): FilingObject
  • getObjectFromUrl(url: string): Promise
  • fetchFiling(url: string): Promise
    Fetches the raw HTML content of an SEC filing from the provided URL.
  • extractTablesFromFilingUrl(url: string): Promise<Array<Array<Array>>>
    Fetches the filing content from a URL and extracts tables from the filing.
  • extractTablesFromContent(filingContent: string): Array<Array<Array>>
    Extracts tables from the provided raw HTML content of an SEC filing.

Extract Tables from SEC Filings

The package provides two ways to extract tables from SEC filings:

  1. Extract from a URL: Fetch and extract tables directly from an SEC filing URL.
  2. Extract from provided HTML content: Extract tables from the provided HTML content when you already have the filing data.
import { SECClient } from 'sec-data-fetcher';

const secClient = new SECClient({
  userAgent: 'Your Company <[email protected]>',
});

// Extract tables from an SEC filing URL
const tablesFromUrl = await secClient.extractTablesFromFilingUrl(
  'https://www.sec.gov/...',
);

// Extract tables from provided HTML content
const filingContent = '<html>...</html>';
const tablesFromContent = secClient.extractTablesFromContent(filingContent);

Notes

  • Ensure that you comply with the SEC’s Terms of Use.
  • All requests include the required headers (User-Agent, Accept-Encoding, and Host).
  • The library includes rate limiting to prevent exceeding the SEC’s request limits.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

MIT License. See the LICENSE file for details.

Disclaimer

This library is provided as-is and is not affiliated with or endorsed by the U.S. Securities and Exchange Commission. Use this library responsibly and in compliance with the SEC’s Terms of Use.