πΉ Step 1 β Sign in to Google
Sign in with the Gmail or Google account that will own your API key and Cloud project.
πΉ Step 2 β Open Google Cloud Console
Visit console.cloud.google.com. Accept the Terms of Service and choose your country when prompted.
πΉ Step 3 β Create or Select a Project
Use the top project selector β New Project. Name it (for example BT Media) β click Create, then select it.
πΉ Step 4 β Enable YouTube Data API v3
Go to APIs & Services β Library. Find YouTube Data API v3 and click Enable.
πΉ Step 5 β Create Your API Key
Open APIs & Services β Credentials β Create credentials β API key. Copy the key displayed on screen.
πΉ Step 6 β Secure Your API Key
Click your key name β Key restrictions and set:
- Application restrictions: limit to HTTP referrers (your domains) or Android/iOS apps.
- API restrictions: allow only YouTube Data API v3.
Save changes. Rotate the key if it ever becomes public.
πΉ Step 7 β Test Your Key
Verify your API key works with curl or JavaScript:
# cURL example
curl -G "https://www.googleapis.com/youtube/v3/search" \
--data-urlencode "part=snippet" \
--data-urlencode "q=music" \
--data-urlencode "type=video" \
--data-urlencode "maxResults=3" \
--data-urlencode "key=YOUR_API_KEY"
// JavaScript example
async function testYouTube(){
const q=new URLSearchParams({part:'snippet',q:'music',type:'video',maxResults:'3',key:'YOUR_API_KEY'});
const r=await fetch('https://www.googleapis.com/youtube/v3/search?'+q);
console.log(await r.json());
}
testYouTube();
If you see items[] in the JSON response, your key works.
Errors mean the API isnβt enabled or restrictions are too strict.
