afdiankit


Nameafdiankit JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/StarHeartHunt/afdiankit
SummaryAfdian SDK for Python
upload_time2023-09-18 09:36:09
maintainer
docs_urlNone
authorStarHeartHunt
requires_python>=3.8,<4.0
licenseMIT
keywords afdian
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!-- markdownlint-disable MD033 MD041 -->
<p align="center">
  <a href="https://raw.githubusercontent.com/StarHeartHunt/afdiankit/master/LICENSE">
    <img src="https://img.shields.io/github/license/StarHeartHunt/afdiankit" alt="license">
  </a>
  <a href="https://pypi.python.org/pypi/afdiankit">
    <img src="https://img.shields.io/pypi/v/afdiankit?logo=python&logoColor=edb641" alt="pypi">
  </a>
  <img src="https://img.shields.io/badge/python-3.8+-blue?logo=python&logoColor=edb641" alt="python">
  <a href="https://github.com/psf/black">
    <img src="https://img.shields.io/badge/code%20style-black-000000.svg?logo=python&logoColor=edb641" alt="black">
  </a>
  <a href="https://github.com/Microsoft/pyright">
    <img src="https://img.shields.io/badge/types-pyright-797952.svg?logo=python&logoColor=edb641" alt="pyright">
  </a>
  <a href="https://github.com/astral-sh/ruff">
    <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json" alt="ruff">
  </a>
  <a href="https://results.pre-commit.ci/latest/github/StarHeartHunt/afdiankit/main">
    <img src="https://results.pre-commit.ci/badge/github/StarHeartHunt/afdiankit/main.svg" alt="pre-commit" />
  </a>
</p>

<div align="center">

<!-- markdownlint-capture -->
<!-- markdownlint-disable MD036 -->

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

_✨ 同时支持 **同步** 与 **异步** 调用 ✨_

</div>

## 安装方式

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

## 使用方法

### 使用爱发电网页端 API

#### 获取网页端 `auth_token`

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

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

调用 `afdiankit` 示例:

```python
from afdiankit import Afdian, TokenAuthStrategy

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

### 使用开放平台 API

在[开发者后台](https://afdian.net/dashboard/dev)生成 webhook 的 token,复制 `user_id`。

调用 `afdiankit` 示例:

```python
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](https://github.com/StarHeartHunt/afdiankit/blob/main/LICENSE)。

## 鸣谢

- [yanyongyu/githubkit](https://github.com/yanyongyu/githubkit)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/StarHeartHunt/afdiankit",
    "name": "afdiankit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "afdian",
    "author": "StarHeartHunt",
    "author_email": "starheart233@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/af/16/509406fbdc07911096a5965c8c6fdfedcc826cd1c8b212ab658a0641ccea/afdiankit-0.2.0.tar.gz",
    "platform": null,
    "description": "<!-- markdownlint-disable MD033 MD041 -->\n<p align=\"center\">\n  <a href=\"https://raw.githubusercontent.com/StarHeartHunt/afdiankit/master/LICENSE\">\n    <img src=\"https://img.shields.io/github/license/StarHeartHunt/afdiankit\" alt=\"license\">\n  </a>\n  <a href=\"https://pypi.python.org/pypi/afdiankit\">\n    <img src=\"https://img.shields.io/pypi/v/afdiankit?logo=python&logoColor=edb641\" alt=\"pypi\">\n  </a>\n  <img src=\"https://img.shields.io/badge/python-3.8+-blue?logo=python&logoColor=edb641\" alt=\"python\">\n  <a href=\"https://github.com/psf/black\">\n    <img src=\"https://img.shields.io/badge/code%20style-black-000000.svg?logo=python&logoColor=edb641\" alt=\"black\">\n  </a>\n  <a href=\"https://github.com/Microsoft/pyright\">\n    <img src=\"https://img.shields.io/badge/types-pyright-797952.svg?logo=python&logoColor=edb641\" alt=\"pyright\">\n  </a>\n  <a href=\"https://github.com/astral-sh/ruff\">\n    <img src=\"https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json\" alt=\"ruff\">\n  </a>\n  <a href=\"https://results.pre-commit.ci/latest/github/StarHeartHunt/afdiankit/main\">\n    <img src=\"https://results.pre-commit.ci/badge/github/StarHeartHunt/afdiankit/main.svg\" alt=\"pre-commit\" />\n  </a>\n</p>\n\n<div align=\"center\">\n\n<!-- markdownlint-capture -->\n<!-- markdownlint-disable MD036 -->\n\n_\u2728 \u4e00\u4e2a\u73b0\u4ee3\u5316\u7684\u7231\u53d1\u7535 Python SDK \u2728_\n\n_\u2728 \u540c\u65f6\u652f\u6301 **\u540c\u6b65** \u4e0e **\u5f02\u6b65** \u8c03\u7528 \u2728_\n\n</div>\n\n## \u5b89\u88c5\u65b9\u5f0f\n\n```bash\npip install afdiankit\n# or, use poetry\npoetry add afdiankit\n# or, use pdm\npdm add afdiankit\n```\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n### \u4f7f\u7528\u7231\u53d1\u7535\u7f51\u9875\u7aef API\n\n#### \u83b7\u53d6\u7f51\u9875\u7aef `auth_token`\n\n\u5728\u7231\u53d1\u7535\u7f51\u9875\u7aef\u6253\u5f00 F12 \u5f00\u53d1\u8005\u5de5\u5177\uff0c\u5207\u6362\u5230 Console\uff08\u63a7\u5236\u53f0\uff09\u6807\u7b7e\u9875\uff0c\u8f93\u5165\u4ee5\u4e0b JavaScript \u4ee3\u7801\u83b7\u53d6\u7f51\u9875\u7aef auth token\n\n```javascript\ndocument.cookie.match(new RegExp(\"(^| )auth_token=([^;]+)\"))[2];\n```\n\n\u8c03\u7528 `afdiankit` \u793a\u4f8b\uff1a\n\n```python\nfrom afdiankit import Afdian, TokenAuthStrategy\n\nafdian = Afdian(\"<auth_token>\")\n# \u6216\u8005\u663e\u5f0f\u8c03\u7528 TokenAuthStrategy\ngithub = Afdian(TokenAuthStrategy(\"<auth_token>\"))\n```\n\n### \u4f7f\u7528\u5f00\u653e\u5e73\u53f0 API\n\n\u5728[\u5f00\u53d1\u8005\u540e\u53f0](https://afdian.net/dashboard/dev)\u751f\u6210 webhook \u7684 token\uff0c\u590d\u5236 `user_id`\u3002\n\n\u8c03\u7528 `afdiankit` \u793a\u4f8b\uff1a\n\n```python\nfrom afdiankit import Afdian, TokenAuthStrategy\n\nafdian = Afdian()\nuser_id = \"<user_id>\"\ntoken = \"<token>\"\n\nafdian.open.post_ping(\n    token=token,\n    user_id=user_id,\n    params={\"a\": \"1\"},\n    ts=int(time.time())\n).json()\n```\n\n## \u8bb8\u53ef\u8bc1\n\n\u9879\u76ee\u6e90\u4ee3\u7801\u4f7f\u7528 MIT \u8bb8\u53ef\u8bc1\u6388\u6743\uff0c\u89c1 [LICENSE](https://github.com/StarHeartHunt/afdiankit/blob/main/LICENSE)\u3002\n\n## \u9e23\u8c22\n\n- [yanyongyu/githubkit](https://github.com/yanyongyu/githubkit)\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Afdian SDK for Python",
    "version": "0.2.0",
    "project_urls": {
        "Documentation": "https://github.com/StarHeartHunt/afdiankit",
        "Homepage": "https://github.com/StarHeartHunt/afdiankit",
        "Repository": "https://github.com/StarHeartHunt/afdiankit"
    },
    "split_keywords": [
        "afdian"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b2a96175031a83d5b71d7010302e407de77ab1a15c2bafd287711afb0dc560b7",
                "md5": "e6cbfacb6f8f85ec0261ac05c01de16a",
                "sha256": "e580b89dd966c9826d5e6cd2c1a11314cc626834cd4f8961ffa533950aee953b"
            },
            "downloads": -1,
            "filename": "afdiankit-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e6cbfacb6f8f85ec0261ac05c01de16a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 40738,
            "upload_time": "2023-09-18T09:36:08",
            "upload_time_iso_8601": "2023-09-18T09:36:08.035124Z",
            "url": "https://files.pythonhosted.org/packages/b2/a9/6175031a83d5b71d7010302e407de77ab1a15c2bafd287711afb0dc560b7/afdiankit-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af16509406fbdc07911096a5965c8c6fdfedcc826cd1c8b212ab658a0641ccea",
                "md5": "6473d5d0daa3f77e34aac53bcb4b4b6d",
                "sha256": "a570111dab24fa2066caea5ee2c9896fa1a7eaea3600cb8eb7f885b3c5bd5e64"
            },
            "downloads": -1,
            "filename": "afdiankit-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6473d5d0daa3f77e34aac53bcb4b4b6d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 24349,
            "upload_time": "2023-09-18T09:36:09",
            "upload_time_iso_8601": "2023-09-18T09:36:09.303116Z",
            "url": "https://files.pythonhosted.org/packages/af/16/509406fbdc07911096a5965c8c6fdfedcc826cd1c8b212ab658a0641ccea/afdiankit-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-18 09:36:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "StarHeartHunt",
    "github_project": "afdiankit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "afdiankit"
}
        
Elapsed time: 0.24778s