How to Download Files from SEC EDGAR Programmatically Using an API

By · Oct 23, 2026 · 6 min read

How to Download Files from SEC EDGAR Programmatically Using an API

If you are learning how to download files from SEC EDGAR, the process starts with finding the right filing and choosing the output you need. SEC Filing Data provides a third-party API for working with filings sourced from EDGAR, the SEC’s original regulatory repository.

The overall process is to obtain API access, search for filings, select the intended report, obtain its source-document URL, request PDF generation, and save and check the returned file. We will use Apple throughout, with an annual 10-K as the target report.

This article explains that workflow and provides a filing-search example. Use the linked API documentation for endpoint-specific implementation details when connecting the steps in your application.

What Is an SEC Filings API?

An SEC filings API lets an application request filing information without someone manually searching for each report in a browser. It can help researchers and developers find company disclosures and use the returned information in their own tools.

SEC Filing Data’s SEC Filings API provides programmatic access to filings sourced from EDGAR. In this walkthrough, you will search for Apple’s filing records, identify the annual report you need, and use its source-document URL to prepare a PDF download.

Finding a filing and downloading its contents are separate steps. The search helps you identify the report; the document request retrieves the content you want to save.

What You Need Before You Start

You will need a SEC Filing Data account, a valid API token, and a subscription that includes the operations used in this walkthrough.

You will also need a terminal with cURL and a company identifier. The examples use Bash syntax, suitable for macOS, Linux, or a Bash environment on Windows. Use a cURL version that supports --fail-with-body.

Keep your token in an environment variable named SEC_FILING_DATA_TOKEN. The commands read it from that variable, so you do not need to place your credential directly in the example code. Keep the token out of shared files and screenshots.

For this walkthrough, the intended output is a readable PDF of Apple’s annual report.

How to Download SEC Filings Using SEC Filing Data’s API

1. Get API access and prepare your token

Create or sign in to your SEC Filing Data account, then follow the getting-started instructions to generate an API key from your account. Store the key securely and check that your subscription includes the operation you intend to use. If you cannot locate your API access settings, contact SEC Filing Data support for help.

The Query endpoint examples supply the token directly in the Authorization header. The request below reads that value from your environment variable.

2. Choose the company and report

For this example, the company is Apple Inc., its ticker is AAPL, and its Central Index Key, or CIK, is 320193. A CIK identifies an EDGAR filer and is useful when company names or trading symbols change.

Use the CIK to find Apple’s filing records, then select a 10-K for the reporting period you need. If you want to download 10-Q filings instead, choose the quarterly report in the returned records.

An accession number identifies an individual submission. It is different from the company identifier and should remain attached to your chosen report. An amendment, such as a 10-K/A, is a separate submission rather than an interchangeable copy of the original.

3. Search for matching filings

Send a POST request to the SEC Query API with a JSON body. For a company search, set query_type to cik and query_value to 320193.

Set SEC_FILING_DATA_TOKEN securely, then use this company-search request to write the response body to apple-filings.json.

curl --fail-with-body --silent --show-error \
  --connect-timeout 10 --max-time 60 \
  --request POST \
  'https://api.secfilingdata.com/v1/filings/query' \
  --header "Authorization: ${SEC_FILING_DATA_TOKEN:?Set SEC_FILING_DATA_TOKEN}" \
  --header 'Content-Type: application/json' \
  --data '{"query_type":"cik","query_value":"320193","from":0,"size":10,"sort_order":"DESC"}' \
  --output apple-filings.json

This is a company search, not a combined company-and-10-K filter. Inspect the records before choosing the report. To request the next page, change from from 0 to 10; the documented maximum size is 100.

Open apple-filings.json to review the results.

4. Read the results and choose the document

Inspect the response returned to your account and check the candidate filing’s company, form, filing date, and accession number wherever those details are supplied. Match them to the annual report you need before selecting a document.

Choose the main 10-K report for an annual-report download. A submission can also include exhibits, images, and supporting files. An exhibit URL identifies that attachment, so selecting it does not retrieve the main report.

Keep the selected filing’s accession number with your records. PDF generation requires the report’s source-document URL: the address of the actual report file. A company identifier, accession number, or company search page is not a substitute.

Look for a source-document link associated with the selected report in your results. If the response does not clearly identify the main document’s URL, consult the current Query documentation or ask SEC Filing Data support which value to use. Do not guess a response field or construct a URL from incomplete information.

5. Prepare the Selected Document for PDF Generation

Once you have identified the main report’s source URL, the next step is to prepare a readable PDF copy. SEC Filing Data’s Filing Download and PDF Generator API uses a filing document’s URL as the input for this process. Supply the report’s source URL through the required url parameter.

The URL should point to the document you want to convert. If you supply an exhibit’s URL, that attachment becomes the input; the service does not select the main 10-K for you.

PDF generation creates a readable copy of the selected document, not structured financial-statement data.

The documentation’s examples show two stages: requesting PDF generation and then downloading the generated file. They check the generation result using status and retrieve the file from the location in pdf_url. The examples also include fileName as a suggested filename.

Before implementing the generation request, confirm the HTTP method and authentication requirements for that operation. The reference currently gives conflicting method instructions, so the examples should not be treated as a confirmed request contract. Once the operation succeeds and supplies a generated-file URL, continue to the download step below.

6. Save the generated file and check it

After generation succeeds, retrieve the file from the returned pdf_url location.

Use the full returned pdf_url value as the address for the file request. This is the generated PDF’s location, rather than the original report’s source URL. Save the downloaded content as a PDF in your chosen folder, using a descriptive name such as apple-10-k.pdf or the returned filename.

Open the saved PDF and confirm Apple’s name, the form, and the reporting period. A file ending in .pdf is not sufficient evidence of a successful download: make sure it opens as a PDF and contains the intended report.

Retain the selected source URL and accession number with your research records. A readable converted copy should remain traceable to its original filing.

Common Problems and How to Resolve Them

For an authorization error, check your token, endpoint-specific header instructions, and subscription access. Do not expose the token in a support screenshot or log.

If a search returns no results, check the company identifier and search criteria. If the request is rejected, check your JSON syntax and that the search value matches its search type. Review the endpoint reference for the meaning of any status code returned.

If you cannot find the desired annual report, review additional result pages and confirm you selected the company’s CIK. A small company-search page can contain several filing types without including the report you want.

If the saved file will not open, inspect the HTTP result and response content. General troubleshooting includes checking whether you saved an error message or a generation response instead of the file itself. Renaming JSON or HTML to .pdf does not convert it.

Can You Download Filings Directly from SEC.gov?

Yes. You can also find and download filings directly from SEC.gov. For a company search, the SEC’s submissions JSON provides filing information that helps you identify the report you need. You can then retrieve the selected source document from the EDGAR archive. The EDGAR API guide provides further details on submissions data and the SEC’s separate financial-data APIs.

The SEC’s public data APIs do not require an API key. For automated requests, identify your application and contact information in the User-Agent header and follow the SEC’s fair-access requirements. These include a maximum of ten requests per second across machines; staying below that limit does not guarantee uninterrupted access. The Developer Resources page provides additional guidance on accessing source files and using SEC data responsibly.

With direct access, your application handles the search, document selection, and retrieval steps. SEC Filing Data uses its own API credentials and subscription terms, so the token in this walkthrough should not be sent to SEC.gov.

 

Downloading the right filing starts with identifying the company and selecting the correct report. Search the filing records, check the form and reporting period, and retain the source-document URL and accession number. For a PDF copy, use the generated file’s returned location to download it, then open the saved document to confirm its contents.

You can use the SEC Filing Data API to bring filing searches into your research or application workflow. Start with one company and one report, then expand the process as you become familiar with the responses and the services included in your plan.

Tags

Learn More

Learn about our SEC Filing API and Investor Relations Website Services.

In this article

Featured

No post found.

Tags

Get Started
Get free alerts on your SEC filings with data insights
Start for Free
Get Started
Get free alerts on your SEC filings with data insights
Start for Free