Stay up to date with AI tools, model releases, and developer workflows that matter.

According to recent reports, weekly. Free. One click to leave.

It has been revealed that 7 Day Free Trial. Cancel Anytime.

You need a YouTube API key the moment your app has to read anything from YouTube: a video's length, its view count, a channel's latest uploads. Getting one takes about five minutes. Using it well takes a little longer, because YouTube changed how its quota works in June 2026, and plenty of guides still describe the old rules.

In this guide we'll get a key, lock it down and test it. Then we'll use it from Node.js for three real jobs: adding up the length of a playlist, listing a channel's videos without spending a search, and estimating what a video earned. Along the way we'll cover what the YouTube API costs (nothing), how the 2026 quota works, and the errors you're most likely to hit.

A YouTube API key identifies your project to the YouTube Data API v3. With just a key, you can read public data:.

According to recent reports, A key isn't enough for anything that touches someone's account. Uploading videos, editing playlists or reading private data needs OAuth 2.0, where the user signs in and grants your app access.

According to recent reports, you'll need a Google account. The YouTube Data API is free, so there's nothing to pay for.

The restrictions matter more than they look. A key is just a string in a URL, and anyone who copies an unrestricted one can spend your daily quota for you. With an API restriction, the key is useless for other Google APIs. With an application restriction, it only works from your server or your site. Changes to restrictions can take up to five minutes to apply, so don't panic if a request fails straight after you save.

According to recent reports, before writing any code, check the key with a single request. This one asks for the first video ever uploaded to YouTube, and uses the fields parameter to trim the response down to four values:.

If the key works, you'll get this back:.

That request cost 1 unit of your daily quota, which brings us to the question everyone asks.

Sources indicate that yes. There's no charge per request and no paid plan. Instead you get a daily quota, and since June 1, 2026 it's split into separate buckets:.

In a recent development, google's quota calculator lists the cost of every method. Quotas reset at midnight Pacific Time. Every request costs at least 1 unit, including requests that fail, so a retry loop around a broken call can use up a day's quota on its own.

If you've read older guides, search is the big change. A search used to cost 100 units out of the same 10,000, so 100 searches emptied your whole day. Uploads were worse still, at about 1,600 units each until December 2025. Now both have their own buckets, and the 10,000 units are left for everything else.

To give you a feel for what 10,000 units buys, here's what each example in this guide costs:.

According to recent reports, you can't pay for more. To go above the defaults, fill in the YouTube API Services Audit and Quota Extension Form, which is linked from Google's page on quota and compliance audits. YouTube first audits your project to check it follows the YouTube API Services Terms of Service, then someone from the API team gets back to you. Google doesn't give a timeline, so apply well before you need the extra quota.

Sources indicate that most projects never need to. The rest of this guide is about getting a lot done with very few units.

The examples need Node.js 20.6 or later, for the built-in fetch and the --env-file flag. There are no packages to install. Make a folder with a .env file in it:.

Every example imports one small helper. It builds the URL, adds your key and turns API errors into readable messages:.

Run any example with node --env-file=.env followed by the file name.

YouTube doesn't tell you how long a playlist is. To work it out, you need two methods:.

Durations come back in ISO 8601 format. PT15M33S is 15 minutes 33 seconds, PT1H2M3S adds an hour, and a stream longer than a day looks like P1DT2H3M4S. The toSeconds() function below handles all three.

Here it is on freeCodeCamp's Full Courses in One Video playlist:.

That's 184 hours of courses for 4 units of quota. Private and deleted videos still show up in a playlist's items, but videos.list doesn't return them, which is why the script prints "52 of 52 videos available". On a playlist with removed videos, the two numbers will differ.

This is the core of the free YouTube playlist length calculator I built on createthat.ai. The live version adds a target time box that works out the speed you need to finish by a deadline, and it accepts channel, video and Shorts links as well as playlists.

The obvious way to find a channel's videos is to search for them. Don't: search is now capped at 100 calls a day, and it isn't built to list everything a channel has posted. Every channel has an uploads playlist instead, and you can reach it in two cheap calls:.

Two units, and none of your 100 daily searches. To get every upload rather than the newest five, page through the playlist with the same pageToken loop as Example 1.

videos.list with part=statistics returns a video's view, like and comment counts. Dislike counts have been private since December 2021 and favoriteCount is always 0, so don't build anything on those. The script also copes with a missing like or comment count, which you'll see on some videos.

This time the fields parameter trims the response to the values we use. That makes the response smaller, but it doesn't change the cost: the call is 1 unit either way.

Here it is on freeCodeCamp's Learn Python full course, one of the most-watched videos in that playlist:.

In a recent development, treat the last line as a rough range, not an answer. The Data API doesn't share anyone's revenue, so any estimate is views multiplied by an RPM: what a creator keeps per 1,000 views. RPM moves a lot with the topic and where the viewers live, and the estimate assumes the video demonstrates ads, which not every channel does.

And sometimes you don't need an API at all. When I built a font tester, I needed a list of Google Fonts. The Google Fonts Developer API would have meant a key and a call on every visit, for a list that barely changes. Instead I generated a file of the 500 most popular fonts once, from Google's public font metadata, and the page loads it like any other file. No key, no quota and nothing to fail.

When a call fails, the response's error.message and error.details[0].reason tell you why. These are the ones you'll see most:.

For the invalid key error, the full response looks like this:.

Yes. Creating a key and calling the YouTube Data API costs nothing. You're limited by the daily quota instead, and there's no paid tier: more quota comes through an audit.

Sources indicate that in the Google Cloud console, select your project and go to APIs & Services > Credentials. Your keys are listed under API keys, with a Show key option next to each one.

Industry observers note that it works, but anyone can read the key from your page. If you do it, restrict the key to your website and to the YouTube Data API v3. A small server route that calls the API for you is safer, and it gives you somewhere to cache results.

By default, 100 searches, 100 uploads and 10,000 units for everything else. Most reads cost 1 unit and videos.list takes 50 IDs per call, so that's enough for the details of up to 500,000 videos a day.

Getting a YouTube API key is the easy part: one project, one API to enable, one key and two restrictions. The 2026 quota is generous if you work with it:.

Industry observers note that all three examples together cost 7 units, out of 10,000. From here, try commentThreads.list to pull a video's comments 100 at a time, or extend Example 2 to page through a channel's entire upload history and add it all up with the code from Example 1.

According to recent reports, 7 Day Free Trial. Cancel Anytime.

→ Read original article