---
title: Python
description: Automate Firmreader from scripts and backend services
---

> **For AI agents:** the complete documentation index is at [llms.txt](/llms.txt). Append `.md` to any page URL for its markdown version.

The Python SDK targets Python 3.9+ and exposes a synchronous client. An async client is available under `firmreader.aio`.

## Install

```bash
pip install firmreader
```

## Initialize the client

```python
import os
from firmreader import Firmreader

client = Firmreader(api_key=os.environ["FIRMREADER_API_KEY"])  # fr_live_...
```

## Create a post

```python
post = client.posts.create(
    channel_id="ch_company_news",
    title="Welcome to Firmreader",
    body="We're excited to announce our new internal communications platform.",
    priority="normal",
)

print(f"Published post {post.id}")
```

## List posts

```python
posts = client.posts.list(channel_id="ch_company_news", limit=20)

for post in posts.data:
    print(post.title)
```

## Handle errors

Non-2xx responses raise `FirmreaderError`, which carries the HTTP `status` and an API `code`.

```python
from firmreader import FirmreaderError

try:
    client.posts.create(channel_id="ch_invalid", title="Hi", body="...")
except FirmreaderError as err:
    print(f"{err.status}: {err.code}")
```

<Tip>
Pass `idempotency_key="..."` to any write method so retried requests don't create duplicate posts.
</Tip>
