Download Original SEC Filing API

Download original SEC EDGAR filing documents using their original SEC filing URLs. This API retrieves the requested filing document in its original format and returns the file contents directly in the API response.

Unlike the PDF Generation API, this endpoint does not convert documents to PDF. It preserves the original filing format, including HTML, TXT, XML, and supported exhibits.

Dataset: SEC EDGAR filings, exhibits, and filing documents available in the SEC filing directory.

Output: Original document bytes (the response is a file download, not JSON).

API Endpoint

POST https://api.secfilingdata.com/v1/filings/download-original

Supported HTTP method: POST

Authentication

All requests require an API token in the Authorization header.

Authorization: YOUR_API_TOKEN

Request Parameters

Parameter Type Required Description
url string Required The original SEC filing document URL. The URL must point to a document in the SEC EDGAR Archives directory.
file_type string Optional Document type to download. Supported values: primary_document, complete_submission, xml, and exhibit. Defaults to primary_document.
document_name string Conditional Exact filename listed in the SEC filing directory. Required when file_type is xml or exhibit.

Supported File Types

file_type Description document_name
primary_document Downloads the main document specified in the SEC filing URL. Not required
complete_submission Downloads the complete SEC submission TXT file for the accession. Not required
xml Downloads a specific XML document listed in the filing directory. Required; must be the exact XML filename.
exhibit Downloads a specific exhibit listed in the filing directory. Required; must be the exact exhibit filename.

Request Example

{
    "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
    "file_type": "primary_document"
}

Request Examples by File Type

1. Primary document

{
    "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
    "file_type": "primary_document"
}

2. Complete submission

{
    "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
    "file_type": "complete_submission"
}

3. XML document

{
    "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
    "file_type": "xml",
    "document_name": "YOUR_XML_FILENAME.xml"
}

4. Exhibit

{
    "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
    "file_type": "exhibit",
    "document_name": "YOUR_EXHIBIT_FILENAME.htm"
}

Response

On success, the API returns the original document bytes directly in the HTTP response. The response is not a JSON object and does not contain a separate download URL. The response includes a content type and an attachment filename so the client can save the document.

HTTP/1.1 200 OK
Content-Type: text/html
Content-Disposition: attachment; filename="ko-20251231.htm"
Content-Length: [document size]

[Original SEC filing document bytes]

Error Responses

If the request cannot be completed, the API returns a JSON error response with an appropriate HTTP status code.

HTTP Status Description
400 Missing URL, invalid file type, invalid SEC URL, or missing/invalid document name.
404 SEC filing index or requested document was not found.
500 Internal error, storage initialization error, or file handling error.
502 Unable to retrieve the filing index or original document from SEC/GCS.
503 SEC rate-limit lock could not be acquired or the request could not proceed.

Example error response

{
    "status": false,
    "message": "Requested document was not found in SEC filing directory.",
    "document_name": "YOUR_EXHIBIT_FILENAME.htm"
}

Code Examples

The examples below send one POST request and save the binary response directly to a file. Replace YOUR_API_TOKEN with your API token and update the request parameters for the document you want to download.

<?php

$apiUrl = "https://api.secfilingdata.com/v1/filings/download-original";
$authToken = "YOUR_API_TOKEN";

$postData = [
    'url' => 'https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm',
    'file_type' => 'primary_document'
];

$savePath = __DIR__ . '/ko-20251231.htm';

$ch = curl_init($apiUrl);

curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($postData),
    CURLOPT_RETURNTRANSFER => false,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_CONNECTTIMEOUT => 30,
    CURLOPT_TIMEOUT => 300,
    CURLOPT_HTTPHEADER => [
        "Authorization: {$authToken}",
        "Content-Type: application/json"
    ]
]);

// Save the binary response to a file.
$file = fopen($savePath, 'wb');

if (!$file) {
    die("Unable to create output file.");
}

curl_setopt($ch, CURLOPT_FILE, $file);

$result = curl_exec($ch);

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$curlError = curl_error($ch);
$curlErrno = curl_errno($ch);

$fileSize = ftell($file);

curl_close($ch);
fclose($file);

if ($result === false || $httpCode !== 200 || $fileSize <= 0) {
    @unlink($savePath);
    die("Download failed. HTTP: {$httpCode}; cURL: {$curlError}");
}

echo "File downloaded successfully: {$savePath}";
echo "\nSize: " . number_format($fileSize) . " bytes";
echo "\nContent-Type: " . $contentType;
?>
import requests

api_url = "https://api.secfilingdata.com/v1/filings/download-original"

headers = {
    "Authorization": "YOUR_API_TOKEN",
    "Content-Type": "application/json"
}

payload = {
    "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
    "file_type": "primary_document"
}

save_path = "ko-20251231.htm"

with requests.post(
    api_url,
    json=payload,
    headers=headers,
    stream=True,
    timeout=300
) as response:

    if response.status_code != 200:
        raise Exception(
            f"API error {response.status_code}: {response.text}"
        )

    with open(save_path, "wb") as file:
        for chunk in response.iter_content(chunk_size=1024 * 1024):
            if chunk:
                file.write(chunk)

print(f"File downloaded successfully: {save_path}")
const apiUrl = "https://api.secfilingdata.com/v1/filings/download-original";

const payload = {
    url: "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
    file_type: "primary_document"
};

fetch(apiUrl, {
    method: "POST",
    headers: {
        "Authorization": "YOUR_API_TOKEN",
        "Content-Type": "application/json"
    },
    body: JSON.stringify(payload)
})
.then(async response => {
    if (!response.ok) {
        const errorText = await response.text();
        throw new Error(`API error ${response.status}: ${errorText}`);
    }

    return response.blob();
})
.then(blob => {
    const downloadUrl = URL.createObjectURL(blob);
    const link = document.createElement("a");

    link.href = downloadUrl;
    link.download = "ko-20251231.htm";

    document.body.appendChild(link);
    link.click();
    link.remove();

    URL.revokeObjectURL(downloadUrl);
})
.catch(console.error);
const axios = require("axios");
const fs = require("fs");

(async () => {
    const apiUrl = "https://api.secfilingdata.com/v1/filings/download-original";

    const payload = {
        url: "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
        file_type: "primary_document"
    };

    const response = await axios.post(apiUrl, payload, {
        headers: {
            Authorization: "YOUR_API_TOKEN",
            "Content-Type": "application/json"
        },
        responseType: "stream",
        timeout: 300000
    });

    const savePath = "ko-20251231.htm";
    const writer = fs.createWriteStream(savePath);

    response.data.pipe(writer);

    writer.on("finish", () => {
        console.log(`File downloaded successfully: ${savePath}`);
    });

    writer.on("error", error => {
        console.error("File write failed:", error);
    });
})().catch(error => {
    if (error.response) {
        console.error("API error:", error.response.status);
        console.error(error.response.data);
    } else {
        console.error(error.message);
    }
});
curl --fail-with-body -X POST \
  "https://api.secfilingdata.com/v1/filings/download-original" \
  -H "Authorization: YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{
    "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
    "file_type": "primary_document"
  }' \
  --output ko-20251231.htm
package main

import (
    "bytes"
    "fmt"
    "io"
    "net/http"
    "os"
)

func main() {
    apiURL := "https://api.secfilingdata.com/v1/filings/download-original"

    payload := []byte(`{
        "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
        "file_type": "primary_document"
    }`)

    req, err := http.NewRequest("POST", apiURL, bytes.NewReader(payload))
    if err != nil {
        panic(err)
    }

    req.Header.Set("Authorization", "YOUR_API_TOKEN")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    response, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer response.Body.Close()

    if response.StatusCode != http.StatusOK {
        body, _ := io.ReadAll(response.Body)
        panic(fmt.Sprintf("API error %d: %s", response.StatusCode, body))
    }

    file, err := os.Create("ko-20251231.htm")
    if err != nil {
        panic(err)
    }
    defer file.Close()

    if _, err := io.Copy(file, response.Body); err != nil {
        panic(err)
    }

    fmt.Println("File downloaded successfully: ko-20251231.htm")
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    public static void main(String[] args) throws Exception {
        String apiUrl = "https://api.secfilingdata.com/v1/filings/download-original";

        String json = """
        {
            "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
            "file_type": "primary_document"
        }
        """;

        HttpClient client = HttpClient.newHttpClient();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(apiUrl))
            .header("Authorization", "YOUR_API_TOKEN")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();

        HttpResponse response = client.send(
            request,
            HttpResponse.BodyHandlers.ofByteArray()
        );

        if (response.statusCode() != 200) {
            throw new RuntimeException(
                "API error " + response.statusCode() + ": " +
                new String(response.body())
            );
        }

        Path output = Path.of("ko-20251231.htm");
        Files.write(output, response.body());

        System.out.println("File downloaded successfully: " + output);
    }
}
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var apiUrl = "https://api.secfilingdata.com/v1/filings/download-original";

        using var client = new HttpClient
        {
            Timeout = TimeSpan.FromMinutes(5)
        };

        var json = """
        {
            "url": "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
            "file_type": "primary_document"
        }
        """;

        using var request = new HttpRequestMessage(HttpMethod.Post, apiUrl);
        request.Headers.Add("Authorization", "YOUR_API_TOKEN");
        request.Content = new StringContent(
            json,
            Encoding.UTF8,
            "application/json"
        );

        using var response = await client.SendAsync(
            request,
            HttpCompletionOption.ResponseHeadersRead
        );

        if (!response.IsSuccessStatusCode)
        {
            var error = await response.Content.ReadAsStringAsync();
            throw new Exception(
                $"API error {(int)response.StatusCode}: {error}"
            );
        }

        await using var input = await response.Content.ReadAsStreamAsync();
        await using var output = File.Create("ko-20251231.htm");

        await input.CopyToAsync(output);

        Console.WriteLine("File downloaded successfully.");
    }
}
require "net/http"
require "uri"
require "json"

api_url = URI("https://api.secfilingdata.com/v1/filings/download-original")

payload = {
  url: "https://www.sec.gov/Archives/edgar/data/21344/000162828026010047/ko-20251231.htm",
  file_type: "primary_document"
}.to_json

request = Net::HTTP::Post.new(api_url)
request["Authorization"] = "YOUR_API_TOKEN"
request["Content-Type"] = "application/json"
request.body = payload

Net::HTTP.start(
  api_url.hostname,
  api_url.port,
  use_ssl: true
) do |http|

  http.request(request) do |response|
    unless response.code.to_i == 200
      error_body = response.read_body
      abort("API error #{response.code}: #{error_body}")
    end

    File.open("ko-20251231.htm", "wb") do |file|
      response.read_body do |chunk|
        file.write(chunk)
      end
    end
  end
end

puts "File downloaded successfully: ko-20251231.htm"

Important Notes

  • The API returns the original document directly. Clients should save the HTTP response body as a file instead of attempting to decode it as JSON on successful responses.
  • The file_type parameter defaults to primary_document when it is omitted.
  • For xml and exhibit requests, provide the exact filename from the SEC filing directory in document_name.
  • The API uses cached filing documents when available. If a requested document is not cached, it retrieves the original document and caches it for subsequent requests.
  • The API preserves the original document format; it does not convert the document to PDF.