5

I'm trying to get channels info with ChannelsList. This endpoint has a parameter the name is: forUsername but it does not work for this page: https://www.youtube.com/c/FolkartTr

This is my query and it returns empty data:

https://i.sstatic.net/gd86q.png

Somehow, I got this channelID in the page source and its: "channelId":"[UCnS--2e1yzQCm5r4ClrMJBg]". When I try to query with this ID it's okay and returns with correct data.

https://i.sstatic.net/QjCsK.png

and this is its payload: http://jsonblob.com/941253671862419456

How will I be able to reach this channel info using a username? I got a few links with usernames and I want to get their info with their username. I don't have any chance to get their channelID's for all.

Thanks for your help.

4 Answers 4

5

If I understood correctly, your problem is that you can't do anything from such a c/ channel id with the Channels: list of the YouTube Data API v3. If you're just looking for the channel id linked to this id then because as YouTube Data API v3 doesn't work for this, I would recommend you to use my open-source YouTube operational API, indeed by requesting https://yt.lemnoslife.com/channels?cId=FolkartTr you'll receive a JSON with id equals to the channel id linked to the provided cId value.

Sign up to request clarification or add additional context in comments.

Comments

2

YouTube released a revision on 31st January 2024 to add a forHandle parameter in the channel list API that does exactly what OP asks.

You can call the channel list API with forHandle to get the channel ID and the upload playlist for that user/handle that you can subsequently use to fetch the videos.

GET https://www.googleapis.com/youtube/v3/channels

Query parameters:

forHandle=FolkartTr OR @FolkartTr OR %40FolkartTr (this allows the '@' sign as well as URL encoding of it)
key=<your API key>
part=contentDetails

The response will be similar to this:

{
    "kind": "youtube#channelListResponse",
    "etag": "uIHxDmri3hu046xPYA5kt7Zh_Xs",
    "pageInfo": {
        "totalResults": 1,
        "resultsPerPage": 5
    },
    "items": [
        {
            "kind": "youtube#channel",
            "etag": "bCWfzhSw3uxD6RCZ7IkkgaPF5Hs",
            "id": "UCnS--2e1yzQCm5r4ClrMJBg",
            "contentDetails": {
                "relatedPlaylists": {
                    "likes": "",
                    "uploads": "UUnS--2e1yzQCm5r4ClrMJBg"
                }
            }
        }
    ]
}

From the documentation:

The forHandle parameter specifies a YouTube handle, thereby requesting the channel associated with that handle. The parameter value can be prepended with an @ symbol. For example, to retrieve the resource for the "Google for Developers" channel, set the forHandle parameter value to either GoogleDevelopers or @GoogleDevelopers.

You can subscribe and/or keep an eye here for the API updates:

https://developers.google.com/static/youtube/v3/feeds/data-api-revision-history.xml

Comments

1

Notice that the channel title and the channel customUrl might be different.

In your example - http://jsonblob.com/941253671862419456 -, the channel title is Folkart, but its customUrl - which is the value you get when view on YouTube - is: folkarttr.

Note the difference in both case-sensitive and additional letters.

For these reasons, you should not based your channel search by name, but, rather, by its channel_id.

If you really need to search by userName, the answer from Benjamin Loison can solve your requirement.

See if you can find a ticket on Issue Tracker or post your issue there too. Then, you might get some official answer.

Comments

1

I found an answer on their issue tracker. The forUsername is for an older username system that is no longer in use and is not the new @username or /c/username system. A search request might do the job instead.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.