1

When making a GET request to the API for GoogleDevelopers channel, I'm getting the following result as expected.

Request: https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=GoogleDevelopers&key=MY_API_KEY

Response:

{
    "kind": "youtube#channelListResponse",
    "etag": "w0k6RzPUxkrdtxJxL2f_V-wMmtE",
    "pageInfo": {
        "totalResults": 1,
        "resultsPerPage": 5
    },
    "items": [
        {
            "kind": "youtube#channel",
            "etag": "P81a-u1XylztNDFIIotdR2fpRn8",
            "id": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
            "contentDetails": {
                "relatedPlaylists": {
                    "likes": "",
                    "favorites": "",
                    "uploads": "UU_x5XG1OV2P6uZZ5FSM9Ttw"
                }
            }
        }
    ]
}

When making the request to my own Youtube Channel, Im just getting the following response.

Request: https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=JOSCHLI1304&key=MY_API_KEY

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

The items Array is missing...

I have no idea why this API Call works for all other channels, but not for my Channel?

I hope somebody can help me out.

Thanks

Ken White
  • 123,280
  • 14
  • 225
  • 444

1 Answers1

2

That happens because JOSCHLI1304 is not the user name of any YouTube channel:

$ python3 youtube-search.py --user-name JOSCHLI1304
youtube-search.py: error: user name "JOSCHLI1304": no associated channel found

$ python3 youtube-search.py --custom-url JOSCHLI1304
youtube-search.py: error: custom URL "JOSCHLI1304": no associated channel found

$ python3 youtube-search.py --search-term JOSCHLI1304 --type channel
UCtwQthkBopRVzS5NrneQ8ZQ: JOSCHLI1304

$ python3 youtube-search.py --channel-url UCtwQthkBopRVzS5NrneQ8ZQ
joschli1304svideosundtutorials

The third command above (the one containing the command line argument --search-term) shows that there's a channel -- UCtwQthkBopRVzS5NrneQ8ZQ -- that has its title set to JOSCHLI1304.

Furthermore, the fourth command above shows that the channel of which ID is UCtwQthkBopRVzS5NrneQ8ZQ has it's custom URL set to something that's close to the name you're looking for: joschli1304svideosundtutorials.

Appendix

The script youtube-search.py used above is a public (MIT licensed) Python 3 program (that I developed) implementing an algorithm that searches for custom URLs and also is querying the API for user names.

Note that youtube-search.py requires a valid API key to be passed to it as argument of the command line option --app-key or, otherwise, passed on as the environment variable YOUTUBE_DATA_APP_KEY. (Use the command line option --help for brief helping info.)

stvar
  • 6,551
  • 2
  • 13
  • 28
  • Thanks for your answer. But can you tell me, what my Username is? What do I have to input in the URL? – joschli1304 Apr 05 '21 at 17:54
  • @joschli1304: User names are a *legacy* feature of the API v3: not every channel has one attached and no channel is required to have one attached. (See [this official statement](https://issuetracker.google.com/issues/35173130#comment5) from Google staff from 2013-07-11.) Your channel -- `UCtwQthkBopRVzS5NrneQ8ZQ` -- does not have a user name as per the API response (no `items` array). – stvar Apr 05 '21 at 19:22
  • @joschli1304: For what concerns your second question -- *What do I have to input in the URL?* --, please be more specific: to what URL are you referring? If you refer to the argument of the parameter [`forUsername`](https://developers.google.com/youtube/v3/docs/channels/list#forUsername), then, again, you may issue that API endpoint with (really) *any* value of that argument: the API will never return an response referring to your channel (since this channel *has no user name attached*). – stvar Apr 05 '21 at 19:29
  • Thank. Is it possible to set a user name to a YouTube channel? – joschli1304 Apr 06 '21 at 08:34
  • Unfortunately, @joschli1304, currently there's no way one could attach a user name to his/her channel. I'd warmly recommend you to handle your channel within your app (any channel for that matter) based on IDs: these are real unique identifiers; they are here for quite a long time and will stay as such for the long run. – stvar Apr 06 '21 at 11:06