Documents
Retrieve raw document content and generate PDFs from SEC filings.
getDocument()
Retrieve the raw content of a document as a string (HTML, XML, TXT, etc.).
Parameters
| Name | Type | Description |
|---|---|---|
document_idrequired | string | Document ID in format: {accession_number}-{sequence} |
typescript
const content = await client.getDocument({
document_id: '0000320193-24-000123-1'
});
console.log(`Document length: ${content.length} characters`);
if (content.startsWith('<!DOCTYPE html')) {
console.log('HTML document');
} else if (content.startsWith('<?xml')) {
console.log('XML document');
}generatePdf()
Generate a PDF from a single document or an entire filing.
Parameters
| Name | Type | Description |
|---|---|---|
document_id | string | Document ID for single document PDF |
accession_number | string | Accession number for full filing PDF |
Single Document
typescript
const pdf = await client.generatePdf({
document_id: '0000320193-24-000123-1'
});
// Browser - create download link
const url = URL.createObjectURL(pdf);
const a = document.createElement('a');
a.href = url;
a.download = 'document.pdf';
a.click();Entire Filing
typescript
// Generate PDF of entire filing (combines all HTML documents)
const pdf = await client.generatePdf({
accession_number: '0000320193-24-000123'
});
// Node.js - save to file
import { writeFile } from 'fs/promises';
const buffer = Buffer.from(await pdf.arrayBuffer());
await writeFile('filing.pdf', buffer);