FastComments.com

FastComments 的 Python SDK


這是 FastComments 的官方 Python SDK。

FastComments API 的官方 Python SDK

儲存庫

在 GitHub 檢視


安裝 Internal Link

Install from GitHub

Install directly from a release tag (recommended, fully reproducible):

pip install git+https://github.com/fastcomments/fastcomments-python.git@v3.1.0

Pin the tag rather than a branch so builds are deterministic. The same form works in requirements.txt:

fastcomments @ git+https://github.com/fastcomments/fastcomments-python.git@v3.1.0

Each tagged GitHub Release also has a built wheel attached if you prefer to install a binary artifact directly.

Library Contents

This library contains two modules: the generated API client and the core Python library which contains hand‑written utilities to make working with the API easier, including SSO support.

Public vs Secured APIs

For the API client, there are three classes, DefaultApi, PublicApi, and ModerationApi. The DefaultApi contains methods that require your API key, and PublicApi contains methods that can be made directly from a browser/mobile device/etc without authentication. The ModerationApi provides an extensive suite of live and fast moderation APIs. Every ModerationApi method accepts an sso parameter and can authenticate via SSO or a FastComments.com session cookie.

注意事項 Internal Link

廣播 ID

您會看到在某些 API 呼叫中需要傳入 broadcast_id。當您接收到事件時,會收到這個 ID 回傳,因此如果您打算在客戶端採用樂觀更新(您大概會想這麼做,因為它提供最佳體驗),就可以利用這個 ID 判斷是否忽略該事件。此處請傳入一個 UUID。該 ID 應足夠唯一,以免在同一個瀏覽器會話中出現兩次。

系統需求 Internal Link


  • Python >= 3.8

基礎安裝是純標準庫,並提供 SSO 工具。產生的 API 客戶端(DefaultApi/PublicApi/ModerationApi)需要 client 額外套件,該套件會拉入 urllib3 >= 1.25.3python-dateutil >= 2.8.2pydantic >= 2.0.0 以及 typing-extensions >= 4.0.0

pip install "fastcomments[client] @ git+https://github.com/fastcomments/fastcomments-python.git@v3.1.0"


需要協助?

如果您在使用 Python SDK 時遇到任何問題或有任何疑問,請:

貢獻

歡迎貢獻!請造訪 GitHub 儲存庫 以取得貢獻指南。