Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 484
Seong Lee Avatar asked Oct 23 '15 03:10

Seong Lee


People also ask

Can you still use YouTube API v2?

What should I do? You can continue using the v2 API for comments and uploading video captions for now, and we'll be adding this functionality into the v3 API soon. While we don't have specific dates yet, we will release that functionality so that developers have as much time as possible to migrate to v3.

Did YouTube change its API?

July 12, 2022The YouTube API Services Terms of Service has been updated. Please see the YouTube API Services Terms of Service - Revision History for more information.

What is snippet in YouTube API?

The snippet object contains basic details about the video, such as its title, description, and category. The date and time that the video was published. Note that this time might be different than the time that the video was uploaded.


2 Answers

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.

like image 142
Daniel Zhang Avatar answered Oct 02 '22 09:10

Daniel Zhang


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",

...
like image 28
Janyk Avatar answered Oct 02 '22 11:10

Janyk