Does Douyin have an API? Get videos and comments with Python (2026)
Douyin Open Platform reads the authorising user's own data, and keyword search of other people's videos is not open at present; to search videos and read comments from a program, use a third-party data API. Below it is done with DataXAPI's Python SDK; the free trial covers up to 333 calls. 2 endpoints do it: Douyin video search → Douyin video comments. The worked example below is 11 calls and costs $0.0400 in all; a failed call is not charged.
Search a page of Douyin videos on a keyword, take two pages of comments under the 5 most liked, and write one CSV: caption, likes, comment text, comment likes, time.
Step 1: Douyin video search
A page of videos for the search terms; sort can be newest or most liked, and published_within keeps the last day, week or half year. Each item's id is the video ID.
curl -G "https://api.dataxapi.com/v1/douyin/videos/search" \ --data-urlencode "query=露营" \ -H "Authorization: Bearer $DATAXAPI_API_KEY"
# pip install dataxapi from dataxapi import DataXAPI dx = DataXAPI() # reads DATAXAPI_API_KEY result = dx.douyin.videos.search(query="露营") print(result["data"]["items"])
// npm i @dataxapi/sdk import { DataXAPI } from "@dataxapi/sdk"; const dx = new DataXAPI(); // reads DATAXAPI_API_KEY const result = await dx.douyin.videos.search({ query: "露营" }); console.log(result.data.items);
dataxapi call douyin.videos.search 'query=露营'{
"code": "ok",
"request_id": "c4c779e7-8730-415a-ab8b-2439d70fb51a",
"data": {
"items": [
{
"id": "7732320280216651754",
"url": "https://www.douyin.com/video/7732320280216651754",
"type": "video",
"title": null,
"text": "周末的露营日常,随手记录一下",
"lang": "zh",
"published_at": "2026-09-11T01:32:11.000Z",
"author": {
"id": "MS4wLjABAAAAWo9vAvyTzp3sb2-krZmkriyZuGbWt-p4togQvkClUpj",
"username": "weekend_lin",
"name": "小林的周末",
"avatar_url": "https://p3-pc.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_ec931a72ca043f30fa7e.jpeg",
"followers": 2525
},
"metrics": {
"likes": 96505,
"comments": 2219,
"shares": 60467,
"favorites": 7038
},
"images": null,
"hashtags": ["户外生活", "好物分享"]
},
// … 6 more
]
},
"page": {
"next_cursor": "c1.ts-YHxldZuVXCxH6Gev5iQGlxtlGILU8V8n9tjjp",
"cursor_expires_at": "2026-10-12T20:01:55.000Z",
"has_more": true,
"returned": 7
},
"warnings": [],
"meta": {
"capability": "douyin.videos.search",
"result_status": "complete",
"fetched_at": "2026-10-12T19:01:55.000Z",
"cached": false,
"replayed": false,
"unavailable": {
"metrics.views": "capability",
"metrics.reposts": "platform",
"author.verified": "capability",
"mentions": "capability",
"post_id": "platform",
"parent_id": "platform",
"root_id": "platform",
"is_pinned": "capability"
},
"billing": {
"amount": "0.02",
"currency": "USD",
"balance_after": "9.98"
}
}
}From a response recorded 2026-10-12 19:01 UTC. Names, text and IDs are examples, and so are the links: none is the recorded one (the page shows no one's personal data); the figures are as recorded. Long lists are cut. The request ID, cursor and balance are made up.
Douyin video search · $0.0200 / a call · Parameters, fields and errors on the endpoint's page →
Step 2: Douyin video comments
Put the video ID into id for a page of about 20 comments; the next page comes from page.next_cursor. With only a link or share text, put it into url as it is.
curl -G "https://api.dataxapi.com/v1/douyin/videos/comments/list" \ --data-urlencode "id=7694940173372575014" \ -H "Authorization: Bearer $DATAXAPI_API_KEY"
# pip install dataxapi from dataxapi import DataXAPI dx = DataXAPI() # reads DATAXAPI_API_KEY result = dx.douyin.videos.comments.list(id="7694940173372575014") print(result["data"]["items"])
// npm i @dataxapi/sdk import { DataXAPI } from "@dataxapi/sdk"; const dx = new DataXAPI(); // reads DATAXAPI_API_KEY const result = await dx.douyin.videos.comments.list({ id: "7694940173372575014" }); console.log(result.data.items);
dataxapi call douyin.videos.comments.list id=7694940173372575014
{
"code": "ok",
"request_id": "d42da88d-b7ed-4b0d-9190-4b171bfc73ad",
"data": {
"items": [
{
"id": "7544703737319021316",
"text": "拍得好舒服,看了好几遍",
"published_at": "2026-10-10T07:45:43.000Z",
"author": {
"id": "MS4wLjABAAAASYaIbhAX0MPyFQ_-aWJ7QWUFF8a5fMOppwdnFl0eOFd",
"username": "nanfeng_0721",
"name": "南边的风",
"avatar_url": "https://p3-pc.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_ec3a5fcd08ca5afb5397.jpeg"
},
"metrics": { "likes": 11209, "comments": 1 },
"post_id": "7654977487690830406",
"parent_id": null,
"root_id": null
},
// … 19 more
]
},
"page": {
"next_cursor": "c1.WJBi7NXZjb_3e9vNCUTP2jkcLJBy9Nk7njwbaUrK",
"cursor_expires_at": "2026-10-16T19:31:05.000Z",
"has_more": true,
"returned": 20
},
"warnings": [],
"meta": {
"capability": "douyin.videos.comments.list",
"result_status": "complete",
"fetched_at": "2026-10-16T18:31:05.000Z",
"cached": false,
"replayed": false,
"unavailable": { "url": "platform" },
"billing": {
"amount": "0.002",
"currency": "USD",
"balance_after": "9.998"
}
}
}From a response recorded 2026-10-16 18:31 UTC. Names, text and IDs are examples, and so are the links: none is the recorded one (the page shows no one's personal data); the figures are as recorded. Long lists are cut. The request ID, cursor and balance are made up.
Douyin video comments · $0.0020 / a call · Parameters, fields and errors on the endpoint's page →
What the example costs
One page of search results, then two pages of comments under 5 videos
Prices are the prices in force when this page was built. A failed call costs nothing.
In your AI (MCP)
Connect DataXAPI to your AI client once. Then say what you want; the agent finds these endpoints, checks the price and calls them on your balance.
{
"capability": "douyin.videos.search",
"query": "露营",
"idempotency_key": "<a new UUID>"
}Sign in to copy the setup prompt with your keyAbout the MCP server →
With a Skill
Why DataXAPI
- Steady: endpoints were available 99.9% of the last 30 days, on a public status page you can check.
- Fast: a paid call took 2.2 seconds at the median over the last 7 days (counted 2026-11-06).
- Fewer tokens: across 36 endpoints on Douyin, one recorded real response each, the platform's own JSON comes to 2.4M tokens and what an AI reads through DataXAPI's MCP server to 72k, 97% fewer; the JSON of a direct API call is 96% fewer too (counted 2026-11-06). Every platform answers in one shape: the author in
author, counts inmetrics, the next page inpage.next_cursor, so another platform needs no new parser. - See before you pay: every endpoint's page shows a recorded real response, field by field.
- Spending you control: a failed call is not charged; each key can have a limit,
X-Max-Pricecaps one call, and the sameIdempotency-Keywithin 24 hours is never charged twice. - Ready for AI: a remote MCP server listed in the official MCP registry as
com.dataxapi/mcp, usable from Claude, Cursor and ChatGPT. - Free trial of up to 333 calls, no card.
Good to know
- No Douyin account or cookie, and no signatures such as
a_bogusormsTokento produce. - Replies come from
douyin.comments.replies.list, with the comment ID and the video ID. - Without code: connect DataXAPI to Claude or ChatGPT and say the sentence under “In your AI”.
The whole script
The task above as one script that runs as it is: Python, the SDK, your key from DATAXAPI_API_KEY. It writes a CSV file and ends by printing what it called, fetched and was charged.
# pip install dataxapi # export DATAXAPI_API_KEY=dx_... (your key) import csv from decimal import Decimal from dataxapi import DataXAPI dx = DataXAPI() calls, fetched, charged = 0, 0, Decimal("0") def run(capability, params): """One call; counts it and what it was charged.""" global calls, charged result = dx.call(capability, params) calls += 1 charged += Decimal(str(result["meta"]["billing"]["amount"])) return result QUERY = "露营" VIDEOS, PAGES = 5, 2 # 1. A page of videos for the search terms; the most liked first. videos = run("douyin.videos.search", {"query": QUERY})["data"]["items"] videos = sorted(videos, key=lambda each: -(each["metrics"].get("likes") or 0))[:VIDEOS] # 2. Two pages of comments under each video. rows = [] for video in videos: cursor = None for _ in range(PAGES): page = run("douyin.videos.comments.list", {"id": video["id"], **({"cursor": cursor} if cursor else {})}) for comment in page["data"]["items"]: rows.append([video.get("text"), video["metrics"].get("likes"), comment.get("text"), comment["metrics"].get("likes"), comment.get("published_at")]) cursor = page["page"]["next_cursor"] if not page["page"]["has_more"]: break fetched = len(rows) with open("douyin-videos-comments.csv", "w", newline="", encoding="utf-8") as file: csv.writer(file).writerows([["caption", "video_likes", "comment", "comment_likes", "published_at"], *rows]) print(f"calls: {calls}, items: {fetched}, charged: ${charged}")