SEC-API.io TypeScript and JavaScript Library

repository·master·Indexed 43 days ago

https://github.com/sec-api-io/sec-api-node

A comprehensive TypeScript and JavaScript library (version 4.0.8) for accessing SEC EDGAR data. It provides tools for querying filings, full-text search, real-time filing streams via WebSocket, and downloading individual filings or bulk datasets. The library includes specialized APIs for XBRL-to-JSON conversion, section extraction from 10-K/10-Q/8-K filings, PDF generation, and accessing Form ADV investment adviser data.

Tokens
21.2K
Snippets
72
Records
74
Agent score
53%

What's inside SEC-API.io

  1. Overview of SEC-API.io features

    master

    The library provides access to a wide range of SEC data through various specialized APIs, including:

    • Search & Download: SEC EDGAR Filings Query, Full-Text Search, Real-Time Filing Stream, and Filing/Exhibit Download.
    • Bulk Datasets: Complete EDGAR filing datasets.
    • Converters & Extractors: XBRL-to-JSON and 10-K/10-Q/8-K section extraction.
    • Ownership & Investment Data: Insider trading (Forms 3, 4, 5), Institutional holdings (13F, 13D/G), and Investment Adviser data (Form ADV).
    • Security Offerings: Registration statements (S-1/424B4), Crowdfunding (Form C), and Private Offerings (Form D).
    • Public Company Data: Directors, Executive Compensation, and Subsidiary information.
    • Enforcement & Legal: SEC Enforcement Actions, Litigation Releases, and AAER database.
  2. Understand the Insider Trading API response format

    master

    The insiderTradingApi.getData() method returns an object containing a total count and a transactions array. Each transaction object represents a specific filing and contains detailed information about the issuer, the reporting owner, and the specific trades or holdings.

    Key Response Fields

    • total: An object containing the value and the relation (e.g., gte, eq) to the total number of matches.
    • transactions: An array of filing objects. Common fields include:
      • issuer: Contains cik, name, and tradingSymbol.
      • reportingOwner: Contains the owner's cik, name, address, and relationship (e.g., isDirector, isOfficer).
      • nonDerivativeTable: Contains transactions (for Form 4/5) or holdings (for Form 3) involving common stock or other non-derivative securities. Includes amounts (shares, price, etc.) and postTransactionAmounts.
      • derivativeTable: (Primarily for Form 4) Contains transactions involving derivatives like Restricted Stock Units.
      • footnotes: An array of objects with id and text providing context for transactions.
      • filedAt: The timestamp when the document was filed.
    {
      "total": { "value": 837, "relation": "eq" },
      "transactions": [
        {
          "id": "b5e3ff9eca7a16f1b7fef6aef6767fbc",
          "accessionNo": "0001104659-26-025379",
          "filedAt": "2026-03-09T19:00:14-04:00",
          "documentType": "4",
          "issuer": {
            "cik": "1318605",
            "name": "Tesla, Inc.",
            "tradingSymbol": "TSLA"
          },
          "reportingOwner": {
            "name": "Taneja Vaibhav",
            "relationship": { "isOfficer": true }
          }
          // ...
        }
      ]
    }
  3. Connect to the Filings Real-Time Stream API via WebSocket

    master

    The Stream API provides a real-time push-based feed of the latest SEC EDGAR filings via a WebSocket connection. This ensures you receive metadata for new filings as soon as they become available.

    To implement this, use a WebSocket client (like ws) to connect to wss://stream.sec-api.io?apiKey=YOUR_API_KEY. Listen for the message event to receive and parse the incoming filing data.

    const WebSocket = require('ws');
    
    const API_KEY = 'YOUR_API'; // replace this with your actual API key
    const STREAM_API_URL = 'wss://stream.sec-api.io?apiKey=' + API_KEY;
    
    const ws = new WebSocket(STREAM_API_URL);
    
    ws.on('open', () => console.log('✅ Connected to:', STREAM_API_URL));
    ws.on('close', () => console.log('Connection closed'));
    ws.on('error', (err) => console.log('Error:', err.message));
    
    ws.on('message', (message) => {
      const filings = JSON.parse(message.toString());
      filings.forEach((filing) => {
        console.log(
          filing.id,
          filing.cik,
          filing.formType,
          filing.filedAt,
          filing.linkToFilingDetails,
        );
      });
    });
  4. Import the SEC-API library

    master

    The sec-api-node library provides a unified entrypoint for accessing various SEC data APIs. You can import the default secApi object or use named exports to access specific API modules directly. To use the library, you must first set your API key using setApiKey.

    import secApi, {
      setApiKey,
      queryApi,
      fullTextSearchApi
    } from 'sec-api';
    
    // Set your API key before making calls
    setApiKey('YOUR_API_KEY');
  5. Set your SEC-API.io API Key

    master

    Before making any API calls, you must authenticate by setting your API key. The library uses a global store for the key, which is updated via the setApiKey method. This method is available on all top-level API modules.

    const secApi = require('sec-api');
    
    // Set the API key globally for the library
    secApi.queryApi.setApiKey('YOUR_API_KEY');
    const secApi = require('sec-api');
    secApi.queryApi.setApiKey('YOUR_API_KEY');
  6. Download entire SEC filing datasets

    master

    Use the datasetsApi object to download complete, bulk datasets of SEC filings (e.g., all 10-K filings or all 13-F holdings). You must authenticate using setApiKey('YOUR_API_KEY') before calling download(datasetName).

    const { datasetsApi } = require('sec-api');
    
    datasetsApi.setApiKey('YOUR_API_KEY');
    
    // downloads all 10-K filings (1993-present) to ./sec-api-datasets/form-10k-content/YYYY/YYYY-MM.zip
    await datasetsApi.download('form-10k-content');
    
    // all 13-F institutional holdings
    await datasetsApi.download('form-13f-holdings');
  7. Download individual EDGAR filings

    master

    Use the downloadApi object to retrieve specific SEC filings or exhibits. You must first authenticate using setApiKey('YOUR_API_KEY'). The getFile method allows you to download a filing by providing its SEC URL. Note that accounts are typically limited to 200 downloads per second.

    const { downloadApi } = require('sec-api');
    
    downloadApi.setApiKey('YOUR_API_KEY');
    
    // 200 downloads / second per account
    const filing = await downloadApi.getFile(
      'https://www.sec.gov/Archives/edgar/data/1318605/000162828025045968/tsla-20250930.htm',
    );
    
    console.log(filing.slice(0, 1000));
  8. Access Audit Fees data via Audit Fees Data API

    master

    The auditFeesApi allows you to access audit fee data disclosed in proxy statements (DEF 14A). This includes fees paid to auditors for audit services, audit-related services, tax services, and other services. Use getData to query the database.

    const { auditFeesApi } = require('sec-api');
    
    auditFeesApi.setApiKey('YOUR_API_KEY');
    
    const data = await auditFeesApi.getData({
      query: 'cik:1318605',
      from: '0',
      size: '10',
      sort: [{ filedAt: { order: 'desc' } }],
    });
    // response: { total, data }
  9. Access SEC Litigation Releases via Litigation Releases API

    master

    The secLitigationsApi provides access to SEC litigation releases that announce civil lawsuits filed by the SEC in federal courts. Use getData to query the database using a query string.

    const { secLitigationsApi } = require('sec-api');
    
    secLitigationsApi.setApiKey('YOUR_API_KEY');
    
    const data = await secLitigationsApi.getData({
      query: 'releasedAt:[2024-01-01 TO 2024-12-31]',
      from: '0',
      size: '50',
      sort: [{ releasedAt: { order: 'desc' } }],
    });
    // response: { total, data }
  10. Query Form D filings with formDApi

    master

    Use the formDApi module to access Form D filings, which report private securities offerings exempt from SEC registration (e.g., Regulation D).

    To use this API:

    1. Import formDApi from sec-api.
    2. Authenticate using formDApi.setApiKey('YOUR_API_KEY').
    3. Call formDApi.getData() with a configuration object containing:
      • query: A Lucene-style query string to filter filings (e.g., filtering by offeringSalesAmounts.totalOfferingAmount).
      • from: The starting offset for pagination.
      • size: The number of results to return.
      • sort: An array of objects defining the sort order (e.g., [{ filedAt: { order: 'desc' } }]).

    The response returns an object containing total (metadata about the result set) and offerings (an array of filing objects).

    const { formDApi } = require('sec-api');
    
    formDApi.setApiKey('YOUR_API_KEY');
    
    const data = await formDApi.getData({
      query: 'offeringData.offeringSalesAmounts.totalOfferingAmount:[1000000 TO *]',
      from: '0',
      size: '50',
      sort: [{ filedAt: { order: 'desc' } }],
    });
    // response: { total, offerings }