Skip to main content

Python SDK for the SecBlast SEC Filing API

Project description

SecBlast Python SDK

Python SDK for the SecBlast SEC Filing API.

Installation

pip install secblast

Quick Start

from secblast import SecBlastClient

# Initialize the client
client = SecBlastClient(api_key="your-api-key")

# Look up a company
entity = client.get_entity(ticker="AAPL")
print(f"{entity.name} (CIK: {entity.cik})")

# Search filings
filings = client.lookup_filings(
    tickers=["AAPL"],
    form_types=["10-K"],
    date_from="2023-01-01",
)
print(f"Found {filings.count} filings")

# Full-text search
results = client.fulltext_search(
    "material contract",
    form_types=["8-K"],
)
for hit in results.hits:
    print(f"{hit.accession_number}: {hit.text_content[:100]}...")

# Get financial data
balance_sheet = client.get_balance_sheet(cik="320193")

Async Support

import asyncio
from secblast import AsyncSecBlastClient

async def main():
    async with AsyncSecBlastClient(api_key="your-api-key") as client:
        entity = await client.get_entity(ticker="AAPL")
        print(entity.name)

asyncio.run(main())

API Reference

Entity Lookup

# Search entities with filters
entities = client.lookup_entities(
    tickers=["AAPL", "MSFT"],
    exchanges=["NASDAQ"],
    sics=["3571"],  # Electronic Computers
    name_includes=["tech"],
)

# Get single entity
entity = client.get_entity(ticker="AAPL")
entity = client.get_entity(cik="320193")

Filing Lookup

# Search filings
filings = client.lookup_filings(
    tickers=["AAPL"],
    form_types=["10-K", "10-Q"],
    date_from="2023-01-01",
    date_to="2023-12-31",
    exclude_amendments=True,
    sort_by="filing_date",
    sort_order="desc",
)

# Get detailed filing info
detail = client.get_filing_info("0000320193-23-000077")
print(detail.filing.form_type)
print(len(detail.documents))

# Get 10-K/10-Q sections
sections = client.get_filing_sections(document_id, form_type="10-K")
for section in sections:
    print(f"{section.id}: {section.name}")

# Batch fetch 8-K items
items = client.get_8k_items([
    "0001829126-25-010357",
    "0001213900-25-126699",
])

Full-Text Search

# Standard search
results = client.fulltext_search("revenue growth")

# Exact phrase
results = client.fulltext_search(
    "material contract",
    query_type="match_phrase",
)

# Lucene query syntax
results = client.fulltext_search(
    "revenue AND NOT loss",
    query_type="query_string",
)

# With filters
results = client.fulltext_search(
    "merger agreement",
    ciks=["320193"],
    form_types=["8-K"],
    date_from="2023-01-01",
    sort_by="_score",  # Sort by relevance
)

Documents

# Get raw document content
content = client.get_document(document_id)  # Returns bytes

# Get as JSON
doc = client.get_document(document_id, output_format="json")
print(doc.file_name, doc.content_type)

# Generate PDF
pdf_bytes = client.get_pdf(document_id=document_id)
# Or entire filing
pdf_bytes = client.get_pdf(accession_number="0000320193-23-000077")

Financial Data

# Get financial statements
balance_sheet = client.get_balance_sheet(cik="320193")
income_stmt = client.get_income_statement(cik="320193")
cash_flow = client.get_cash_flow(cik="320193")

# Get raw XBRL data
raw = client.get_raw_financials(cik="320193")

# List available filings
filings = client.list_financial_filings(cik="320193")

# Get historical data for a concept
history = client.get_financial_history(cik="320193", concept="us-gaap:Revenue")

# Export to Excel
xlsx_bytes = client.export_financials_excel(cik="320193")
with open("financials.xlsx", "wb") as f:
    f.write(xlsx_bytes)

Error Handling

from secblast import (
    SecBlastClient,
    AuthenticationError,
    RateLimitError,
    ValidationError,
)

client = SecBlastClient(api_key="your-api-key")

try:
    entity = client.get_entity(ticker="AAPL")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limit exceeded: {e.limit_type}")
except ValidationError as e:
    print(f"Invalid request: {e.message}")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secblast-0.1.8.tar.gz (74.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secblast-0.1.8-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file secblast-0.1.8.tar.gz.

File metadata

  • Download URL: secblast-0.1.8.tar.gz
  • Upload date:
  • Size: 74.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for secblast-0.1.8.tar.gz
Algorithm Hash digest
SHA256 505768aa1eb61c53d2c595d6177f4409afa394f1971b02ad5a0d87e0fdafedb7
MD5 296e153099ff35f1ab9c0776ccc277f0
BLAKE2b-256 b42e1cac242dcd36314ea99e57ea7bd998488e3e0f7407aa068b97c6ad8452a2

See more details on using hashes here.

File details

Details for the file secblast-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: secblast-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for secblast-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7738bb06d4e2a56109607360ea4ebbfda00bfb540563f5b97c0757fad42668c6
MD5 a2d4fe8ed3eded35df9dfe4975ce6f0d
BLAKE2b-256 34af182e8155d7e1b8e2ad7c78a85c3ab560f754f63d04d3bb9403399a5cbcc4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page