FastComments.com

FastComments Python SDK

这是 FastComments 的官方 Python SDK。

FastComments API 的官方 Python SDK

仓库

在 GitHub 上查看


安装 Internal Link

从 GitHub 安装

直接从发布标签安装(推荐,完全可复现):

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

固定标签而不是分支,以确保构建确定性。同样的写法可以在 requirements.txt 中使用:

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

每个带标签的 GitHub Release 也附带了构建好的 wheel,如果您更倾向直接安装二进制工件的话。

库内容

此库包含两个模块:生成的 API 客户端以及包含手写工具的核心 Python 库,这些工具能够让使用 API 更加方便,包括 SSO 支持。

公开 API 与受限 API

对于 API 客户端,有三个类,DefaultApiPublicApiModerationApiDefaultApi 包含需要您的 API 密钥的方法,PublicApi 包含可以直接从浏览器/移动设备等无认证情况下调用的方法。ModerationApi 提供了丰富的实时快速审核 API 套件。每个 ModerationApi 方法都接受 sso 参数,并且可以通过 SSO 或 FastComments.com 会话 Cookie 进行身份验证。

注意事项 Internal Link

广播 ID

你会看到在某些 API 调用中需要传递 broadcast_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.0typing-extensions >= 4.0.0

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

需要帮助?

如果您在使用 Python SDK 时遇到任何问题或有任何疑问,请:

贡献

欢迎贡献!请访问 GitHub 仓库 获取贡献指南。