Hand it to your AI agent
Copy this prompt into Claude Code, Cursor, Codex or any coding agent. It tells the agent where the docs are and how to use your API key.
Use the Lovely Router data tool "Search YouTube videos" (id `youtube-search`, YouTube) to get data for me. It returns JSON.
- Docs (read first): https://lovelyrouter.com/docs/tools/run.md and https://lovelyrouter.com/docs/api/tools.md
- Input fields and price: GET https://lovelyrouter.com/v1/tools/youtube-search (public, no key needed). Price: $0.00125 / video.
- Run: POST https://lovelyrouter.com/v1/tools/youtube-search/run with a body like `{"input":{"keywords":["espresso tutorial"],"maxItems":5},"max_results":10}`. A 200 has the finished run with `items`; a 202 means it is still running, so poll the `poll` path until `status` is `succeeded`, `failed`, `timed_out` or `stopped`.
- Only delivered results are billed. Keep max_results small on the first run, check the output, then scale up (up to 200 per run).
- If you support MCP, you can instead connect the server https://lovelyrouter.com/mcp (Streamable HTTP, same key; https://lovelyrouter.com/docs/tools/mcp.md) and use suggest_tools, get_tool and run_tool with tool "youtube-search".
- Auth: read my API key from the LOVELY_API_KEY environment variable and send it as `Authorization: Bearer $LOVELY_API_KEY`. Never print or commit the key. If it is not set, ask me to create one at https://lovelyrouter.com/app/keys.
- Billing is prepaid: every call is charged to my balance, so test with a small request before running anything large.
- Every docs page is plain Markdown; the full index is https://lovelyrouter.com/llms.txt.
My task: <describe the data you need, e.g. which places, profiles, keywords or URLs, and the output format>Input
keywordsarraySearch terms, one search per entry.
startUrlsarrayYouTube links instead of (or besides) keywords: search results, channel, playlist or video URLs.
sortstringSorts search results by the given option. Only works with search keywords.
r · ra · u · v
uploadDatestringUpload date for the search results, which is passed to YouTube as the upload date URL query parameter. (any, hour, today, week, month, year) Only works with search keywords.
all · l · t · w · m · y
durationstringDuration of the video for the search results, which is passed to YouTube as the duration URL query parameter. (any, short, long)
all · s · l
maxItemsintegerMaximum number of items that you want as output.
Try it
Call it from code
How runs, polling and billing work →curl https://lovelyrouter.com/v1/tools/youtube-search/run \
-H "Authorization: Bearer $LOVELY_API_KEY" \
-H "content-type: application/json" \
-d '{"input":{"keywords":["espresso tutorial"],"maxItems":5},"max_results":10}'# MCP (agents): suggest_tools → get_tool → run_tool
run_tool({
"tool": "youtube-search",
"input": {"keywords":["espresso tutorial"],"maxItems":5},
"max_results": 10
})What it costs
| Results | Runs (at 200 per run) | Cost |
|---|---|---|
| 100 | 1 | $0.125 |
| 1,000 | 5 | $1.25 |
| 10,000 | 50 | $12.50 |
Prepaid, no subscription. Fewer results than requested cost less. Pricing
Used for
Frequently asked questions
How much does the Search YouTube videos API cost?
$0.00125 / video. 1,000 results, fetched in runs of up to 200, cost $1.25. There is no subscription: you pay from a prepaid balance.
Is this a YouTube scraper?
Yes. If you searched for a YouTube scraper, a YouTube video data API or a YouTube search results scraper, this is it: YouTube videos for search keywords, or from YouTube links (search results, channel, playlist or video URLs): title, views, likes, comments count, duration, channel, date.
How many results does one run return?
10 by default and up to 200 per run. Set max_results to cap a run: you are billed only for the results it delivers.
Do I need a YouTube account or API key?
No. You call the tool with your Lovely Router API key and get JSON back. There is nothing to set up on YouTube.
Can an AI agent use this tool?
Yes. Connect Claude Code, Cursor or any MCP client to the Lovely Router MCP server: the agent finds the tool with suggest_tools and runs it with run_tool and the id youtube-search.
What happens if a run fails?
A run that fails or is stopped pays only for the results it delivered, with no call fee. The most a run can cost is held when it starts and the rest is released when it settles.