# douyin-api
## 说明
抖音官网接口
开发者文档:https://developer.open-douyin.com/docs-page
移动/网站应用文档指引:https://developer.open-douyin.com/docs/resource/zh-CN/dop/overview/usage-guide
## 接口演示
```python
from douyin_api import DouYin
from douyin_api.utils import Timer
from douyin_api.tool import get_video_id_by_short_url, get_iframe_data_by_video_id
from _.不要对外公开 import client_key, client_secret, redirect_uri, access_token, open_id, item_id, refresh_token, short_url
正式环境 = 'https://open.douyin.com'
沙盒环境 = 'https://open-sandbox.douyin.com'
if __name__ == '__main__':
with Timer() as timer:
...
d = DouYin(client_key, client_secret, 正式环境)
# print(d.client_token())
scope = 'user_info,video.list.bind,video.data.bind'
scope += ',trial.whitelist' # 测试的时候需要这个权限
# renew_refresh_token 用户授权续期
print(d.get_permission_code_url(scope=scope, redirect_uri=redirect_uri))
# print(d.access_token(code='9c1592704acfd7dbuQbpWj9u7EsBV8KuDbPT'))
# 刷新 refresh_token 的有效期
# print(d.renew_refresh_token(refresh_token))
# 刷新 refresh_token 的有效期
# print(d.refresh_token(refresh_token))
# 设置用户access_token,有些接口需要这个才能访问
d.set_access_token(access_token, open_id)
# print(d.userinfo())
# 分页获取用户所有视频的数据,返回的数据是实时的
# print(d.video_list(cursor=0, count=10))
# 查看设置用户access_token是否影响client_token接口访问
# print(d.client_token())
# video_id = get_video_id_by_short_url(short_url)
# print('从抖音短连接获取视频id', video_id)
# # 通过VideoID获取IFrame代码
# if video_id:
# print(get_iframe_data_by_video_id(video_id))
# 查询用户特定视频的数据,如点赞数、播放数等,返回的数据是实时的
# print(d.video_data(ids=[item_id]))
# print(d.video_data(ids=[str(video_id)], use_item_ids=False))
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ldsxp/douyin-api",
"name": "douyin-api",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "lds",
"author_email": "85176878@qq.com",
"download_url": "https://files.pythonhosted.org/packages/d8/86/817d024d60ea9bcb775c0e48596d5bf09174a98c0d32ee9d91420b231d6e/douyin-api-0.1.8.tar.gz",
"platform": "any",
"description": "# douyin-api\n\n## \u8bf4\u660e\n\n\u6296\u97f3\u5b98\u7f51\u63a5\u53e3\n\n\u5f00\u53d1\u8005\u6587\u6863\uff1ahttps://developer.open-douyin.com/docs-page\n\n\u79fb\u52a8/\u7f51\u7ad9\u5e94\u7528\u6587\u6863\u6307\u5f15\uff1ahttps://developer.open-douyin.com/docs/resource/zh-CN/dop/overview/usage-guide\n\n\n## \u63a5\u53e3\u6f14\u793a\n\n```python\nfrom douyin_api import DouYin\nfrom douyin_api.utils import Timer\nfrom douyin_api.tool import get_video_id_by_short_url, get_iframe_data_by_video_id\n\nfrom _.\u4e0d\u8981\u5bf9\u5916\u516c\u5f00 import client_key, client_secret, redirect_uri, access_token, open_id, item_id, refresh_token, short_url\n\n\u6b63\u5f0f\u73af\u5883 = 'https://open.douyin.com'\n\n\u6c99\u76d2\u73af\u5883 = 'https://open-sandbox.douyin.com'\n\nif __name__ == '__main__':\n with Timer() as timer:\n ...\n d = DouYin(client_key, client_secret, \u6b63\u5f0f\u73af\u5883)\n\n # print(d.client_token())\n\n scope = 'user_info,video.list.bind,video.data.bind'\n scope += ',trial.whitelist' # \u6d4b\u8bd5\u7684\u65f6\u5019\u9700\u8981\u8fd9\u4e2a\u6743\u9650\n\n # renew_refresh_token \u7528\u6237\u6388\u6743\u7eed\u671f\n print(d.get_permission_code_url(scope=scope, redirect_uri=redirect_uri))\n\n # print(d.access_token(code='9c1592704acfd7dbuQbpWj9u7EsBV8KuDbPT'))\n\n # \u5237\u65b0 refresh_token \u7684\u6709\u6548\u671f\n # print(d.renew_refresh_token(refresh_token))\n\n # \u5237\u65b0 refresh_token \u7684\u6709\u6548\u671f\n # print(d.refresh_token(refresh_token))\n\n # \u8bbe\u7f6e\u7528\u6237access_token\uff0c\u6709\u4e9b\u63a5\u53e3\u9700\u8981\u8fd9\u4e2a\u624d\u80fd\u8bbf\u95ee\n d.set_access_token(access_token, open_id)\n\n # print(d.userinfo())\n\n # \u5206\u9875\u83b7\u53d6\u7528\u6237\u6240\u6709\u89c6\u9891\u7684\u6570\u636e\uff0c\u8fd4\u56de\u7684\u6570\u636e\u662f\u5b9e\u65f6\u7684\n # print(d.video_list(cursor=0, count=10))\n\n # \u67e5\u770b\u8bbe\u7f6e\u7528\u6237access_token\u662f\u5426\u5f71\u54cdclient_token\u63a5\u53e3\u8bbf\u95ee\n # print(d.client_token())\n\n # video_id = get_video_id_by_short_url(short_url)\n # print('\u4ece\u6296\u97f3\u77ed\u8fde\u63a5\u83b7\u53d6\u89c6\u9891id', video_id)\n # # \u901a\u8fc7VideoID\u83b7\u53d6IFrame\u4ee3\u7801\n # if video_id:\n # print(get_iframe_data_by_video_id(video_id))\n\n # \u67e5\u8be2\u7528\u6237\u7279\u5b9a\u89c6\u9891\u7684\u6570\u636e\uff0c\u5982\u70b9\u8d5e\u6570\u3001\u64ad\u653e\u6570\u7b49\uff0c\u8fd4\u56de\u7684\u6570\u636e\u662f\u5b9e\u65f6\u7684\n # print(d.video_data(ids=[item_id]))\n # print(d.video_data(ids=[str(video_id)], use_item_ids=False))\n\n```\n\n\n\n",
"bugtrack_url": null,
"license": "GNU GPL 3",
"summary": "\u6296\u97f3\u5b98\u65b9\u5f00\u653e\u63a5\u53e3",
"version": "0.1.8",
"project_urls": {
"Download": "https://pypi.org/project/douyin-api",
"Homepage": "https://github.com/ldsxp/douyin-api"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "84135cbdaaa2d7e96668dba4b229816b61ad565e5e4846746e1dd5709040e75b",
"md5": "89f07efa0fc19847fd4cfcf996739e5d",
"sha256": "2b1e82b72e6e0969e811abbe96d493be04a170558bee27d6c9cb49d4837e16ad"
},
"downloads": -1,
"filename": "douyin_api-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "89f07efa0fc19847fd4cfcf996739e5d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12954,
"upload_time": "2024-05-14T02:49:56",
"upload_time_iso_8601": "2024-05-14T02:49:56.299119Z",
"url": "https://files.pythonhosted.org/packages/84/13/5cbdaaa2d7e96668dba4b229816b61ad565e5e4846746e1dd5709040e75b/douyin_api-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d886817d024d60ea9bcb775c0e48596d5bf09174a98c0d32ee9d91420b231d6e",
"md5": "120e9192e2f8cd280daa7abdcdc2d8ab",
"sha256": "f552e8b9cc798ec9931b6a38ddcaf79b2ef8c0dd33b2b775bebe1532178a4b40"
},
"downloads": -1,
"filename": "douyin-api-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "120e9192e2f8cd280daa7abdcdc2d8ab",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12615,
"upload_time": "2024-05-14T02:49:58",
"upload_time_iso_8601": "2024-05-14T02:49:58.157439Z",
"url": "https://files.pythonhosted.org/packages/d8/86/817d024d60ea9bcb775c0e48596d5bf09174a98c0d32ee9d91420b231d6e/douyin-api-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-14 02:49:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ldsxp",
"github_project": "douyin-api",
"github_not_found": true,
"lcname": "douyin-api"
}