Skip to content

Latest commit

 

History

History
480 lines (330 loc) · 24.6 KB

README.en.md

File metadata and controls

480 lines (330 loc) · 24.6 KB

Douyin_TikTok_Download_API(抖音/TikTok API)

English|Simplified Chinese

🚀 "Douyin_TikTok_Download_API" is a high-performance asynchronous out-of-the-boxTik Tok|Tiktok|BiliableData crawling tool, supports API calls, online batch analysis and download.

GitHub licenseRelease VersionGitHub StarGitHub ForkGitHub issuesGitHub closed issuesGitHub Repo size
PyPI vPyPI wheelPyPI dmPyPI pyversions
API statusTikHub-API status
爱发电KofiPatreon

Sponsors

These sponsors have paid to place them here,Doinan_tics_download_apiThe project will always be free and open source. If you wish to be a sponsor of this project, please check out myGitHub Sponsor Page

TikHub.io - Global Social Data & API Marketplace

TikHub.io

Your Ultimate Social Media Data & API Marketplace

Professional data solutions for Douyin, Xiaohongshu, TikTok, Instagram, YouTube, Twitter, and more.
Real-time Data | Flexible APIs | Seamless Integration | Competitive Pricing with Discounts

Discover TikHub.io Marketplace
Buy and sell custom APIs, services, and social media solutions.
Join a thriving ecosystem of developers, businesses, and content creators.

Trusted by leading global influencer marketing and social media intelligence platforms

👻 Introduction

🚨If you want to use a private server to run this project, please refer to:Deployment preparations,Docker deployment,One-click deployment

This project is based onPydebioFastingHTTPX, fast asynchronousTik Tok/TiktokData crawling tool, and online batch analysis and downloading of watermark-free videos or picture albums through the web, data crawling API, iOS shortcuts without watermark download and other functions. You can deploy or transform this project yourself to achieve more functions, or you can call it directly in your projectscraper.pyOr install an existing onepip packageAs a parsing library, easy to crawl data, etc....

Some simple application scenarios:

Download videos that are prohibited from being downloaded, perform data analysis, and download without watermark on iOS (withiOS's shortcut command APPIn conjunction with this project API, it can realize in-app download or read clipboard download, etc....

🔊 V4 version notes

  • If you are interested in writing this project, please add WeChat.Evil0ctalNote: Github project reconstruction, everyone can communicate and learn from each other in the group, and do not allow advertisements or illegal things to be made purely friends and technical communication.
  • This project usesX-BogusAlgorithm andA_BogusThe algorithm requests the web APIs of TikTok and TikTok.
  • Due to Douyin's risk control, please go toGet the Douyin website cookies in the browser and replace them in config.yaml.
  • Please read the document below before asking for an issue, and most solutions to the problem will be included in the document.
  • This project is completely free, but please follow it when using it:Apache-2.0 license

🔖TikHub.io API

TikHub.ioIt is an API platform that provides various public data interfaces including Douyin and TikTok. If you want to support itDoinan_tics_download_apiWe strongly recommend that you choose the project developmentTikHub.io

Features:

📦 Out of the box

Simplify the usage process and quickly carry out development work using the encapsulated SDK. All API interfaces are designed according to the RESTful architecture and are described and documented using the OpenAPI specification, with example parameters to ensure that calls are easier.

💰 Cost Advantage

There is no preset package limit, no monthly usage threshold, all consumption is billed instantly based on the actual usage, and the user's daily request volume is charged step by step. At the same time, you can check in in the user's background by checking in every day. , and these free amounts will not expire.

⚡️ Quick support

We have a huge Discord community server where administrators and other users will quickly reply to you to help you quickly resolve current issues.

🎉 Embrace open source

Some of the source code of TikHub will be open sourced on Github and will sponsor some open source projects.

Link:

🖥 Demo site: I am very fragile... Please do not press test (·•᷄ࡇ•᷅ )

😾The online download function of the demo site has been turned off, and Douyin's parsing and API services cannot be guaranteed for availability on the Demo site due to cookies.

🍔Web APP:https://douyin.wtf/

🍟API Document:https://douyin.wtf/docs

🌭tikub APU Docuration:https://api.tikhub.io/docs

💾 iOS Shortcut:Shortcut release

📦️Desktop downloader (recommended warehouse):

⚗️Technology Stack

/crawlers

  • Submit requests to APIs of different platforms and retrieve data, and return dictionary (dict) after processing, supports asynchronousness.

/app/api

  • Obtain the request parameters and useCrawlersAfter processing data, the related classes return in JSON form, download videos, and implement quick calls with iOS shortcuts, and support asynchronous.

/app/web

  • usePyWebIOA simple web program created, process the value entered on the web page and use itCrawlersThe related class processing interface outputs related data on the web page.

Most of the parameters of the above files can be in the correspondingconfig.yamlMake modifications in

💡Project file structure

./Douyin_TikTok_Download_API
├─app
│  ├─api
│  │  ├─endpoints
│  │  └─models
│  ├─download
│  └─web
│      └─views
└─crawlers
  ├─bilibili
  │  └─web  
  ├─douyin
  │  └─web
  ├─hybrid
  ├─tiktok
  │  ├─app
  │  └─web
  └─utils

✨Support functions:

  • Batch analysis on the web side (supports Douyin/TikTok hybrid analysis)
  • Download videos or albums online.
  • Productionpip packageEasy and quick import of your project
  • iOS shortcuts to quickly call APIImplement in-app download of watermark videos/pictures
  • Complete API documentation (Demo/Demo)
  • Rich API interfaces:
    • TikTok web version API

      • Video data analysis
      • Obtain user's homepage work data
      • Obtain data on the user's homepage liked works
      • Obtain data on the user's homepage collection of works
      • Get user homepage information
      • Obtain user compiled works data
      • Obtain user live streaming data
      • Get live streaming data for the specified user
      • Get the ranking of gift-giving users in the live broadcast room
      • Get individual video comment data
      • Get comments and response data for specified videos
      • Generate msToken
      • Generate verification_fp
      • Generate s_v_web_id
      • Generate X-Bogus parameters using interface URL
      • Generate A_Bogus parameters using interface URL
      • Extract a single user id
      • Extract list user id
      • Extract individual works id
      • Extract list work id
      • Extract list live broadcast room number
      • Extract list live broadcast room number
    • TikTok web version API

      • Video data analysis
      • Obtain user's homepage work data
      • Obtain data on the user's homepage liked works
      • Get user homepage information
      • Get the user's homepage fan data
      • Get user's homepage follow data
      • Obtain data on the collection of works by users on the homepage
      • Get search data for users' homepage
      • Get user homepage playlist data
      • Get individual video comment data
      • Get comments and response data for specified videos
      • Generate msToken
      • Generate ttwid
      • Generate X-Bogus parameters using interface URL
      • Extract individual user sec_user_id
      • Extract list user sec_user_id
      • Extract individual works id
      • Extract list work id
      • Get user unique_id
      • Get the list unique_id
    • Bilibili web version API

      • Get individual video details
      • Get the video streaming address
      • Obtain data on video works published by users
      • Get all user favorites information
      • Get video data in the specified favorites
      • Get information about the specified user
      • Get comprehensive popular video information
      • Get comments for the specified video
      • Get a reply to the specified comment under the video
      • Get the specified user dynamics
      • Get real-time video barrage
      • Get information about the specified live broadcast room
      • Get live video streaming
      • Get the anchor who is currently broadcasting in the specified partition
      • Get a list of all live partitions
      • Obtain video score information through bv number

📦 Call the parsing library (deprecated and needs to be updated):

💡PIPI :https://pypi.org/project/douyin-tiktok-scraper/

Install the parsing library:pip install douyin-tiktok-scraper

import asyncio
from douyin_tiktok_scraper.scraper import Scraper

api = Scraper()

async def hybrid_parsing(url: str) -> dict:
    # Hybrid parsing(Douyin/TikTok URL)
    result = await api.hybrid_parsing(url)
    print(f"The hybrid parsing result:\n {result}")
    return result

asyncio.run(hybrid_parsing(url=input("Paste Douyin/TikTok/Bilibili share URL here: ")))

🗺️Supported submission formats:

💡 Tip: Includes but is not limited to the following examples. If you encounter link resolution failure, please enable a new one.issue

  • TikTok Sharing Password (Copy within the APP)
7.43 pda:/ 让你在几秒钟之内记住我  https://v.douyin.com/L5pbfdP/ 复制此链接,打开Dou音搜索,直接观看视频!
  • TikTok short URL (copy within the APP)
https://v.douyin.com/L4FJNR3/
  • Douyin Normal URL (web version copy)
https://www.douyin.com/video/6914948781100338440
  • TikTok Discovery Page URL (APP Copy)
https://www.douyin.com/discover?modal_id=7069543727328398622
  • TikTok short URL (copy within the APP)
https://www.tiktok.com/t/ZTR9nDNWq/
  • TikTok normal website address (web version copy)
https://www.tiktok.com/@evil0ctal/video/7156033831819037994
  • TikTok batch URL (no need to use matching separation)
https://v.douyin.com/L4NpDJ6/
https://www.douyin.com/video/7126745726494821640
2.84 nqe:/ 骑白马的也可以是公主%%百万转场变身https://v.douyin.com/L4FJNR3/ 复制此链接,打开Dou音搜索,直接观看视频!
https://www.tiktok.com/t/ZTR9nkkmL/
https://www.tiktok.com/t/ZTR9nDNWq/
https://www.tiktok.com/@evil0ctal/video/7156033831819037994

🛰️API Documentation

API documentation:

local:http://localhost/docs

Online:https://api.douyin.wtf/docs

API Demo:

  • Crawl video data (TikTok or Douyin mixed analysis)https://api.douyin.wtf/api/hybrid/video_data?url=[视频链接/Video URL]&minimal=false
  • Download video/picture album (TikTok or Douyin mixed analysis)https://api.douyin.wtf/api/download?url=[视频链接/Video URL]&prefix=true&with_watermark=false

For more demonstrations, please check the document content...

⚠️Preparation before deployment (please read carefully):

  • You need to solve the risk control problem of crawler cookies by yourself, otherwise the interface may be unavailable. After modifying the configuration file, you need to restart the service before it takes effect. It is best to use cookies from the account you have logged in.
    • Douyin web cookies (acquire and replace cookies in the following configuration files):
    • Cookie: __ac_nonce=06629f03b000ca74fd5d0; __ac_signature=_02B4Z6wo00f018OnaAwAAIDCyYGzp89TogfDh2yAAJbJ17; s_v_web_id=verify_lvetxr14_jPt0ZofI_p5Nw_44FG_BGSL_SVodoPoGUlGG; ttwid=1%7CtCoZxPEZnSPKZQhxavM2S9G9udonQu1yTp4eeGEhmOU%7C1714024522%7Ce9786696e4a0d08ac93356835424aece59d214e5f5c1d054dcb62cc18a48b829; IsDouyinActive=true; home_can_add_dy_2_desktop=%220%22; dy_swidth=1463; dy_sheight=915; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1463%2C%5C%22screen_height%5C%22%3A915%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A32%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A7.85%2C%5C%22effective_type%5C%22%3A%5C%224g%5C%22%2C%5C%22round_trip_time%5C%22%3A100%7D%22
    • TikTok web cookies (acquire and replace cookies in the following configuration files):
    • Cookie: tt_csrf_token=YmksDB6a-h4cT2fF7JpORI2O9UBMCWjsntIc; ttwid=1%7C0FVb9fFc-sjDG2UdJwdC1AirqYozQ0xfbAS4N72vN2Y%7C1713886256%7C78a9d83445b82b73ca8d4e0cf024ea6cdf1329b7f3866c826b0a69a300ebce46; ak_bmsc=51B1D53481A3A4E4D0CEFF2BCF622DA2~000000000000000000000000000000~YAAQ7uIsF6c4j+SOAQAAANmUCxfRGVXZ4D9xnO97l1yDw0OWyomnVkNY7IUKaggUja0kQzFQ+WG4xaxBcPt0AN0n26KeHXGGKgHYpHPUMUBHGHQGDtE4RLyy7U+LPbSJCqVaSDiPuzxHht0YUIbWogvrFmBfkP4ohcmjkZxWtEI9qQ4Whaobb2CFHGdKNt0zlVNBjJQ3uYRAvUe12zSBynQB18y6QhE8goneRkCEw9VIeft2pFIwNQ8tkWWEjDt6wHNaqeND7eASg5WLzYskWbTt6bPAOhSNRLJ38HZrOB5QNg+xxN5uuCSYmjMXCl8SkvQr91pInmOng+V898FLLBQtefs95whvbpfE0mKwBk5Cz2TkkHcUJa/IoC0CLmNqoEk3AtKxpw/J; tt_chain_token=46Xkv2ukMzyJ2e7XU7y0AQ==; bm_sv=A2E67B998DE8E6A4F1C2C02485467446~YAAQ7uIsF6g4j+SOAQAABdqUCxf1J/K4dYG0k7bbw2m5rFujdlSqMoCKDubu4R602nFvbY6zWC5puJczBv3IXwJJRpQxxR03wDCMVlKTCqjQvgDs8BoCuoNQxfY2fdS+F3bKut2lxXPQ2qctqz4kHBrgspJArHn/zu/IuKCIeSzmV4KcyxW6Zvw3/xMRA0MeHgyuHsTRBS+VrFk8Ju2NbJWWC8uSHbLCM/dhFT7/ktw8RE30r24XpQmhLpVTsUSC~1; tiktok_webapp_theme=light; msToken=ySXERzKCE0QUG0cCg6TWLw3wfEB-6kh6kAfuzhzjcQvmV1jBFloSgIsT9xk-QXFVdI99U1Fqb9mhUpIOldoDkjdZwskB8rvt66MHZaHnvBRZRtOKtTYsWT8osDyQXDVZWdPkvyE598h9; passport_csrf_token=1a47d95ebf68fc3648b0018ee75afc9f; passport_csrf_token_default=1a47d95ebf68fc3648b0018ee75afc9f; perf_feed_cache={%22expireTimestamp%22:1714057200000%2C%22itemIds%22:[%227346425092966206766%22%2C%227353812964207594795%22%2C%227343343741916171563%22]}; msToken=yWwG-ITrCnjJbx5ltBa9FTXdCImOJrl-wtQJSQH3afeEumWZcbo_qcrF6F7-NjYcrG6JVxtJiOU208REZeCSgXEZrrs5_65K741fQ7PSzCGOhz6vUyycq3Xvj4Mu-S0kJ6SqyltHnpJp
  • I turned off the online download function of the demonstration site. Someone downloaded a huge video and it crashed directly on my server. You can right-click to save the video on the web parsing result page...
  • The cookies on the demo site are my own and are not guaranteed to be valid for a long time. They only serve as a demonstration. If you deploy it yourself, please get the cookies yourself.
  • HTTP 403 error occurs if you need to access the video link returned by TikTok Web API. Please use the API in this project/api/downloadThe interface downloads TikTok videos. This interface has been manually closed in the demonstration site, and you need to deploy this project yourself.
  • There is one hereVideo tutorialYou can refer to:https://www.bilibili.com/video/BV1vE421j7NR/

💻Deployment (Method 1 Linux)

💡Tip: It is best to deploy this project to a server in the United States, otherwise strange bugs may occur.

Recommended to useDigitalOceanserver, because it can be free.

Sign up with my invitation link and you can get a credit of $200, and I can get a reward of $25 when you spend $25 on it.

My invitation link:

https://m.do.co/c/9f72a27dec35

Use scripts to deploy this project in one click

Turn on/stop service

  • Use the following command to control the operation or stop of the service:
    • sudo systemctl start Douyin_TikTok_Download_API.service
    • sudo systemctl stop Douyin_TikTok_Download_API.service

Turn on/off automatically

  • Use the following command to set the service to automatically run on or cancel the automatic run on:
    • sudo systemctl enable Douyin_TikTok_Download_API.service
    • sudo systemctl disable Douyin_TikTok_Download_API.service

Update the project

  • When the project is updated, make sure that the update script is executed in the virtual environment and update all dependencies. Enter the project bash directory and run update.sh:
  • cd /www/wwwroot/Douyin_TikTok_Download_API/bash && sudo bash update.sh

💽Deployment (Method 2 Docker)

💡 Tip: Docker deployment is the easiest way to deploy, suitable for users who are not familiar with Linux. This method is suitable for ensuring environmental consistency, isolation and quick settings. Please use a server that can access Douyin or TikTok normally, otherwise strange bugs may occur.

Preparation

Before you begin, make sure your system has Docker installed. If Docker is not installed, you canDocker official websiteDownload and install.

Step 1: Pull the Docker image

First, pull the latest Douyin_TikTok_Download_API image from Docker Hub.

docker pull evil0ctal/douyin_tiktok_download_api:latest

If necessary, you can replace itlatestTags for the specific version you need to deploy.

Step 2: Run the Docker container

After pulling the image, you can start a container from this image. The following are the commands to run the container, including the basic configuration:

docker run -d --name douyin_tiktok_api -p 80:80 evil0ctal/douyin_tiktok_download_api

Each part of this command works as follows:

  • -d: Run containers in the background (separated mode).
  • --name douyin_tiktok_api : Name the containerdouyin_tiktok_api
  • -p 80:80: Map port 80 on the host to port 80 of the container. Adjust the port number according to your configuration or port availability.
  • evil0ctal/douyin_tiktok_download_api: The name of the Docker image to be used.

Step 3: Verify that the container is running

Use the following command to check if your container is running:

docker ps

This lists all active containers. Finddouyin_tiktok_api to confirm its normal operation.

Step 4: Access the application

After the container runs, you should be able to passhttp://localhostOr the API client access Douyin_TikTok_Download_API. If you have a different port configured or accessed from a remote location, adjust the URL.

Optional: Custom Docker commands

For more advanced deployments, you may want to customize Docker commands, including environment variables, volume mounts for persistent data, or other Docker parameters. Here is an example:

docker run -d --name douyin_tiktok_api -p 80:80 \
  -v /path/to/your/data:/data \
  -e MY_ENV_VAR=my_value \
  evil0ctal/douyin_tiktok_download_api
  • -v /path/to/your/data:/data: Turn on the host/path/to/your/dataThe directory mounted to the container/dataDirectory, used to persist or share data.
  • -e MY_ENV_VAR=my_value: Set environment variables in the containerMY_ENV_VAR, its value ismy_value

Configuration file modification

Most of the configurations of the project can be found in the following directoriesconfig.yamlModify the file:

  • /crawlers/douyin/web/config.yaml
  • /crawlers/tiktok/web/config.yaml
  • /crawlers/tiktok/app/config.yaml

Step 5: Stop and remove the container

When you need to stop and remove the container, use the following command:

# Stop
docker stop douyin_tiktok_api 

# Remove
docker rm douyin_tiktok_api

📸Screenshot

API speed test (compare the official API)

🔎点击展开截图

TikTok official API:

This project API:

TikTok official API:

This project API:


Project interface

🔎点击展开截图

Web main interface:

Web main interface:


📜 Star History

Star History Chart

Apache-2.0 license

Start: 2021/11/06

Githubub:@Evil0ctal