Social media5 min readBy Purrkey teamUpdated

How to search YouTube videos by keyword

Get a normalized table of YouTube videos with titles, channels, views, lengths and publish times from one keyword search

On this page

You need a first-page set of 10 YouTube videos for the query "how to cook rice", with titles, channels, view counts, lengths and publish times in one table you can scan before choosing a tutorial angle. The set comes from one call to a YouTube search tool that returns normalized JSON

The worksheet below is the deliverable. No run has been executed for this article, so the values show the shape of the table and nothing more

The task and the table design

The decision you are feeding is editorial: which tutorial angle and which creator style to prioritize for a new video. A first page of 10 rows is small enough to read by eye and wide enough to show which channels dominate the phrase

Example input, labelled as a phrase to replace: query is "how to cook rice"

Table design for the deliverable. Values here are placeholders showing the shape

idtitlechannelviewslengthTextpublishedTimeurlDecision
(video id)(video title)(channel name)0(mm:ss)(relative time)(video URL)keep or skip

The Decision column is yours to fill after reading the row. Nothing in the response writes it for you

Input the tool takes

anyapi.youtube.search is called through POST /v1/runs with toolId anyapi.youtube.search. The query string is required and holds the search phrase. Four optional properties shape the answer:

  • cursor: a continuation token taken from a previous response's nextCursor
  • sortBy: relevance (the default) or popular (most-viewed)
  • uploadDate: today, this_week, this_month or this_year; omit it for any time
  • requireFields: an array of output field names the request must be able to return, with nextCursor as the documented value

requireCursor is deprecated. The contract says to send requireFields: ["nextCursor"] in its place, which does exactly the same thing, and to omit it when you do not intend to page. Those are the documented properties; check the current input schema before a run rather than treating the list as closed

Example input, with a phrase you swap for your own: {"query": "how to cook rice"}. Keep the value a plain search phrase

Reading the output fields that drive the decision

The response carries found, data and reason. found is a boolean. data is null or an object holding a videos array and a nextCursor. reason appears only when found is false, and its one documented value is not_found, meaning the source states the target does not exist or returned nothing for it. That is a successful call, not an error

Each entry in videos returns id, url, title, channel, views, lengthText and publishedTime as required fields, plus authorId, authorAvatarUrl, image and createdUtc when the serving source has them. Two of those decide your sort. views is an integer, so it sorts as a number. publishedTime is a string, so it does not; reach for createdUtc when you need a sortable timestamp, since it is a UTC epoch value in seconds that you multiply by 1000 for a JS Date in milliseconds. lengthText is a string too, so read it as display text and compare it by hand

Paging is where this tool has a cost trap. Cursor paging requires nextCursor, and asking for it through requireFields can raise the quote when the cheapest source cannot page: a source that can page serves instead, and you are quoted and charged its price. The contract adds that a named field can still be absent on a result that genuinely lacks it, and that on a paginated walk the requirement applies to the first page only, with later pages staying with the source that page chose at the price it was quoted

The agent prompt

Agent prompt
Set up https://purrkey.app/SKILL.md, then use Purrkey to search YouTube
for the query "how to cook rice" and return the first page of videos as a
table. Check the current inputs and price of anyapi.youtube.search before
running anything. Send one request with sortBy set to relevance, no
uploadDate and no cursor. If a nextCursor comes back and page one leaves
the question open, send it as cursor for a second page and say in the
output that the table covers two pages. Return columns id, title, channel,
views, lengthText, publishedTime, url and a decision column with keep or
skip. Leave a cell empty when the response has no value for it and do not
invent values.

Replace the query with your own phrase. The first run is one call. Add the second page only after you have read page one, because a paging request can come back at a higher quoted price than a plain search

Estimated tool cost

Prices come from the Purrkey catalog, read November 13, 2026, under price revision anyapi-catalog-2026-11-05. The unit is max_call, explained once: "Maximum per call. Successful runs settle at the actual AnyAPI charge." The totals below are ceilings, not settled charges

StepFormulaUnit pricePlanned quantityTotal
First page onlycalls x max priceup to $0.0012 per call1$0.0012
Two-page cursor walkcalls x max priceup to $0.0012 per call2$0.0024

Model fees for the agent are not counted. The two-page row assumes both requests settle at the base price; if the first request names nextCursor and the cheapest source cannot page, that call can be quoted higher

Next action

Run the search from the YouTube search tool page. If the 10 rows leave you with one or two creators worth a closer look, the companion article is Check YouTube channel stats and links

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 YouTube.
Explore YouTube tools and pricing

FAQ

How do I search YouTube videos by keyword?

Send the phrase as query to anyapi.youtube.search and read the videos array in the response. Each entry carries id, url, title, channel, views, lengthText and publishedTime.

What inputs does anyapi.youtube.search take?

query is required. cursor, sortBy, uploadDate and requireFields are optional, and requireCursor is deprecated and should be omitted.

How much does a YouTube keyword search cost?

The catalog lists it at up to $0.0012 per call, as a max_call ceiling. One first-page request is at most $0.0012 and a two-page cursor walk is at most $0.0024.

Why can asking for nextCursor raise the price?

When the cheapest source cannot page, a source that can serves the request, and you are quoted and charged its price. Naming nextCursor through requireFields is what triggers that routing.

What does a found false response mean?

reason is not_found, which means the source states the target does not exist or returned nothing for it. It is a successful call, not an error.

Which output field should I sort on?

views is an integer and sorts as a number. publishedTime and lengthText are strings, so use createdUtc, a UTC epoch value in seconds, when you need a sortable timestamp.

Next step

Try this with YouTube

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 YouTube tools

Share this article