| If you have a YouTube channel URL like: https://www.youtube.com/@%EC%B6%94%EC%B6%94%EB%A3%A8%EC%A3%BC%EC%B6%98
…and you need the Channel ID (the one that starts with UC...), YouTube doesn’t include it directly in handle-based URLs. The easiest and most reliable way is to use the YouTube Data API v3. Step 1: Get a YouTube Data API KeyThe YouTube Data API is free for up to 10,000 requests per day, which is more than enough for most projects. - Go to Google Cloud Console
https://console.cloud.google.com/ - Create a Project
- Click the project dropdown → New Project
- Name it (e.g.,
YouTubeAPIProject) → Create
- Enable YouTube Data API v3
- Go to the API page
- Click Enable
- Create an API Key
- In the left menu: APIs & Services → Credentials
- Click Create Credentials → API key
- Copy the key shown
- (Optional) Restrict the Key
- Click your new API key
- Under API Restrictions, choose YouTube Data API v3
- Under Application Restrictions, limit by IP or HTTP referrer
Step 2: PHP Script to Get Channel ID from a Handle<?php function getYouTubeChannelIdFromHandle($handle, $apiKey) {
$url = "https://www.googleapis.com/youtube/v3/channels?part=id&forHandle=" . urlencode($handle) . "&key=" . $apiKey;
$json = file_get_contents($url);
$data = json_decode($json, true);
return $data['items'][0]['id'] ?? null;
}
$apiKey = "YOUR_API_KEY"; // Replace with your real key $handle = "@추추루주춘"; // Your YouTube handle
$channelId = getYouTubeChannelIdFromHandle($handle, $apiKey);
echo "Channel ID: " . $channelId;
Step 3: Test Your KeyVisit this URL in your browser (replace YOUR_API_KEY): https://www.googleapis.com/youtube/v3/channels?part=id&forHandle=@추추루주춘&key=YOUR_API_KEY
If successful, you’ll get: {
"items": [
{
"id": "UCxxxxxxxxxxxxxxxx"
}
]
}
💡 Notes- API usage is free within the quota (10,000 lookups/day).
- No scraping is required, so this method is stable.
- Works with handles, custom URLs, and direct channel URLs.
|