YouTube requires you to have an API key for retrieving video information outside of the YouTube website. This step-by-step tutorial will walk you through the somewhat cumbersome process of getting an API key. But before we start, make sure that you have a Google account.
Step 1: Create a Project
Log in to https://console.developers.google.com/apis/dashboard with your Google account. First, you need to create a project. In the dashboard, click the button “Create”.
Choose a project name and click the “Create” button.
Step 2: Enable the YouTube API
Next, you need to enable the YouTube API. Switch to the library section in the left sidebar or hit the “Enable APIs and services” button at the top of the screen.
On the next screen, scroll down until you see the “YouTube Data API v3” tile and click on it.
Next, click on the “Enable” button.
Step 3: Add Credentials
Don’t give up, we are halfway through. Click the “Create credentials” button.
Instead of going through the next form, just click on the link “API key”.
Next, choose a name for your API key. For now, leave the “Application restrictions” to “None” and hit the “Create” button. If you later decide to use the key for a real-world application, you should definitely restrict it.
Step 4: Enjoy the API Key
Finally, Google provides you with a shiny new API key.