> ## Documentation Index
> Fetch the complete documentation index at: https://docs.secapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Start with the Python SDK

> Install the SEC API Python SDK, retrieve one filing, and retain source and diagnostic identifiers.

## Prerequisites

* Python 3.11 or newer.
* An API key in `SECAPI_API_KEY`.

```bash theme={null}
python -m pip install secapi-client
export SECAPI_API_KEY="secapi_..."
```

## Run a complete first request

Create `first_request.py`:

```python theme={null}
from secapi_client import SecApiClient, SecApiError

client = SecApiClient()

try:
    filing = client.agent_latest_filing(ticker="AAPL", form="10-K")
    print({
        "accessionNumber": filing.get("accessionNumber"),
        "filingDate": filing.get("filingDate"),
        "filingUrl": filing.get("filingUrl"),
        "requestId": filing.get("requestId"),
    })
except SecApiError as error:
    print({"status": error.status, "code": error.code, "requestId": error.request_id})
    raise
```

```bash theme={null}
python first_request.py
```

Expect a current filing identity and request ID. The values are live; retain the accession number and filing URL if a later process needs to locate the same source filing.

## Errors and retry behavior

`SecApiError` exposes an HTTP status, `code`, `request_id`, and any supplied retry details. The client has a bounded retry policy and observes `Retry-After` when present. A `429` can be retried even when it follows a mutating request; treatment of other failures depends on the HTTP method and retry options.

For a `401`, check the environment variable and use API-key authentication for data endpoints. For `429`, let the client wait or honor the returned interval in your own policy. Before a mutation whose replay is unsafe, construct the client with `retry=False` or ensure the operation is idempotent.

## Production notes

* The default client uses `https://api.secapi.ai`; override `base_url` only for an environment you control.
* Pass `api_version` after validating the exact operation; log `Request-Id` and `SECAPI-Version` around failures.
* Disable SDK retries when a queue, job runner, or service mesh already owns retry behavior.
* Endpoint fields and response views are not interchangeable. Consult the reference before parsing optional metadata.

Next: [SDK reliability](/sdk-reliability), [error code catalog](/error-code-catalog), or [API reference](/api-reference).
