douyin-api


Namedouyin-api JSON
Version 0.1.11 PyPI version JSON
download
home_pagehttps://github.com/ldsxp/douyin-api
Summary抖音官方开放接口
upload_time2025-07-18 04:00:08
maintainerNone
docs_urlNone
authorlds
requires_pythonNone
licenseGNU GPL 3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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/25/f3/6d3e03c8af94f53ead559d1851118c2a39fef00d06de054014b6fb92081e/douyin-api-0.1.11.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.11",
    "project_urls": {
        "Download": "https://pypi.org/project/douyin-api",
        "Homepage": "https://github.com/ldsxp/douyin-api"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "82489a92176a99bfd4f9c8013998eaeded37b4c1ade9246957e68c051ee51061",
                "md5": "70fe14f24f5ac04651e26912d207d19e",
                "sha256": "4dfbabfb0cce133192c019ddba4e258cf2788cc70910c50e7898ca786b902cf1"
            },
            "downloads": -1,
            "filename": "douyin_api-0.1.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "70fe14f24f5ac04651e26912d207d19e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12996,
            "upload_time": "2025-07-18T04:00:07",
            "upload_time_iso_8601": "2025-07-18T04:00:07.264095Z",
            "url": "https://files.pythonhosted.org/packages/82/48/9a92176a99bfd4f9c8013998eaeded37b4c1ade9246957e68c051ee51061/douyin_api-0.1.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25f36d3e03c8af94f53ead559d1851118c2a39fef00d06de054014b6fb92081e",
                "md5": "b4a7b7aae92a19e0099456794394b1a6",
                "sha256": "bbefc7147962cb64b51a2c424ac90631629b7bb7314548b09ba40c034995edd9"
            },
            "downloads": -1,
            "filename": "douyin-api-0.1.11.tar.gz",
            "has_sig": false,
            "md5_digest": "b4a7b7aae92a19e0099456794394b1a6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12654,
            "upload_time": "2025-07-18T04:00:08",
            "upload_time_iso_8601": "2025-07-18T04:00:08.235396Z",
            "url": "https://files.pythonhosted.org/packages/25/f3/6d3e03c8af94f53ead559d1851118c2a39fef00d06de054014b6fb92081e/douyin-api-0.1.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-18 04:00:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ldsxp",
    "github_project": "douyin-api",
    "github_not_found": true,
    "lcname": "douyin-api"
}
        
lds
Elapsed time: 1.80149s