Seong Lee
Seong Lee

Reputation: 10520

Youtube API - no channel name

I'm trying to retrieve my Youtube channel name using Youtube data API but I'm getting empty item. I have a channel in my Youtube account so it should return one.

These are the query properties I entered -

part:'contentDetails', forUsername: 'Seong+Lee',

to get the following response from their interactive documentation page.

200 OK
- SHOW HEADERS -
{
 "kind": "youtube#channelListResponse",
 "etag": "\"fpJ9onbY0Rl_LqYLG6rOCJ9h9N8/C3QZ-VsykvkpW2zCm7VjGBCayqc\"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 5
 },
 "items": [
 ]
}

In my app I get the same response so I figured there is no issue with my request code. Why can't I get the channel name?

Upvotes: 5

Views: 1448

Answers (3)

Philip Butler
Philip Butler

Reputation: 489

If you are authenticate your app using google's oauth2 then you can include the mine parameter and set it to true in your request to recieve your own channel. Check the common use cases here for more info.

See also this answer

Upvotes: 0

Janyk
Janyk

Reputation: 571

As it looks like your channel does not have a legacy custom URL, you are not able to use the forUsername parameter. This parameter only works with /user/{channelname} URL's. In this case, it means you have to work with your channel ID which you can find over here.

In order to get the display name of your channel, you need the snippet part instead of the contentDetails.

https://www.googleapis.com/youtube/v3/channels?part=snippet&id=UCwy6X3JB24VTsDFqMwdO5Jg&key={YOUR_API_KEY}

You will then receive display name of the channel as snippet.title

{
    kind: "youtube#channelListResponse",
    etag: ""0KG1mRN7bm3nResDPKHQZpg5-do/L4uU6pmZJ1wQKdGUwnnigYpSEVo"",
    pageInfo: {
        totalResults: 1,
        resultsPerPage: 1
    },
    items: [
    {
        kind: "youtube#channel",
        etag: ""0KG1mRN7bm3nResDPKHQZpg5-do/GKVRHf7CLp-mUGFTR_3wbc5Lq-k"",
        id: "UCwy6X3JB24VTsDFqMwdO5Jg",
        snippet: {
            title: "Seong Lee",

...

Upvotes: 4

Daniel Zhang
Daniel Zhang

Reputation: 5858

You can retrieve your contentDetails by using your channel ID.

GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UCwy6X3JB24VTsDFqMwdO5Jg&key={YOUR_API_KEY}

Your username is apparently not valid.

Upvotes: 5

Related Questions