Skip to main content

Python SDK for SEC API

Project description

SEC API Python SDK

Python SDK for SEC API -- SEC filings, financial statements, ownership data, and more.

Installation

pip install secapi-client

Configuration

from omni_datastream_py import SecApiClient

client = SecApiClient(
    api_key="ods_test_...",
    # Optional: override base URL (defaults to https://api.secapi.ai)
    # base_url="http://127.0.0.1:8787",
)

You can also authenticate with a Bearer token:

client = SecApiClient(bearer_token="your-bearer-token")

OmniDatastreamClient and OmniDatastreamError remain available for existing integrations.

Environment Variables

Variable Description
SECAPI_API_KEY Your SEC API key (starts with ods_)
OMNI_DATASTREAM_API_KEY Legacy fallback for existing integrations

Configuration Options

Parameter Default Description
api_key None API key authentication
bearer_token None Bearer token authentication
base_url https://api.secapi.ai API base URL
api_version 2026-03-19 API version header
retry None Retry configuration, or False to disable SDK retries
telemetry None Retry telemetry configuration, or False to opt out

Reliability

The SDK retries transient failures with exponential backoff and jitter. Defaults:

  • Auto-retried by default: GET, HEAD, OPTIONS
  • Opt-in required: POST, PUT, PATCH, DELETE, MCP tools/call
  • Always retried regardless of method: 429 rate limits, with Retry-After honored
  • Retryable failures: network errors, 408, 429, 502, 503, 504
  • Never retried: 400, 401, 403, 404, 422
  • Backoff: base 200ms, max 5s, max retries 3, total budget 30s
  • Circuit breaker: opens after 5 consecutive retryable failures, cools down for 60s

Disable retries globally if you already wrap the SDK with your own retry layer:

client = SecApiClient(
    api_key="ods_test_...",
    retry=False,
)

Per-call overrides are supported:

filing = client.latest_filing(ticker="AAPL", form="10-K", retry=False)

artifact = client.create_artifact(
    {"kind": "audit", "payload": {"ticker": "AAPL"}},
    retry={"enabled": True, "idempotency_key": "artifact-aapl-audit-2026-05-01"},
)

Only opt into retries for mutating requests when the operation is idempotent from your application's point of view. Provide an idempotency key so ambiguous network failures can be correlated safely.

Retry telemetry emits anonymous client_retry_attempt events to SEC API's telemetry project. Set telemetry=False globally or per call to opt out.

Quickstart

import os
from omni_datastream_py import SecApiClient

api_key = os.environ.get("SECAPI_API_KEY") or os.environ["OMNI_DATASTREAM_API_KEY"]
client = SecApiClient(api_key=api_key)

# Resolve a company entity
entity = client.resolve_entity(ticker="AAPL")
print(entity)

# Get the latest 10-K filing
filing = client.latest_filing(ticker="AAPL", form="10-K")
print(filing)

# Extract a specific section
section = client.latest_section(
    section_key="item_1a",
    ticker="AAPL",
    form="10-K",
    mode="compact",
)
print(section)

Common Use Cases

Financial Statements

# XBRL facts
facts = client.facts(ticker="AAPL", tag="Assets", taxonomy="us-gaap", limit=5)

# Full financial statements
statements = client.all_statements(ticker="AAPL", period="annual", limit=3)

Ownership and Institutional Holdings

# Latest 13F filing (institutional holdings)
holdings = client.latest_13f(cik="0001067983", limit=10)

Market Data

# Market calendar
calendar = client.market_calendar(market="XNYS", duration=3)

# Volatility signal
vol = client.volatility_signal(ticker="AAPL")

Offerings and M&A

# IPO and offering filings
offerings = client.offerings(forms="S-1,424B4", limit=3)

Diagnostics

# Artifact summary (data freshness)
summary = client.artifact_summary()

# System observability (requires admin:operator)
operator_client = SecApiClient(api_key=os.environ["OMNI_OPERATOR_API_KEY"])
obs = operator_client.observability()

Error Handling

from omni_datastream_py import SecApiClient, SecApiError

client = SecApiClient(api_key="ods_test_...")

try:
    result = client.resolve_entity(ticker="INVALID")
except SecApiError as e:
    print(f"Status: {e.status}")
    print(f"Payload: {e.payload}")

Scope

The Python SDK covers the full REST surface including:

  • Entity resolution and search
  • Filing retrieval and section extraction
  • XBRL facts and financial statements
  • Offerings, market calendar, and volatility signals
  • Ownership, insiders, and compensation data
  • Institutional holdings (13F)
  • Enforcement actions and M&A events
  • Artifacts, diagnostics, and observability
  • Events, streams, and webhooks

MCP (Model Context Protocol)

MCP tool calls use HTTP POST, so they are not retried on 502/503 by default. Opt in per call only when the tool is read-only or otherwise idempotent:

result = client.mcp(
    {
        "jsonrpc": "2.0",
        "id": "1",
        "method": "tools/call",
        "params": {"name": "entities.resolve", "arguments": {"ticker": "AAPL"}},
    },
    retry={"enabled": True, "idempotency_key": "mcp-entities-resolve-aapl"},
)

Links

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

secapi_client-0.3.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

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

secapi_client-0.3.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file secapi_client-0.3.0.tar.gz.

File metadata

  • Download URL: secapi_client-0.3.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for secapi_client-0.3.0.tar.gz
Algorithm Hash digest
SHA256 23fa55235f08e78796c2fe8dafa52ec1555e0ff3c4f27233082184b716987eaa
MD5 0313e3e9e54b911190c33dc27e4a30d5
BLAKE2b-256 8dcdfc18f8bc238ecf1057d0535593c3c5f5e38cf648d6a1521ce9055aa29b17

See more details on using hashes here.

File details

Details for the file secapi_client-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: secapi_client-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for secapi_client-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c3c8ce49a6e0dedd1692da4adacfaaacb4b08684c57dc67284796f0e5d737c4
MD5 ba0c459307ddf654b84296f1b484c29a
BLAKE2b-256 e811cb511750a96ebb8c5b5bd86d0949f319bfd9d333b8df3ac28302c4e7528d

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