---
title: Python
description: >-
  Installez et utilisez le SDK Python de Firmreader pour créer des publications, lister les canaux et gérer les erreurs API avec Python 3.9+.
lastUpdated: "2026-08-21"
---

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

Le SDK Python cible Python 3.9 ou version ultérieure et expose un client synchrone. Un client asynchrone est disponible sous `firmreader.aio`.

## Installation

```bash
pip install firmreader
```

## Initialiser le client

```python
import os
from firmreader import Firmreader

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

## Créer une publication

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

## Lister les publications

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

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

## Gérer les erreurs

Les réponses non-2xx lèvent `FirmreaderError`, qui contient le `status` HTTP et un `code` d’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>
Transmettez `idempotency_key="..."` à toute méthode d’écriture afin que les requêtes réessayées ne créent pas de publications en double.
</Tip>
