---
title: Python
description: >-
  Scopri come installare e usare l’SDK Python di Firmreader per creare post, elencare contenuti dei canali e gestire errori API da Python 3.9 in poi.
lastUpdated: "2026-08-17"
---

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

L’SDK Python supporta Python 3.9 e versioni successive e offre un client sincrono. Un client asincrono è disponibile in `firmreader.aio`.

## Installazione

```bash
pip install firmreader
```

## Inizializzare il client

```python
import os
from firmreader import Firmreader

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

## Creare un 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}")
```

## Elencare i post

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

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

## Gestire gli errori

Le risposte non 2xx generano `FirmreaderError`, che contiene lo `status` HTTP e un `code` API.

```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>
Passa `idempotency_key="..."` a qualsiasi metodo di scrittura per evitare che i tentativi ripetuti creino post duplicati.
</Tip>
