Blog / API guides

YouTube Scraper or API: What You Get

A YouTube scraper is code that loads YouTube pages and pulls titles, view figures, channel details, comments and transcripts out of what comes back. You maintain the fetching, the parsing and the fixes when either breaks. The other route is 15 YouTube endpoints that return the same kinds of data as JSON at 1 credit per successful call. This post compares the two job by job, works out the cost per video and channel tracked, and gives a verdict per use case.

What does building a YouTube scraper involve?

A YouTube scraper is several small scrapers, one per kind of page, plus the code that keeps them honest. Search results, a video's page, a channel's page and its video list, comments and transcripts each have their own layout and their own way of loading more. Each one needs a fetcher, a parser and a check that the output still looks right.

The fetcher is the easy part to write and the hard part to keep running. Pages on a large video site are built for browsers, so the fields you want may sit in the HTML, in data embedded in the page, or in later requests the page makes. You find out which by reading the page, and you find out again when it changes. Any site that size also has to tell people from automated traffic, so a scraper that runs daily at volume should expect slow responses, challenge pages and blocks. Getting around those protections with rotating proxies or CAPTCHA solvers isn't a fix we'd recommend.

The parser is where silent failures live. A layout change rarely throws an error; it returns an empty view count, a missing date or half the comments. So the monitor matters as much as the scraper: compare each run's row counts and empty fields with the last run. Before you build any of it, read YouTube's terms of service.

What do the YouTube endpoints cover?

The YouTube API on Perceptlayer has 15 endpoints, all GET, all 1 credit per successful call. They map onto the page types a scraper would handle: search, a video, a channel and its videos, comments, transcripts and trending. Each returns JSON with named fields, so there's no parser of yours to break. Failed calls cost nothing and return X-Credits-Used: 0.

Job Endpoint Parameters you'll use first
Search GET /v1/youtube/search query, type, order, videoDuration, publishedAfter, publishedBefore, limit, continuation
One video GET /v1/youtube/video video_id
A video's chapters GET /v1/youtube/chapters video_id
A channel GET /v1/youtube/channel channel_id
A channel's videos GET /v1/youtube/channel-videos channel_id, sort (newest, popular, oldest), type (videos, shorts, live, podcasts)
A channel's playlists GET /v1/youtube/channel-playlists channel_id
One playlist GET /v1/youtube/playlist playlist_id
Comments GET /v1/youtube/comments video_id (required), limit
Transcript GET /v1/youtube/transcript video_id, language
Trending GET /v1/youtube/trending type (now, music, gaming, movies), gl

Several endpoints accept the same ID under two spellings: channel_id or channelId, video_id or videoId. Use one consistently. The rest of the set covers related videos, search suggestions, channel community posts, a second transcript endpoint keyed on videoId, and Locales, which takes no parameters. The reference documents types and allowed values only, so it states no defaults or page sizes.

A search request

This request searches for programming tutorials:

curl "https://api.perceptlayer.com/v1/youtube/search?query=programming+tutorial" \
  -H "X-API-Key: $API_KEY"

To filter it, add documented parameters. order takes date, rating, relevance or viewCount, and videoDuration takes short, medium or long:

curl "https://api.perceptlayer.com/v1/youtube/search?query=programming+tutorial&type=video&order=date&videoDuration=long" \
  -H "X-API-Key: $API_KEY"

No response is recorded for the YouTube endpoints yet, so this post doesn't show one. Run the call in the playground on the YouTube API page to see the fields, and check there whether search results carry IDs in the form video and comments expect before you chain them.

How do a scraper and the endpoints compare?

The scraper costs engineering time and carries terms and blocking risk; the endpoints cost credits per call and take the parsing and upkeep off your hands. The table compares them for a recurring job, such as following a few hundred videos and channels every day.

DIY YouTube scraper YouTube endpoints
Setup Fetcher, a parser per page type, storage, monitoring API key in the X-API-Key header
Search Parse result pages and follow "load more" yourself search with order, videoDuration, date bounds and continuation
Video and channel details Parse each page; fix the parser when the layout moves video, channel, channel-videos, chapters
Comments Page through them yourself comments with video_id and limit
Transcripts Find and parse the caption data per video transcript with video_id and language
Trending Parse the trending page per region trending with type and gl
When pages change Your parser breaks, often silently You read named JSON fields
Blocks and challenges Yours to handle at volume Not yours; a failed call returns an error code and costs 0
Speed As fast as you can fetch without being blocked 1 request a second free, at least 5 a second paid
Cost Hosting and your time 1 credit per successful call

The official route is a third option, with its own trade-offs. YouTube Data API Quota: Limits, Costs and Alternatives covers its daily quota and what search-heavy and transcript jobs run into, so this post doesn't repeat it.

What does tracking a video or channel cost?

On the endpoints, cost follows calls, and each call is 1 credit. A daily snapshot of one video is one video call, so 1 credit per video per day. A daily check on one channel is a channel call plus a channel-videos call sorted newest, so 2 credits per channel per day. You usually need a video's transcript once, so cache it and treat it as a one-off 1 credit.

Job Calls Credits
500 videos, snapshot once a day 500 a day 500 a day, 15,000 per 30 days
100 channels, channel + channel-videos daily 200 a day 200 a day, 6,000 per 30 days
2,000 transcripts, once 2,000 2,000
300 search queries, once a week 300 a week 300 a week, 15,600 a year
Trending, 4 type values × 10 gl values, daily 40 a day 40 a day, 1,200 per 30 days

The 100 free credits on signup cover a small test of any of these jobs, or the first 2 days of the trending row. That row is 1,200 credits per 30 days, so the Starter pack's 10,000 covers about eight months of it. The 500-video job is 15,000 credits a month and needs purchased credits; the Build pack's 50,000 covers just over three months of it, and purchased credits last 12 months. At 500 calls, the free tier's 1 request a second finishes the run in under 9 minutes. See pricing for what credits cost and the credits docs for how they're debited.

Comments cost by the call, not by the comment. Each comments request is 1 credit, and limit is an optional integer whose range isn't documented, so test the values you need in the playground and count the comments per call before estimating a large job.

What do the restricted-endpoint terms mean for YouTube data?

The YouTube API includes restricted endpoints. They work after you accept the restricted-endpoint terms in your dashboard; until then a call returns restricted_endpoint (403) and costs nothing. The terms don't permit collecting personal data without a lawful basis or using it to contact people, which matters most for comments.

Use comments in aggregate: how many a video draws, which topics or product names come up, how the mix changes after a release. Don't store commenters' names or handles, don't build profiles of individual viewers, and don't use comments to message anyone. Video, channel, transcript and trending data is public content about videos, so the job there is to respect the creators' rights in what you republish. Data is collected from publicly available sources and returned as found at the time of the call.

Which route should you choose?

Choose by what you track and how often, since that decides whether upkeep or per-call cost dominates. The verdicts below assume a recurring job. To look at a few videos once, open YouTube in a browser and skip both routes.

  • Daily view and engagement snapshots for a fixed video list: use video on a schedule and store the response with the run date. It's 1 credit per video per day.
  • Watching competitors' or partners' channels for new uploads: call channel-videos with sort=newest daily, and channel weekly for channel-level figures. Budget 2 credits per channel per day at most.
  • Transcripts for search, summaries or an LLM corpus: call transcript once per video with the language you need, and cache the result. It's a one-off 1 credit per video.
  • Topic research across many videos: run search with order and the publishedAfter and publishedBefore bounds, weekly, then fetch details only for the videos you keep.
  • Audience feedback on your own videos: comments in aggregate, counted and grouped by topic, without storing who wrote what.
  • An app that uploads, manages or acts for signed-in YouTube users: these endpoints don't do that; look at YouTube's own developer options.
  • Learning how scraping works: build a scraper against a practice site, not a large video platform.

For an agent that answers "what's trending in gaming" or "summarise this video", connect the MCP server so it calls trending or transcript directly; the AI agents docs cover setup. TikTok API: Official Options and Public Trend Data covers the same kind of trend data on another platform. To test the fields for your own job, run search in the playground on the YouTube API page, then get a free API key.

APIs in this post

Frequently asked questions

Is scraping YouTube allowed?

That depends on YouTube's terms of service, the rights in the content you store or republish, and the law where you operate, so read the terms and get legal advice for commercial use. Don't get around blocks, challenges or other protections. Video facts and aggregate figures are lower risk than personal data; leave commenters' names and handles out of anything you keep.

How much does a YouTube transcript cost?

One GET /v1/youtube/transcript call per video, at 1 credit when it succeeds. Pass the video_id and, if you need a specific one, a language. You usually need each transcript once, so cache it: 2,000 transcripts cost 2,000 credits. A failed call costs nothing and returns X-Credits-Used: 0.

Can I get YouTube comments without a scraper?

Yes. GET /v1/youtube/comments takes a required video_id of up to 11 characters and an optional limit, and costs 1 credit per successful call. It's a restricted endpoint: accept the restricted-endpoint terms first, use comments in aggregate, and don't use them to profile or contact the people who wrote them.

How do I get more search results than one call returns?

GET /v1/youtube/search takes page and continuation as optional parameters, and limit as an optional integer. The reference doesn't document page sizes or how continuation values are issued, so check a response in the playground before you build paging. Each further page is a separate call at 1 credit.

What happens when a YouTube call fails?

You pay nothing. The response has an HTTP status and a JSON body with error.code, error.message and error.request_id, plus X-Credits-Used: 0. A rate-limited call returns rate_limited (429) with a Retry-After header in seconds. The errors docs list every code, and the rate limits docs list each pack's rate.

  1. YouTube Data API Quota: Limits, Costs and Alternatives

    YouTube Data API quota: 100 search.list calls and 10,000 units a day by default, 200 units per caption download. The arithmetic, and a per-call alternative.

  2. Vimeo API: Public Videos as JSON

    Three restricted Vimeo endpoints at 1 credit each: video search with a total count, video details and an account's public videos, with real responses.

  3. Reddit Scraper or API: What You Get

    A Reddit scraper vs 14 Reddit endpoints at 1 credit a call: a recorded search with score, num_comments and next_after, and the cost per subreddit tracked.

Start with 100 free credits

No password to set. We email you a sign-in link, and your key works on every API.

No credit card. 100 free credits on signup.