create an API key for youtube data

How to Get a Google API Key for YouTube Data API

Follow these steps to create a Google API key, which will allow you to use YouTube’s Data API to display videos on your WordPress site.

Step 1: Create a New Project

  1. Click on this link to go directly to the Google Cloud Console:
    Create New Project
  2. In the “New Project” screen, give your project a name (for example: “YouTube WP Feeder”) and click Create.
  • You can leave the Location field as “No Organization” unless you’re part of an organization.

Wait a few seconds for the project to be created. Once it’s ready, a notification will popup – click Select Project to start working in the new project.

Step 2: Enable YouTube Data API v3

  • After selecting your project, you’ll be taken to the Project Dashboard.
  • From the dashboard, click on Go to API Overview (you’ll find this on the main dashboard).

On the API Overview page, look at the left-hand menu and click on Library.

Search for YouTube Data API v3:

In the API Library, use the search bar and type YouTube Data API v3.

Select it from the search results.

search for Youtube data API v3

Enable YouTube Data API v3:

Click the Enable button to activate the API for your project.

enable youtube data API v3

Step 3: Create Credentials for your Google API Key

  • After enabling the API, you will be redirected to the YouTube Data API v3 dashboard.
  • Click on Create Credentials at the top of the page.
  • Then choose API key from the drop down menu.
create an api key for Youtube data
  • Google will generate an API key for you. Copy the API key and store it in a safe place (you’ll use this API key when configuring your WordPress plugin).
create an API key to access Youube data
  • Click Close to finish.

Step 4: Restrict the API Key (Optional but Recommended)

edit API Key to access restrictions section
  1. To avoid misuse of your API key, click on API & Services > Credentials in the left-hand menu.
  2. Find the API key you just created in the list, and click the three dots and choose Edit API key on the far right of the key.
  3. Under Key restrictions, you can specify restrictions:
set application restrictions for your API key
  • HTTP referrers (web sites): Use this option to restrict the API key to be used only on specific websites (e.g., your website).
  • IP addresses: Restrict the key to specific IP addresses.
  1. After making your restrictions, click Save.

Step 5: Use the API Key in Your Plugin

Now that you have the API key, you can use it in your WordPress plugin. For example, when using the YouTube WP Feeder plugin, add the API key to the shortcode like this:

[youtube_feed channel_id="YOUR_CHANNEL_ID" api_key="YOUR_API_KEY" max_results="6"]

That’s it! You now have a fully functional API key that you can use with your YouTube Data API to fetch videos and display them on your WordPress site.


Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *