# How do I get the IP location of Douyin commenters and count them by province?

> Collect Douyin comments with the IP location Douyin displays for each one, tally commenters by province, and see what the field can and cannot tell you. Cost per 1,000.

Canonical page: https://okdata.online/answers/douyin-comment-ip-location/

**Short answer: **Each comment from the okdata Douyin video comments endpoint carries ip_location, the province Douyin shows next to it, so a province tally is a count over the comments you collect. A page of about 20 comments costs $0.002, so 1,000 comments cost $0.10; Xiaohongshu comments carry the same field.

A regional food brand wants to know where the people commenting on its Douyin videos are, before deciding which cities get the next store opening. Douyin shows an IP location (IP属地) next to every comment, so the data is there. Scrapers often lose it: search results do not carry it, and some tools never map the field from comments. Comments fetched through an API carry that field, so a province breakdown is a simple count.

## Where the field is

[Douyin video comments](/apis/douyin/videos/comments/list/) returns `ip_location` on every comment, as Douyin displays it, usually a province or region name such as 广东 or 四川. Video search results do not include it; it belongs to comments (and, with `view=full`, to account profiles under `ext`).

## Steps

1. Pick videos: your own, or the top results of [video search](/apis/douyin/videos/search/) for your category.
2. Page through comments for each video.
3. Count `ip_location` values. Weight by likes if you want "who agrees" rather than "who speaks".

## Cost

| Job | Calls | Cost |
|---|---|---|
| 1,000 comments | 50 | $0.10 |
| 20 videos × 5 pages | 100 | $0.20 |
| Same study on 20 Xiaohongshu notes × 5 pages | 100 | $2.00 |

## Script

```python
import os, requests
from collections import Counter

URL = "https://api.okdata.online/v1/douyin/videos/comments/list"
HEAD = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}
where = Counter()
for vid in ["7301234567890123456"]:
    params = {"id": vid, "fields": "ip_location,likes"}
    for _ in range(5):
        body = requests.get(URL, headers=HEAD, params=params, timeout=60).json()
        where.update(c["ip_location"] or "unknown" for c in body["data"]["items"])
        if not body["page"]["has_more"]:
            break
        params["cursor"] = body["page"]["next_cursor"]
print(where.most_common(10))
```

## Read it with care

- It is the location of the commenter's IP as Douyin labels it, at province level. VPNs, travel and mobile networks blur it. It says nothing about city or district.
- Some comments have no label; count them as unknown rather than dropping them.
- Commenters are not viewers. People who comment skew toward engaged fans; treat the result as "where the conversation is".
- Top-level comments only; replies are counted per comment but not returned.

## Alternatives

For your own account, Douyin's creator center shows audience region for viewers, a better source for "where is my audience". Xingtu shows audience region for creators you might hire. For comparing regions across competitors' videos, public comments are what is available; see [word-of-mouth analysis](/solutions/word-of-mouth/).

## Endpoints used

- [Douyin video comments](https://okdata.online/apis/douyin/videos/comments/list/) `douyin.videos.comments.list`: $0.002 per call · about 20 comments per page
- [Douyin video search](https://okdata.online/apis/douyin/videos/search/) `douyin.videos.search`: $0.02 per call · about 20 videos per page
- [Xiaohongshu note comments](https://okdata.online/apis/xiaohongshu/notes/comments/list/) `xiaohongshu.notes.comments.list`: $0.02 per call · about 10 comments per page

Updated 2026-11-12
