# 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.

Updated 2026-11-06

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 by step

### 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. ([Douyin video search](https://dataxapi.com/apis/douyin/videos/search/), $0.0200 / a call)

cURL

```bash
curl -G "https://api.dataxapi.com/v1/douyin/videos/search" \
  --data-urlencode "query=露营" \
  -H "Authorization: Bearer $DATAXAPI_API_KEY"
```

Python

```python
# pip install dataxapi
from dataxapi import DataXAPI

dx = DataXAPI()  # reads DATAXAPI_API_KEY
result = dx.douyin.videos.search(query="露营")
print(result["data"]["items"])
```

TypeScript

```typescript
// 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);
```

CLI

```bash
dataxapi call douyin.videos.search 'query=露营'
```

Recorded response: 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.

```jsonc
{
  "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"
    }
  }
}
```

### 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. ([Douyin video comments](https://dataxapi.com/apis/douyin/videos/comments/list/), $0.0020 / a call)

cURL

```bash
curl -G "https://api.dataxapi.com/v1/douyin/videos/comments/list" \
  --data-urlencode "id=7694940173372575014" \
  -H "Authorization: Bearer $DATAXAPI_API_KEY"
```

Python

```python
# 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"])
```

TypeScript

```typescript
// 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);
```

CLI

```bash
dataxapi call douyin.videos.comments.list id=7694940173372575014
```

Recorded response: 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.

```jsonc
{
  "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"
    }
  }
}
```

## What the example costs

One page of search results, then two pages of comments under 5 videos

| Endpoint | Calls | Price | Subtotal |
| --- | --- | --- | --- |
| [Douyin video search](https://dataxapi.com/apis/douyin/videos/search/) | 1 | $0.0200 | $0.0200 |
| [Douyin video comments](https://dataxapi.com/apis/douyin/videos/comments/list/) | 10 | $0.0020 | $0.0200 |
| Total | 11 |  | $0.0400 |

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.

Say: Search Douyin for 露营 (camping) videos from the last week, take the 5 most liked, get two pages of comments under each, as one table.

What the agent sends to the call tool: 

```json
{
  "capability": "douyin.videos.search",
  "query": "露营",
  "idempotency_key": "<a new UUID>"
}
```

[About the MCP server](https://dataxapi.com/mcp/)

## With a Skill

The Comments and word of mouth Skill does this job as a ready-made task, under a spending cap. “What are people praising and complaining about under this post?” Its example run: 3 calls, at most $0.0060. [Comments and word of mouth](https://dataxapi.com/skills/comments/)

## 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 in `metrics`, the next page in `page.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-Price` caps one call, and the same `Idempotency-Key` within 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_bogus` or `msToken` to 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.

```python
# 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}")
```

## Endpoints

- [Douyin video search](https://dataxapi.com/apis/douyin/videos/search/)
- [Douyin video comments](https://dataxapi.com/apis/douyin/videos/comments/list/)

## More about Douyin

- [Douyin API](https://dataxapi.com/apis/douyin/)
- [How to get Douyin keyword trends in bulk](https://dataxapi.com/guides/douyin-keyword-trends/)
- [How to export Douyin video comments in bulk](https://dataxapi.com/guides/douyin-video-comments/)
- [How to look up a Douyin creator's Xingtu rate card](https://dataxapi.com/guides/douyin-xingtu-creator-rates/)
- [How do I export Douyin data?](https://dataxapi.com/answers/export-douyin-data/)
- [What is sec_uid on Douyin, and how is it different from uid and the Douyin ID?](https://dataxapi.com/answers/douyin-sec-uid/)
- [What are aweme_id and modal_id on Douyin, and what is a v.douyin.com link?](https://dataxapi.com/answers/douyin-aweme-id-modal-id/)
- [Is the Douyin search index a number of searches?](https://dataxapi.com/answers/douyin-search-index-vs-search-count/)
- [What is the Douyin keyword index (Ocean Engine)?](https://dataxapi.com/answers/what-is-douyin-keyword-index-ocean-engine/)
- [What is Douyin Xingtu?](https://dataxapi.com/answers/what-is-douyin-xingtu/)
- [Douyin API for developers: third-party Douyin data APIs and what they return (2026)](https://dataxapi.com/answers/douyin-third-party-data-apis/)
- [Douyin video download URL: getting a video's play address by API (2026)](https://dataxapi.com/answers/douyin-video-play-url-api/)
- [Which social media data API is best for AI agents? Count the tokens a response takes (2026)](https://dataxapi.com/answers/social-media-api-for-ai-agents/)

---

Catalog revision 9d3b7fa5a896745d. [HTML version](https://dataxapi.com/guides/douyin-api-python/)
