Answers
How do I get the IP location of Douyin commenters and count them by province?
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 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
- Pick videos: your own, or the top results of video search for your category.
- Page through comments for each video.
- Count
ip_locationvalues. 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
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.
Updated