YouTube Data API

Hi, I would like to write a script, that get the channel_id from a channel url.
For this, I was trying to use the username:
https://www.youtube.com/@t3dotgg -> t3dotgg
https://youtube.googleapis.com/youtube/v3/channels?part=id&forUsername=t3dotgg&key=[YOUR_API_KEY]
but I get this response:

200
{
  "kind": "youtube#channelListResponse",
  "etag": "RuuXzTIr0OoDqI4S0RU6n4FqKEM",
  "pageInfo": {
    "totalResults": 0,
    "resultsPerPage": 5
  }
}


but if I use a different username like ludwig it works:

200
{
  "kind": "youtube#channelListResponse",
  "etag": "TAcFH8yqbppZUNBGKLFmQiISJUg",
  "pageInfo": {
    "totalResults": 1,
    "resultsPerPage": 5
  },
  "items": [
    {
      "kind": "youtube#channel",
      "etag": "uyh-UPnVJ-53EQBU_y-FVSAZ7xw",
      "id": "UCZL4arowpEICMkWEPyx_vaQ"
    }
  ]
}
Was this page helpful?