Skip to main content

Afdian SDK for Python

Project description

license pypi python black pyright ruff pre-commit

✨ 一个现代化的爱发电 Python SDK ✨

✨ 同时支持 同步异步 调用 ✨

安装方式

pip install afdiankit
# or, use poetry
poetry add afdiankit
# or, use pdm
pdm add afdiankit

使用方法

使用爱发电网页端 API

获取网页端 auth_token

在爱发电网页端打开 F12 开发者工具,切换到 Console(控制台)标签页,输入以下 JavaScript 代码获取网页端 auth token

document.cookie.match(new RegExp("(^| )auth_token=([^;]+)"))[2];

调用 afdiankit 示例:

from afdiankit import Afdian, TokenAuthStrategy

afdian = Afdian("<auth_token>")
# 或者显式调用 TokenAuthStrategy
github = Afdian(TokenAuthStrategy("<auth_token>"))

使用开放平台 API

开发者后台生成 webhook 的 token,复制 user_id

调用 afdiankit 示例:

from afdiankit import Afdian, TokenAuthStrategy

afdian = Afdian()
user_id = "<user_id>"
token = "<token>"

afdian.open.post_ping(
    token=token,
    user_id=user_id,
    params={"a": "1"},
    ts=int(time.time())
).json()

许可证

项目源代码使用 MIT 许可证授权,见 LICENSE

鸣谢

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

afdiankit-0.2.0.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

afdiankit-0.2.0-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file afdiankit-0.2.0.tar.gz.

File metadata

  • Download URL: afdiankit-0.2.0.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for afdiankit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a570111dab24fa2066caea5ee2c9896fa1a7eaea3600cb8eb7f885b3c5bd5e64
MD5 6473d5d0daa3f77e34aac53bcb4b4b6d
BLAKE2b-256 af16509406fbdc07911096a5965c8c6fdfedcc826cd1c8b212ab658a0641ccea

See more details on using hashes here.

File details

Details for the file afdiankit-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: afdiankit-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for afdiankit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e580b89dd966c9826d5e6cd2c1a11314cc626834cd4f8961ffa533950aee953b
MD5 e6cbfacb6f8f85ec0261ac05c01de16a
BLAKE2b-256 b2a96175031a83d5b71d7010302e407de77ab1a15c2bafd287711afb0dc560b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page