I have found YouTube to be a great tool to grow a business. And the good news? You don’t need to film a single second of video to take advantage of it. Thanks to the YouTube data API, you can embed and display existing videos directly on your site.
No need for storyboarding, scripting, or editing. Just leverage what’s already out there.
In this guide, I’ll walk you through how the YouTube API works, how to get your API key, and how to use it to showcase the right content, drive engagement, and strengthen your brand, all without ever hitting “record.”
Table of Contents
- What is the YouTube API?
- YouTube API Data
- Benefits of Using the YouTube API
- How to Get a YouTube API Key
- YouTube API Key Troubleshooting
- How to Access YouTube Live API
- YouTube API Examples
- Custom YouTube API Code Samples
- How to Use the YouTube API on Your WordPress Website
- YouTube API FAQs
What is the YouTube API?
The YouTube API is an application programming interface that allows you to embed videos, curate playlists, and offer other YouTube functionalities on your website. It helps businesses offer advanced video sharing features on their website or app without needing to write code from scratch.
Like other APIs (or Application Programming Interfaces), the YouTube API makes a programmer’s work easier by skipping the drudgery of writing every single line of code every time users need to access data. Instead, programmers can use predefined functions and protocols to curate YouTube videos on a website.
Consider it a link between your app or website and the vast amount of information available on YouTube. The API allows you to:
- Retrieve channels, playlists, and video information.
- Show current data of videos, such as views, likes, and comments.
- Dynamically embed content according to channel activity or keywords.
- Control user activities such as playlists, uploads, and subscriptions (with appropriate authentication).
With that in mind, what kind of data can you feature using the YouTube API? Let’s take a look.

Free Ebook: How to Use an API
Everything you need to know about the history and use of APIs.
- A History of APIs
- Using APIs
- Understanding API Documentation
- And more!
Download Free
All fields are required.

YouTube API Data
The YouTube API gives you access to YouTube’s data in a more comprehensive, scalable way than standalone YouTube embed codes would. You can retrieve entire playlists, users’ uploads, and even search results using the YouTube API. To enable viewers to upload videos and manage channel subscriptions directly from your website or app, you may also include YouTube features in your website.
Let's examine a few of the most widely used features of the API.
YouTube Resource |
Example HTTP Request |
Description |
i.e., what we’d like to use the API for |
i.e., one possible request we could make with this resource |
i.e., what the action would look like on our website or app |
GET / search |
Retrieves a range of search results based on the query we’ve set. |
|
DELETE / playlists |
Deletes a playlist. |
|
POST / videos |
Uploads a video to YouTube from our website or app. |
|
POST / comments / markAsSpam |
Allows us to flag one or more comments as spam. |
|
GET / channels |
Retrieves a channel’s videos or playlists (or any other resource, such as comments). |
|
POST / subscriptions |
Adds a subscriber to an authenticated user’s channel. |
|
GET / members |
Retrieves a list of members for a channel that has given us authorization. |
|
PUT / captions |
Updates a caption track (we can upload a new file or change it to a draft). |
|
POST / channelSections |
Allows us to add a section of featured videos, for example, to an authenticated user’s channel. |
|
POST / watermarks / unset |
Allows us to remove a watermark image associated with a channel. |
The above list is not an exhaustive list; I recommend perusing Google’s official documentation.
Benefits of Using the YouTube API
Many marketers and business owners are missing out on the benefits of incorporating YouTube into their digital marketing strategy. Usually, it’s a question of how much time it takes to create high-quality video content.
In a typical YouTube marketing strategy, I would consistently publish video content every week with the hopes of generating likes and subscribers, a portion of which I’d hope would convert into customers. Luckily, this is no longer the only way to use YouTube for your business. YouTube has created an API that allows you to integrate your website with the social platform.
Below are some of the greatest benefits of using the YouTube API.
Leverage existing content without creating your own.
You don’t need a camera or editing software to use the YouTube API. I’ve built entire content hubs just by embedding relevant, high-quality videos from trusted channels. It’s a smart way to deliver value without the cost of content production.
Customize the viewing experience.
Unlike default embed codes, the API gives you full control over how content is displayed. I can design responsive video grids, apply filters based on tags or views, or even sort content by engagement metrics, all without touching the YouTube frontend.
Improve SEO and engagement.
When you integrate video content intelligently, you keep users on your site longer. You will see bounce rates drop and session durations increase just by embedding relevant videos through the API. Plus, search engines tend to favor pages with embedded video content.
Enable real-time features.
From showing a “Now Streaming” banner to updating video stats live on a product page, the YouTube API lets you build interactive experiences. I can use it to create countdowns for upcoming streams and real-time viewer counters for high-traffic events.
Access analytics and performance data.
For clients who want to track how embedded content performs, we can pull data directly from YouTube's API into custom dashboards. This makes it easier to measure impact without jumping into YouTube Studio every time.
For many marketers, using the YouTube API is a no-brainer, yet YouTube restricts access to this useful tool and its data. In order to give access to users whilst protecting the platform from possible abuse, YouTube gives each user a unique API key that enables them to link their website or app to the platform.
Let’s now walk through the process I use to obtain a YouTube API key.
How to Get a YouTube API Key
- Log in to Google Developers Console.
- Create a Google Cloud project.
- On the new project dashboard, click Enable APIs and services.
- In the library, navigate to YouTube Data API v3 under YouTube APIs.
- Enable the API.
- Create a credential (API key).
If you’d prefer to watch a video, check out this walkthrough by ShopiDevs:
1. Log in to Google Developers Console.
The first step I take is logging in to my Google Developers Console using my Google account. If you don’t yet have one, you’ll need to create one.
2. Create a Google Cloud project.
Once I am logged in, I’ll be given the option to Create or Select a project.
For the purpose of this blog, I will be creating a new project by clicking the New Project button. I’ll be taken to a screen where I can add a project name, select my organization, and select a location (URL).
You can create a project without an organization. If you don’t have an organization, you won’t be prompted to select a location. Just make sure you use a personal account because if you use a work account, then it will be mandatory to have an organization.
Once I create a project, everything I do from here onwards, including creating the API key, will apply only to that specific project. If you have multiple projects going at the same time, ensure that the correct one is selected by double-checking that the project is listed on the top navigation bar.
3. On the new project dashboard, click Enable APIs and services.
After creating a project, I’ll be taken to a dashboard where I can find information about my project.
In this dashboard, to move further, I have to click on Enable APIs and service. This takes me to a library of all the APIs and services Google offers.
4. In the library, navigate to YouTube Data API v3 under YouTube APIs.
Amongst the APIs in the API library, I have the YouTube API, with which I get three options:
- YouTube Data API v3
- YouTube Analytics API
- YouTube Reporting API
Because I am looking to use YouTube’s vast bank of videos, I will select YouTube Data API v3, as it gives me access to YouTube’s data, such as videos, playlists, and channels.
Alternatively, I can search for the YouTube Data API in the search bar.
5. Enable the API.
After I arrive at the YouTube Data API page, I will click a blue button with the word Enable.
6. Create a credential (API key).
After clicking Enable, I’ll be taken to an overview page with details about the API. On the left-hand side, I will click on the Credentials button.
In order to get my API key, I will click on the create credentials button, which will give me the option to create an API key, OAuth client ID, and service account.
From here, I just choose the API key option, and voila, I have my API key.
YouTube API Key Troubleshooting
Even when you follow all the setup steps, issues can still pop up. Below are the biggest questions I get about YouTube API keys and how I usually solve them.
Where is my YouTube API key?
Let’s say I am a novice. I’ve created an API key, and I don’t know how to find it. Here’s the step-by-step process.
- Step 1. Log in to Google Developers Console.
- Step 2. I’ll automatically be taken to my project dashboard; here there should be a sidebar, and I will click Credentials.
- Step 3. All done! You’ll find the YouTube API key you created.
Pro tip: Name each API key clearly when creating it, something like YouTube_API_Key, so you don’t have to guess later.
My YouTube API Key is not working.
Sometimes, even if your key looks correct, it just won’t work. I’ve seen this happen often, and here’s what I usually check first:
1. Wrong Project? I make sure I am in the right Google Cloud project. Keys are particular to different projects.
2. Key Restrictions Misconfigured. If I’ve added HTTP referrer or IP restrictions, I do well to verify them to match my actual environment.
3. Corrupted or Old Key. Sometimes everything is done right, but the keys just act up. I simply create a new one. This step is often easier than troubleshooting.
My API was accidentally exposed in public code.
Mistakes like this happen, especially when debugging in CodePen, JSFiddle, or GitHub. But exposed keys can get abused quickly.
What I do:
- I immediately delete or regenerate the API key from the Google Cloud Console.
- Then I replace the key in my code and add restrictions to the new one.
My API keeps getting permission errors even when enabled.
If I’m trying to access restricted resources, like posting comments or managing videos, I need OAuth, not just an API key.
What I do:
- I check the Google documentation to see if the endpoint requires OAuth 2.0.
- If yes, I generate OAuth credentials and follow the full authorization flow.

Free Ebook: How to Use an API
Everything you need to know about the history and use of APIs.
- A History of APIs
- Using APIs
- Understanding API Documentation
- And more!
Download Free
All fields are required.

How to Access YouTube Live API
YouTube Live is a very useful tool for setting up marketing campaigns and software products. It can be used to stream live content programmatically on YouTube, like live Q&As, webinars, or real-time product demos. Here’s how I can set it up.
1. First, get the YouTube API key.
Earlier, we discussed how to get your YouTube API key, as that’s the only way you get access to YouTube services.
First, I set up my project, website, or app, and then get a YouTube API key. This key will let me access YouTube’s Live Streaming API.
Don’t forget to register your app with Google so that your API requests are successfully authenticated.
2. Understand the key resources.
YouTube’s Live Streaming API works with distinct resources, each one serving a different purpose. Here are the main ones I focus on when automating or enhancing livestream campaigns:
- liveBroadcast, metadata of my live event (e.g., title, schedule, privacy).
- liveStream, the actual video feed settings, encoder configuration, stream resolution, etc.
- liveCuepoint, which lets me insert mid-roll ad breaks during a live session.
The API also overlaps with YouTube Data API resources, such as:
- video (your on-demand content).
- videoAdvertisingOptions (ad settings for monetization).
- asset and policy (for rights management).
3. Know what you can do (methods & capabilities).
Each resource comes with a set of methods; here’s an example using liveBroadcast.
- List. Retrieve current or scheduled broadcasts.
- Insert. Create a new broadcast.
- Update. Modify the stream metadata or settings.
- Delete. Remove an existing broadcast.
These methods give you a powerful level of control. You can use insert and update to dynamically create live events from a custom CMS panel for marketing teams. If you’re not a coder, plugins like WP YouTube Live can offer a simpler UI integration.
4. Test everything in Google’s API explorer.
Before deploying anything in production, I strongly recommend using the API Explorer Tool.
It lets me:
- Select a resource and method (like liveBroadcasts.insert).
- Enter parameters (e.g., title, scheduled start time).
- Preview the JSON response.
This is a sandbox environment that helps me experiment without breaking my site or app. As a dev-marketer, this can save time debugging in production.
If you’re looking for more general examples of the YouTube data API, you’re in luck. Below, I share some code samples for common things you might want to do using the API.
YouTube API Examples
What are some other ways we can use the YouTube API on your website or app?
Below are practical, ready-to-run examples for common use cases, ideal for marketers collaborating with developers or devs building YouTube-powered features.
1. Retrieving Your Uploads
The following code samples allow you to retrieve your own or another user’s uploads. Choose the one that aligns with the coding language or platform you’re using.
AppsScript
See the Pen YouTube API Example: Retrieving Uploads by HubSpot (@hubspot) on CodePen.
Go
See the Pen YouTube API Example: Retrieving Uploads (Go) by HubSpot (@hubspot) on CodePen.
.NET
See the Pen YouTube API Example: Retrieving Uploads (.NET) by HubSpot (@hubspot) on CodePen.
Ruby
See the Pen YouTube API Example: Retrieving Uploads (Ruby) by HubSpot (@hubspot) on CodePen.
2. Retrieving Search Results for a Certain Keyword
We can also use the YouTube API to retrieve search results for a certain keyword. Use the code samples below to do so.
AppsScript
See the Pen YouTube API Example: Search (AppsScript) by HubSpot (@hubspot) on CodePen.
Go
See the Pen YouTube API Example: Search (Go) by HubSpot (@hubspot) on CodePen.
.NET
See the Pen YouTube API Example: Search (.NET) by HubSpot (@hubspot) on CodePen.
Ruby
See the Pen YouTube API Example: Search (Ruby) by HubSpot (@hubspot) on CodePen.
For more AppsScript, Go, .NET, and Ruby code samples, click here.
Custom YouTube API Code Samples
If we want to connect our website or app to YouTube using code, whether you’re working in Java, JavaScript, PHP, Python, or even curl, the YouTube Data API v3 documentation offers a rich library of customizable code samples to help us get started quickly. Click here to access code samples you can customize.
To create a code sample for your specific use case, take the following steps.
1. Choose a resource.
I start by selecting the type of data I want to access. Common resource types include:
- channels
- videos
- playlists
- search
Each resource contains different kinds of YouTube data.
2. Pick a method.
Each resource offers a set of methods based on what you want to do. For example, the video resource includes:
- list – Retrieve details about specific videos.
- getRating – Check the rating a user gave to a video.
- insert – Upload or add a video.
3. Find a relevant use case.
Once I’ve selected a method, I then look for a specific example that aligns with my project. For instance:
If I want to display trending video, I’ll use the videos.list to aggregate the most popular videos.
If I want to show a user’s liked videos? Then I use the same videos.list method, but adjust parameters accordingly.
4. Use the “Try This API” tool.
Next to each use case, I click the </> icon to open the “Try this API” tool. Here’s what I can do:
- Customize request parameters, like videoCategoryId or regionCode.
- Preview and modify the API request in real time.
- Select my preferred language, such as Python or JavaScript.
5. Execute and generate your code.
Once I’m happy with my setup, I:
- Click Execute.
- Log in with my Google account and allow access.
- View the generated code snippet right within the tool.
How to Use the YouTube API on Your WordPress Website
If you’re new to APIs and don’t know how to use them on your website, you’re in luck. It’s relatively simple to do, even if you don’t have any advanced technical knowledge.
One of the most effective ways to promote your business through video marketing, without creating the videos yourself, is to curate YouTube content. With so much content already being created on YouTube (500 hours of video per minute), browsing on the platform can get overwhelming for the user.
Using a plugin and a YouTube API key, you can step in and develop standalone content or lists of videos about specific subjects within your industry. This will make it easier for your audience to discover quality YouTube content while promoting the content creator for free. Your payment comes about in the form of growing website traffic.
Video is also a great way to illustrate your points when writing blog posts. It delivers the message faster, can cover more depth, and is the preferred content consumption method for many.
Here are some WordPress YouTube plugins you can use to engage your visitors on your WordPress website. For each of these plugins, you’ll need a YouTube API key.
1. WonderPlugin
WonderPlugin lets you embed a playlist gallery on your website using a YouTube API key. You can also embed YouTube carousels.
2. VideographyWP
VideographyWP is a handy plugin that allows you to replace featured images with featured videos. After you input a YouTube API key into the plugin’s settings, the plugin retrieves the video for you without you needing to code it into the theme or page.
3. Automatic YouTube Gallery
Automatic YouTube Gallery is as automatic as it sounds. To create a video gallery on your WP website, simply input the name of the channel, user, search term, or playlist into the plugin’s settings. You’ll need a YouTube API key for this plugin to automatically retrieve the data.
4. WP YouTube Lite
WP YouTube Lite allows you to embed videos on your site without slowing down your page speed. Using the YouTube API, you can load YouTube videos into a much lighter video player that will keep your page’s loading time fast.
5. Feed Them Social
The Feed Them Social plugin allows you to create and embed social media feeds on your website. It interfaces with the YouTube API to retrieve all of YouTube’s data and create a custom feed. To activate a YouTube feed, you’ll navigate to the YouTube Options page on your plugin settings and enter your API key.
YouTube API FAQs
Still have questions about using the YouTube API? I have answers below.
Why is my API key not working?
Common reasons:
- The API isn’t enabled for your project.
- You’ve hit your quota.
- You’re calling an endpoint that requires OAuth (not just an API key).
- Your API key is restricted improperly.
Is the YouTube API free?
The YouTube API is free if you don’t exceed your daily API request quota. Each request costs a predetermined number of points. You get 10,000 points per day.
How much does the YouTube API cost?
The charge for accessing the YouTube data API is based on quota usage. For each project, you’re given 10,000 free points per day, and all requests cost at least one point.
You can estimate your quota costs using the Quota Calculator, and if you need more queries, you can apply for higher quotas. The pricing may not remain the same.
Use the YouTube API to grow better.
With access to the millions of videos that other people have uploaded, YouTube can help you expand your business and relieve the burden of having to make your own videos. You can pick the video that best fits your objectives.
The YouTube API provides strong tools to improve your video strategy, regardless of your role as a developer, marketer, or company owner.
Consistently creating high-quality, original content can be difficult to incorporate into most marketing strategies. But with access to the YouTube data API, you can take the second-best route to using YouTube for marketing: sharing video on your website.
Engage with your videos rather than merely hosting them. To get smarter, quicker, and better, use the YouTube API.

Free Ebook: How to Use an API
Everything you need to know about the history and use of APIs.
- A History of APIs
- Using APIs
- Understanding API Documentation
- And more!
Download Free
All fields are required.
