Spotify is sorted. Now we go to YouTube's side.

The goal of this chapter is simple: get a YouTube API key and find the ID of the YouTube playlist we want to mirror. Two things. That's it.


A Quick Word on the YouTube API

YouTube is owned by Google, so the YouTube API lives inside Google's developer platform. Don't let that intimidate you — you're logging in with the same Google account you use for Gmail or Google Drive. Nothing new to create.

The YouTube Data API has a free tier that gives you 10,000 units per day. Reading a playlist of 100 songs costs about 200 units. So unless you're syncing 50 playlists a day, you'll never hit the limit. We're well within free territory.


Step 1: Go to Google Cloud Console

Open your browser and go to console.cloud.google.com. Log in with your Google account.

If this is your first time here, Google will ask you to agree to their Terms of Service. Accept and continue.


Step 2: Create a Project

Google organises everything into "projects." Think of a project as a folder for your app. We need to create one.

At the very top of the page, you'll see a dropdown that probably says "Select a project." Click it, then click New Project in the top right of the popup.

Give it a name — something like youtube-to-spotify works fine. Leave the organisation field as is and click Create.

Google will take a few seconds to create it. Once done, make sure your new project is selected in that top dropdown before continuing.


Step 3: Enable the YouTube Data API

With your project selected, use the search bar at the top of the page and type "YouTube Data API v3". Click on the result that says exactly that.

You'll land on an API overview page. Click the blue Enable button.

After a moment, the page will refresh and show you the API is now enabled. You should see a dashboard with some quota charts — all zeros for now, which is correct.


Step 4: Create an API Key

Now we need an actual key. In the left sidebar, click Credentials. Then click + Create Credentials at the top and choose API key.

Google will generate a key immediately and show it to you in a popup. It looks something like this:

AIzaSyD3x8Kv2mNpQr7wLtYhJfUcX9vBsE1oRk

Enter fullscreen mode Exit fullscreen mode

Copy it. This is your API_KEY.

Restrict the Key (Recommended)

After copying it, click Edit API key in that same popup. Under "API restrictions," select Restrict key, then choose YouTube Data API v3 from the dropdown. Click Save.

This means your key only works for YouTube — if someone somehow got hold of it, they couldn't use it anywhere else. It takes 30 seconds and it's good practice.


Step 5: Find Your YouTube Playlist ID

Go to youtube.com and open the playlist you want to mirror on Spotify.

Look at the URL in your browser's address bar. It will look something like this:

https://www.youtube.com/playlist?list=PLGBuKfnErZlAkaUUy57-mR97f8SBgMNHh

Enter fullscreen mode Exit fullscreen mode

The part after list= is your Playlist ID. In this example, that's PLGBuKfnErZlAkaUUy57-mR97f8SBgMNHh. That's the 70's Music Hits Playlist - Best of 70s Music Classics by Redlist Decades — the one we'll be using throughout this series.

Copy that. That's all you need from YouTube.

One thing to note: the playlist needs to be public or unlisted for the API to read it. If it's set to private, the script won't be able to see it. You can change the visibility in YouTube Studio under your playlist settings.


What You Have Now

Between Chapters 2 and 3, you've collected everything the script needs to run. Here's the full list:

Variable What it is Where you got it
CLIENT_ID Spotify app ID Spotify Developer Dashboard
CLIENT_SECRET Spotify app secret Spotify Developer Dashboard
REFRESH_TOKEN Long-lived Spotify login token curl/PowerShell command in Chapter 2
SPOTIFY_PLAYLIST_ID Your Spotify playlist to write to Spotify share link
API_KEY YouTube Data API key Google Cloud Console
YOUTUBE_PLAYLIST_ID PLGBuKfnErZlAkaUUy57-mR97f8SBgMNHh YouTube playlist URL

Six values. That's the whole configuration. No more accounts, no more dashboards. From Chapter 4 onward, it's all code.


What's Next?

In Chapter 4, we write the script. We'll walk through each file — what it does, how it works, and why — in plain English. No assumed knowledge.

See you there.