fredgar-ai

Comprehensive API Documentation for SEC EDGAR Database

Introduction

The U.S. Securities and Exchange Commission (SEC) provides public access to the Electronic Data Gathering, Analysis, and Retrieval (EDGAR) system through a set of RESTful APIs hosted at data.sec.gov. These APIs allow developers to retrieve company submission histories and eXtensible Business Reporting Language (XBRL) financial data in JSON format. The APIs are designed for programmatic access to EDGAR filings, enabling applications such as financial analysis tools, research platforms, and data aggregators.

Key features:

This documentation expands on the official SEC resources, providing detailed endpoint descriptions, parameters, response structures, examples, and best practices. It addresses gaps in the official explanations by including code samples, error handling details, and structured schemas derived from actual API responses.

Base URL: https://data.sec.gov

Official references (SEC):

SEC Webmaster FAQ: guidance for developers

The following summarizes the Developers portion of the SEC’s Webmaster FAQ so this repo stays aligned with how the agency describes scripted access, limits, and support. If anything disagrees with the live SEC page, treat the SEC site as authoritative.

User-Agent and “Undeclared Automated Tool”

The SEC expects automated clients to declare a User-Agent that identifies who is accessing the site. Requests without a proper declaration can produce an “Undeclared Automated Tool” error; the FAQ directs developers to the same programmatic-access guidance below.

Use a descriptive value (for example, organization or product name plus a contact email). The FAQ illustrates request headers including:

Send requests to the appropriate host (data.sec.gov for JSON APIs, www.sec.gov for Archives and HTML as applicable).

Rate limiting and fair access

The SEC states that its current maximum access rate is 10 requests per second, monitored to preserve equitable access. Details sit in the Internet Security Policy (linked from the FAQ). Treat this limit as applying across your automation footprint (multiple machines or processes under the same project or organization should aggregate under the cap).

JSON API services (data.sec.gov)

Per the FAQ, company submissions and extracted XBRL data are available via RESTful APIs on data.sec.gov returning JSON. The SEC points to its EDGAR APIs overview for that material.

“Access Denied”

If you receive Access Denied, the FAQ asks you to email webmaster@sec.gov with a screenshot or the error text and your IP address so staff can assist.

Programmatic downloads: support boundaries

The SEC does not provide technical support for writing code to download EDGAR filings. Scripted access is allowed. The FAQ highlights:

Availability and lag

For documents on www.sec.gov, the FAQ states that filings are often available within about one to three minutes of the EDGAR system timestamp, but lag can increase under load. The SEC does not guarantee timing and cannot predict it. There is no separate timestamp for “first visible on sec.gov.”

Near–real-time discovery

To get as close as possible to when new filings appear on www.sec.gov, the FAQ recommends Latest Filings and the associated RSS feeds, while reminding readers to respect the Internet Security Policy. For a subscription-style feed, see the SEC’s EDGAR Public Dissemination Service contact page.

Email alerts and RSS

The SEC does not offer email notifications specifically for EDGAR filings; dynamic RSS is available for some searches (SEC RSS). Non-EDGAR email updates are offered separately from the sec.gov home page.

Ticker, CIK, and company name

The FAQ lists two mapping files (periodically updated; accuracy and scope are not guaranteed):

File URL Contents
Tab-delimited ticker ↔ CIK ticker.txt Used for Company Search “fast search.”
JSON ticker ↔ CIK ↔ name company_tickers.json EDGAR conformed names; used for home-page typeahead.

Rate Limits and Best Practices

Operational summary (see SEC Webmaster FAQ: guidance for developers above for official wording and links):

Best practices (in addition to SEC expectations):

Authentication

No authentication is required. APIs are public and do not use API keys, tokens, or credentials.

Error Handling

Responses use standard HTTP status codes. Common errors include:

Error responses may include a JSON body with details, e.g., {"error": "Invalid CIK"}. Always check the status code and parse the body for messages.

Endpoints

1. Submissions API

Description: Retrieves the filing history for a specific entity, including metadata (e.g., company name, tickers, addresses) and a list of recent filings (up to 1,000 or one year, whichever is larger). Additional historical filings are referenced in separate JSON files.

Endpoint: /submissions/CIK{10-digit-cik}.json

Method: GET

Parameters:

Response Format: JSON object with company metadata and filings.

Example Request:

GET https://data.sec.gov/submissions/CIK0000320193.json
User-Agent: YourCompany your@email.com

Example Response Snippet:

{
  "cik": "0000320193",
  "entityType": "operating",
  "sic": "3571",
  "sicDescription": "Electronic Computers",
  "name": "Apple Inc.",
  "tickers": ["AAPL"],
  "exchanges": ["Nasdaq"],
  "ein": "942404110",
  "addresses": {
    "mailing": {
      "street1": "ONE APPLE PARK WAY",
      "city": "CUPERTINO",
      "stateOrCountry": "CA",
      "zipCode": "95014"
    },
    "business": { ... }
  },
  "phone": "(408) 996-1010",
  "formerNames": [ ... ],
  "filings": {
    "recent": {
      "accessionNumber": ["0000320193-24-000069", ...],
      "filingDate": ["2024-05-03", ...],
      "form": ["10-Q", ...],
      "size": [5304776, ...],
      "isXBRL": [1, ...],
      "primaryDocument": ["aapl-20240330.htm", ...]
    },
    "files": [ ... ]
  }
}

Bulk Download: Full submissions data in ZIP format.

Code Example (Python):

import requests

headers = {'User-Agent': 'YourCompany your@email.com'}
response = requests.get('https://data.sec.gov/submissions/CIK0000320193.json', headers=headers)
if response.status_code == 200:
    data = response.json()
    print(data['name'])  # Output: Apple Inc.
else:
    print(f"Error: {response.status_code}")

2. XBRL Company Concept API

Description: Returns all XBRL disclosures for a single company and a specific concept (taxonomy/tag), organized by units (e.g., USD). Facts are from non-custom taxonomies and apply to the entire entity.

Endpoint: /api/xbrl/companyconcept/CIK{10-digit-cik}/{taxonomy}/{tag}.json

Method: GET

Parameters:

Response Format: JSON object with concept metadata and facts.

Example Request:

GET https://data.sec.gov/api/xbrl/companyconcept/CIK0000320193/us-gaap/AccountsPayableCurrent.json
User-Agent: YourCompany your@email.com

Example Response Snippet:

{
  "cik": 320193,
  "taxonomy": "us-gaap",
  "tag": "AccountsPayableCurrent",
  "label": "Accounts Payable, Current",
  "description": "Carrying value as of the balance sheet date of liabilities incurred... (truncated)",
  "entityName": "Apple Inc.",
  "units": {
    "USD": [
      {
        "end": "2008-09-27",
        "val": 5520000000,
        "accn": "0001193125-09-214859",
        "fy": 2009,
        "fp": "FY",
        "form": "10-K",
        "filed": "2009-10-27"
      },
      // Additional facts...
    ]
  }
}

Bulk Download: Not specific; use Company Facts bulk for related data.

Code Example (Python):

import requests

headers = {'User-Agent': 'YourCompany your@email.com'}
url = 'https://data.sec.gov/api/xbrl/companyconcept/CIK0000320193/us-gaap/AccountsPayableCurrent.json'
response = requests.get(url, headers=headers)
if response.status_code == 200:
    data = response.json()
    print(data['label'])  # Output: Accounts Payable, Current

3. XBRL Company Facts API

Description: Aggregates all XBRL facts for a company across concepts, from non-custom taxonomies, for consistent comparison.

Endpoint: /api/xbrl/companyfacts/CIK{10-digit-cik}.json

Method: GET

Parameters:

Response Format: JSON object with all concepts.

Example Request:

GET https://data.sec.gov/api/xbrl/companyfacts/CIK0000320193.json
User-Agent: YourCompany your@email.com

Example Response Snippet:

{
  "cik": "320193",
  "entityName": "Apple Inc.",
  "facts": {
    "us-gaap": {
      "Assets": {
        "label": "Assets",
        "description": "Sum of the carrying amounts as of the balance sheet date of all assets...",
        "units": {
          "USD": [
            {
              "end": "2014-09-27",
              "val": 23353000000,
              "accn": "0001193125-14-383437",
              "fy": 2014,
              "fp": "FY",
              "form": "10-K",
              "filed": "2014-10-27"
            },
            // Additional facts...
          ]
        }
      },
      // Additional concepts...
    }
  }
}

Bulk Download: Full company facts ZIP.

Code Example (Python):

import requests

headers = {'User-Agent': 'YourCompany your@email.com'}
url = 'https://data.sec.gov/api/xbrl/companyfacts/CIK0000320193.json'
response = requests.get(url, headers=headers)
if response.status_code == 200:
    data = response.json()
    print(data['facts']['us-gaap']['NetIncomeLoss']['label'])  # Output: Net Income (Loss)

4. XBRL Frames API

Description: Aggregates the latest fact for each reporting entity fitting a specified calendrical period (annual, quarterly, or instantaneous). Supports non-custom taxonomies.

Endpoint: /api/xbrl/frames/{taxonomy}/{tag}/{unit}/{period}.json

Method: GET

Parameters:

Response Format: JSON object with aggregated facts across entities.

Example Request:

GET https://data.sec.gov/api/xbrl/frames/us-gaap/AccountsPayableCurrent/USD/CY2019Q1I.json
User-Agent: YourCompany your@email.com

Example Response Snippet:

{
  "taxonomy": "us-gaap",
  "tag": "AccountsPayableCurrent",
  "ccp": "CY2019Q1I",
  "uom": "USD",
  "label": "Accounts Payable, Current",
  "description": "Carrying value as of the balance sheet date of liabilities incurred... (truncated)",
  "pts": 3390,
  "data": [
    {
      "accn": "0001104659-19-016320",
      "cik": 1750,
      "entityName": "AAR CORP.",
      "loc": "US-IL",
      "end": "2019-02-28",
      "val": 218600000
    },
    // Additional entities...
  ]
}

Bulk Download: Not specific; use related XBRL ZIPs for bulk access.

Code Example (Python):

import requests

headers = {'User-Agent': 'YourCompany your@email.com'}
url = 'https://data.sec.gov/api/xbrl/frames/us-gaap/AccountsPayableCurrent/USD/CY2019Q1I.json'
response = requests.get(url, headers=headers)
if response.status_code == 200:
    data = response.json()
    print(data['pts'])  # Output: Number of aggregated facts

Additional Resources

This document combines the SEC’s published guidance (including the Webmaster FAQ Developers section last noted as reviewed August 2024 on that page) with endpoint notes and examples maintained in this repository. Always verify against sec.gov.