Social media5 min readBy Purrkey teamUpdated

How to search TikTok videos by hashtag with an AI agent

Search TikTok by hashtag and get matching videos with captions, views, likes, comments, and shares

On this page

Your campaign hashtag is live and you need the first page of TikTok videos that carry it, with views, likes, comments and shares side by side, so you can decide which creators and which sounds deserve a closer look. One call to anyapi.tiktok.search_hashtag returns that page as normalized JSON, and the agent reshapes it into the table below

No run has been executed for this guide. The table and its values are a design, not a result

The table the agent returns

One row per video, nine columns, in this order: id, caption, author, views, likes, comments, shares, createdUtc, url. Values here are placeholders showing the shape

idcaptionauthorviewslikescommentssharescreatedUtcurl
(video id)(caption text)(username)0000(Unix seconds)(TikTok URL)

views, likes, comments and shares are listed as required fields on each video object, so a blank cell in one of those columns means the row was not passed through cleanly

Step 1: send the hashtag

query is the only required input; the schema describes it as the hashtag or keyword to search for, with no # sign needed. Leave the # sign off

Example: set query to your campaign hashtag before the run

Two optional inputs are listed. cursor takes a pagination cursor from a previous response. requireFields names output fields the request must be able to return, and its permitted values are locationName, soundAuthor and soundTitle

Step 2: read the fields that decide the shortlist

found at the top level says whether the call produced a result. When it is false, reason is present with the value not_found, and the contract treats that answer as a successful call rather than an error

The engagement counts arrive as integers. The tool does not return an engagement rate, so likes per thousand views and comments per thousand views are calculations you run on the returned table yourself

createdUtc is a UTC epoch timestamp in seconds, so multiply by 1000 to get a JS Date when you sort by recency. id is the stable key for deduplicating rows, and url is the canonical TikTok link to the video

Beyond the required set, a video object can carry authorName, authorVerified, saves, durationSeconds, hashtags, soundClipId, soundTitle, soundAuthor and locationName. The last three are defined as nullable, so a null in that cell can mean the video carries no such detail or that the serving source does not report it

Step 3: page through and watch the price-raising input

data.nextCursor is an opaque cursor and is null when that lane has no more pages. Pass it back as cursor to continue the walk

requireFields is the input that can move the price. Omit it and routing is unchanged, with the cheapest source serving. Name a field the cheapest source cannot return and a dearer source serves, quoted and charged at its price. Its reach is limited: it applies to the first page only, so later pages stay with the source that page chose, at the price it was quoted. Naming a combination no single source returns together is refused as invalid input, with no charge, and a named field can still be absent on a video that genuinely lacks it

For a first-page engagement review, leave requireFields out and read soundTitle or locationName where the source happens to supply them

The agent prompt

Agent prompt
Set up https://purrkey.app/SKILL.md, then use Purrkey to search TikTok for
the campaign hashtag below and return one table of the first page of videos.
Check the current inputs and price of anyapi.tiktok.search_hashtag before
running anything. Call the tool once with query set to the hashtag, without
the leading # sign. Do not set requireFields on this first pass. If a second
page is needed, pass data.nextCursor back as cursor and keep the same table
shape. Return columns in this order: id, caption, author, views, likes,
comments, shares, createdUtc, url, one row per video. If found is false, say
so and report the reason instead of building a table. Do not invent values
for fields the response does not carry.

recipe

Swap the example hashtag for your own and keep the first run to a single page so you can see the shape of the rows before extending the walk

Estimated tool cost

One tool id, one unit price. anyapi.tiktok.search_hashtag is called through POST /v1/runs with toolId anyapi.tiktok.search_hashtag and is listed at up to $0.0036 per call, read through the Purrkey catalog on November 13, 2026. The unit is max_call, defined in the catalog as "Maximum per call. Successful runs settle at the actual AnyAPI charge". The totals below are ceilings, not settled charges, and agent model fees are not counted

StepFormulaUnit pricePlanned quantityTotal
First page1 call x max price$0.0036 per call1$0.0036
Three-page walk3 calls x max price$0.0036 per call3$0.0108

A three-page walk means three calls, one per page, with the cursor from each response feeding the next

Next action

Run the prompt once on your campaign hashtag, then open the TikTok search_hashtag tool page to check the current listing before you extend to a paged walk. For hashtag-level trend work rather than video rows, the companion article sits at trending hashtags on TikTok

Get started by giving this to your agent

  • Claude Code
  • Codex
  • Gemini CLI
  • Cursor
  • GitHub Copilot
Set up https://purrkey.app/SKILL.md, then use Purrkey to show me what I can do with TikTok.
Explore TikTok tools and pricing

FAQ

How do I search TikTok videos by hashtag?

Call anyapi.tiktok.search_hashtag once with the campaign hashtag in the query field, without the leading # sign. The response returns a page of matching videos with caption, author, views, likes, comments and shares as normalized JSON.

What inputs does anyapi.tiktok.search_hashtag take?

query is required and takes the hashtag or keyword without the leading #. cursor is optional and takes a pagination cursor from a previous response. requireFields is optional and names output fields the request must be able to return, from locationName, soundAuthor and soundTitle.

Does the hashtag need a # in front of it?

No. The schema describes query as the hashtag or keyword to search for, without the leading #. Leave the symbol off and send the word on its own.

How do I get the next page of TikTok hashtag results?

Take data.nextCursor from the response and pass it back as cursor. It is null when that lane has no more videos.

Does requireFields cost more?

It can. When the cheapest source cannot return a named field, a dearer source serves and you are quoted and charged its price. A combination no single source returns together is refused as invalid input, with no charge.

How much does a TikTok hashtag search cost?

The tool is listed at up to $0.0036 per call under the max_call unit. A single first page is one call at most $0.0036, and a three-page walk is three calls at most $0.0108.

What happens when a hashtag search finds nothing?

The response returns found as false with reason set to not_found. The contract treats that as a successful call rather than an error.

Next step

Try this with TikTok

The tool directory lists every endpoint with its current price. Inspect the inputs there, then let your agent run a small batch before scaling up.

See TikTok tools

Share this article