# How do I get the videos for a TikTok hashtag through an API?

> No TikTok hashtag feed here, so search the tag as a keyword and keep the videos that carry it. How well that works, what it costs, and when to use something else.

Canonical page: https://okdata.online/answers/tiktok-hashtag-videos-api/

**Short answer: **There is no hashtag feed in the catalog, so search the tag as a keyword with TikTok video search (/v1/tiktok/videos/search) and keep the videos whose hashtags list contains it. Each page of about 30 videos costs $0.002; 300 videos take 10 calls, $0.02.

A café chain launched #matchamonday and wants to see what people posted with it: who joined, which videos got liked, what they said in the captions. On TikTok you open the hashtag page and scroll. Through an API you cannot fetch that page directly, at least not here. What you can do is search for the tag and filter. For most campaign checks that gets you the videos that matter, the ones TikTok ranks highest.

## How to do it

1. Search the tag text with [TikTok video search](/apis/tiktok/videos/search/), as plain words: `matchamonday` or `matcha monday`.
2. Each video comes back with a `hashtags` list. Keep only the videos whose list contains the tag, compared in lowercase.
3. Page with `page.next_cursor` until you stop finding new matches.
4. Use `sort=most_liked` to see the top of the tag first.

```python
import os, requests

URL = "https://api.okdata.online/v1/tiktok/videos/search"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}
TAG = "matchamonday"

found, cursor = {}, None
for _ in range(10):  # at most 10 pages, about 300 videos
    params = {"query": TAG, "sort": "most_liked", **({"cursor": cursor} if cursor else {})}
    body = requests.get(URL, headers=H, params=params, timeout=60).json()
    if body["code"] != "ok":
        raise RuntimeError(f"{body['code']}: {body['message']}")
    for v in body["data"]["items"]:
        if TAG in [h.lower() for h in (v["hashtags"] or [])]:
            found[v["id"]] = (v["author"]["username"], v["metrics"]["likes"], v["url"])
    if not body["page"]["has_more"]:
        break
    cursor = body["page"]["next_cursor"]

print(len(found), "videos carry", "#" + TAG)
```

## Cost

| Depth | Calls | Cost |
|---|---|---|
| First page | 1 | $0.002 |
| About 300 videos | 10 | $0.02 |
| 1,000 videos | 34 | $0.068 |

You pay for every page you fetch, including the videos the filter throws away. A distinctive tag wastes little; a generic one like #fyp wastes most of each page.

## Where this falls short

- You get what search returns for the words, ranked by relevance or likes. That overlaps with the hashtag page but is not the same list, and it is not every video ever tagged.
- The tag's total view count shown on its TikTok page is not returned.
- There is no date filter; sort on `published_at` to see the newest posts.
- For a big, long-running tag, you will see the head of it, not the long tail.

## When to use something else

- **TikTok's Research API** can query by hashtag name with a date range, and it is free for approved non-profit academic researchers.
- **TikTok Creative Center** shows which hashtags are trending by region for advertisers, without code.
- **TikTokApi's hashtag feature** exists, though its issue tracker is full of reports that it stops returning results.

For tracking what rises and falls over weeks, see [trend research](/solutions/trend-research/).

## Endpoints used

- [TikTok video search](https://okdata.online/apis/tiktok/videos/search/) `tiktok.videos.search`: $0.002 per call · about 30 videos per page

Updated 2026-11-12
