Skip to content

How to Restrict A YouTube API Key For my Website

For our purposes, we will restrict it for a dummy website.

I will make a separate blog on restricting a key for android or iOS.

Simply choose the ‘HTTP referrers’ option as shown below:

This will give you information on how to restrict your API key on your dummy website. If you are wanting to restrict the key on a subdomain, you will have to follow the instructions from Google.
For our purposes, we will be doing it for a normal website address such as:

Now click on the ‘Add An Item’ option under Website restrictions.
In the ‘Referrer’ box, place your website address as shown. Make sure to place it as shown when your site does not have any subdomains that the API key needs usage on.

Then click done. You can add other websites to the ‘Referrer’ box too. Make sure to follow the right website address format when you do choose that option.

Now click the ‘Restrict key’ option. We are going to link up the API restriction to our website.
Click the ‘Select APIs’ drop-down and choose the ‘YouTube API’ which would be at the bottom (the last one since we enabled it recently).
Click ‘OK’ and it will show the following:

Then click on ‘Save’ and you will be redirected to either adding another API key or you can click on the ‘Credential’ menu link on the left and it will take you to your API key info.

And there you have it. You can now use your API key on your website safely.


  1. Make sure you have created the API Key.
  2. Choose Restrict Key.
  3. Restrict the key according to your website domain name and any possible subdomains (if needed).
  4. Follow the exact process from Google’s instructions on restricting your website
  5. Ensure that the restricted key works on your website after adding the restriction.


If you are having trouble with your API key setup, please remember that some API’s require a billing account for it to work properly.

However, if this helped you, let me know in the comments below.

Stay awesome!

Join to get updates

Similar Posts

What is a Landing Page?

Many times a web-developer or a business is faced with making the decision to create a landing page. But what is it and why create one?

Read More »
API Link chain

What Is An API

Have you ever wondered what API really means and what it’s supposed to do? Find out in this post.

Read More »
No more posts to show