# Douyin API for public creator videos and likes in Python

> Douyin's API reads only accounts that authorize your app. Our Douyin API returns 20 public videos a call with likes, shares and saves as JSON.

- URL: https://toolzerhub.com/blog/douyin-api
- Published: 2026-11-05
- Publisher: ToolzerHub (we sell the API this post describes)

## Short answer

- Douyin's Open Platform reads only the accounts that log in to your app through Douyin login, and it has no route for a public creator's videos.
- Douyin doesn't expose view counts, so play_count comes back 0 and engagement means the likes, comments, shares and saves that every video returns.
- ToolzerHub's Douyin API returns 20 public videos per call at 2 credits, so 60 videos of one account cost 8 credits, or 10 from a handle.

Douyin has an API, but it only reads accounts that log in to your app. The Douyin Open Platform serves apps whose users authorize them, and it has no route for a public creator's videos. To get any creator's videos and engagement, you read Douyin's public pages. Our API does that, and the script below saves an account's videos to CSV.

## What Douyin's API is for

Douyin's [Open Platform](https://developer.open-douyin.com/capacity-center-page/capacity-detail/7180522194714230845) lets an app sign Douyin users in through OAuth 2.0 and, with the video.list and video.data scopes, query the video list of each user who authorized it. It has no route for a public creator's videos. If you build tools for creators who manage their own accounts, that is the right route. Douyin is ByteDance's Chinese app, separate from TikTok, and TikTok's APIs don't return Douyin data.

## Douyin videos with ToolzerHub

We make ToolzerHub. Our [Douyin API](https://toolzerhub.com/apis/douyin) returns public Douyin data as JSON under `/v2/douyin`, with one API key in the `x-api-key` header. Most routes cost 2 credits a call. This post uses three:

- `profiles/info?sec_user_id=...` returns followers, video count, total likes and following.
- `profiles/info/by-username?username=...` turns a handle such as `rmrbxmt` into its sec_user_id.
- `profiles/posts?sec_user_id=...` returns up to 20 videos a call, newest first, with a cursor for older ones.

Other routes cover video detail, comments, hashtags, music and trend boards; search costs 15 credits. For People's Daily (人民日报, handle rmrbxmt), `profiles/info` returns 203,677,970 followers, 12,622 videos and 19,271,669,518 total likes.

```bash
export TOOLZERHUB_API_KEY=your_key
curl -G -H "x-api-key: $TOOLZERHUB_API_KEY" \
  --data-urlencode "sec_user_id=MS4wLjABAAAA8U_l6rBzmy7bcy6xOJel4v0RzoR_wfAubGPeJimN__4" \
  --data-urlencode "count=20" \
  "https://api.toolzerhub.com/v2/douyin/profiles/posts"
```

The response sits inside `data`. Its paging fields and the first video in `data.aweme_list`, trimmed to its counts:

```json
{
  "has_more": 1,
  "max_cursor": 1793713622000,
  "aweme_list": [
    {
      "aweme_id": "7704311890205265194",
      "duration": 23403,
      "statistics": {
        "digg_count": 187181,
        "comment_count": 97,
        "share_count": 4880,
        "collect_count": 7988,
        "download_count": 288,
        "play_count": 0
      }
    }
  ]
}
```

`digg_count` is likes, `collect_count` is saves and `duration` is milliseconds. `play_count` was 0 on all 20 videos because Douyin doesn't expose view counts. Send `max_cursor` as `cursor` to get the next 20.

## Save a creator's videos to CSV

The script takes a handle or a sec_user_id and pulls pages of 20 videos. It appends one row per video: date, description, length in seconds, likes, comments, shares, saves, downloads and link. A handle costs one extra call, because the handle lookup only resolves the sec_user_id. Save it as `douyin_videos.py` and install `requests` (`pip install requests`).

```python
import csv
import os
import sys
import time
from datetime import datetime, timezone

import requests

BASE = "https://api.toolzerhub.com/v2/douyin"
HEADERS = {"x-api-key": os.environ.get("TOOLZERHUB_API_KEY", "")}
FIELDS = ["account", "aweme_id", "date", "desc", "duration_s", "likes", "comments", "shares",
          "saves", "downloads", "url"]


def get(path, params, tries=3):
    for attempt in range(tries):
        r = requests.get(f"{BASE}/{path}", headers=HEADERS, params=params, timeout=90)
        if r.status_code in (429, 500, 502, 503, 504) and attempt < tries - 1:
            time.sleep(10 * (attempt + 1))
            continue
        r.raise_for_status()
        return r.json()["data"]


def profile(account):
    # sec_user_id values start with MS4wLjABAAAA; anything else is treated as a Douyin handle.
    # The handle lookup returns no follower count, so it only resolves the sec_user_id.
    if not account.startswith("MS4wLjABAAAA"):
        account = get("profiles/info/by-username", {"username": account})["user_info"]["sec_uid"]
    return get("profiles/info", {"sec_user_id": account})["user"]


def main(account, pages="3", out="douyin_videos.csv"):
    user = profile(account)
    sec_uid = user["sec_uid"]
    print(f"{user['nickname']}: {user.get('follower_count')} followers, {user.get('aweme_count')} videos")
    rows, cursor = [], 0
    for _ in range(int(pages)):
        data = get("profiles/posts", {"sec_user_id": sec_uid, "count": 20, "cursor": cursor})
        for v in data.get("aweme_list") or []:
            s = v["statistics"]
            rows.append({
                "account": user["nickname"], "aweme_id": v["aweme_id"],
                "date": datetime.fromtimestamp(v["create_time"], timezone.utc).date().isoformat(),
                "desc": v["desc"], "duration_s": round(v["duration"] / 1000),
                "likes": s["digg_count"], "comments": s["comment_count"], "shares": s["share_count"],
                "saves": s["collect_count"], "downloads": s["download_count"],
                "url": f"https://www.douyin.com/video/{v['aweme_id']}",
            })
        if not data.get("has_more"):
            break
        cursor = data["max_cursor"]  # older videos start from here
    new_file = not os.path.exists(out)
    with open(out, "a", newline="", encoding="utf-8-sig" if new_file else "utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=FIELDS)
        if new_file:
            writer.writeheader()
        writer.writerows(rows)
    print(f"{len(rows)} videos appended to {out}")


if __name__ == "__main__":
    if len(sys.argv) < 2:
        sys.exit("usage: python douyin_videos.py rmrbxmt [pages] [file.csv]   (handle or sec_user_id)")
    if not HEADERS["x-api-key"]:
        sys.exit("set TOOLZERHUB_API_KEY first")
    main(*sys.argv[1:])
```

## What the videos showed

We ran the script on three accounts at 3 pages each. `python douyin_videos.py rmrbxmt 3` saved 60 People's Daily videos in 5 calls and 25.3 seconds. CNR Military (央广军事, 12,039,617 followers) and 小莉帮忙 (12,205,086 followers) returned 60 and 62 videos in 4 calls each, in 8.8 and 9.3 seconds.

Three pages cover 4 to 26 days, and median likes run from 332 to 189,749:

| Account | Videos | Days covered | Median likes | Shares per like | Saves per like |
|---|---|---|---|---|---|
| People's Daily | 60 | 4 | 189,749 | 0.258 | 0.057 |
| CNR Military | 60 | 26 | 13,974 | 0.069 | 0.045 |
| 小莉帮忙 | 62 | 5 | 332 | 2.335 | 0.179 |

Set the page count by how often an account posts: 60 videos reach back 4 days on People's Daily but 26 days on CNR Military.

小莉帮忙 has the smallest likes but the most sharing: its videos get more than twice as many shares as likes. Likes alone would rank it far below both news accounts.

CNR Military's top video, 5,000 recruits in a night drill, has 1,525,526 likes against the account's median of 13,974, and more than People's Daily's best at 886,899. Median length was 27 to 36 seconds on all three accounts.

## What it costs

`profiles/info` and `profiles/posts` cost 2 credits a call, so 60 videos of one account are 8 credits, or 10 from a handle. A weekly check of 10 accounts at 3 pages is about 340-400 credits a month. You get 100 free credits a month; $19 buys 10,000 credits that never expire, and [plans for higher volume](https://toolzerhub.com/pricing) cover larger watchlists. Set your key and run the script on rmrbxmt; People's Daily's last 60 videos are a CSV in under half a minute.

For the TikTok version, see [TikTok user videos via API](https://toolzerhub.com/blog/tiktok-api-get-user-videos); for another Chinese platform, see [Xiaohongshu search API in Python](https://toolzerhub.com/blog/xiaohongshu-search-api-python). To export a video's comments, see [the Douyin comments scraper](https://toolzerhub.com/blog/douyin-comments-scraper).

We are not affiliated with Douyin.
