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

# Python SDK

> Use hosted Almanac from Python.

Install the package:

```bash theme={null}
uv add the-almanac
```

Import `almanac` in Python:

```python theme={null}
from almanac import AlmanacClient

client = AlmanacClient(access_token="ALMANAC_TOKEN")
legal = client.use("reverie/legal")

pages = legal.search("yc safe")
page = legal.pages.read("safe-financing")
sources = legal.sources.search("safe")
```

The SDK calls the same `/v1` API as the CLI and MCP server. It does not import
hosted server services or product-data stores.

## Namespaces

```python theme={null}
legal.pages.read("safe-financing")
legal.sources.list()
legal.sources.upload(["docs/safe.pdf"], guidance="ingest this filing")
legal.jobs.list()
legal.jobs.wait("last")
legal.garden(guidance="tighten stale pages")
```

`wiki.search(...)` searches pages. Use `wiki.sources.search(...)` for source
metadata.

## API keys

Admins can create organization API keys from the website or CLI:

```bash theme={null}
almanac api-keys create "Python job"
```

Use the returned value as the SDK bearer token:

```python theme={null}
from almanac import AlmanacClient

client = AlmanacClient(access_token="waka_...")
legal = client.use("reverie/legal")
print(legal.search("yc safe"))
```

The SDK can also manage keys when the current token has developer-management
access:

```python theme={null}
client.api_keys.list("reverie")
client.api_keys.create("reverie", "Read-only agent", ["almanac:wiki:read"])
client.api_keys.delete("reverie", "ak_123")
```
