Get channel_id by user_id or display_name API V5

Hey guys,

I tried to get streams information and it requires the channel ID. I have this one when I ask a user to be authenticated using the oauth2 process / token etc.

But in case I don’t have this user coming, I would like to retrieve some public information.
Here is the stream route : GET https://api.twitch.tv/kraken/streams/

Someone already asked about it here : Get channel_id by user_id or display_name but the response didn’t work at all, I can’t use the displayed channel name or username (even if it looks the same) to get the information. I even tried to get channel public information using the displayed_name, same following error:

(trying to get info with my channel)
GET https://api.twitch.tv/kraken/channels/elynia_gaming
{
“error”: “Bad Request”,
“status”: 400,
“message”: “Channel identifier “elynia_gaming” is in an invalid format”
}

Any idea ? :slight_smile:

Thanks !

Hey,

For API 5 passing a username doesn’t work like that anymore I don’t believe.
For it to be passed in that form it aught to work as either :
https://api.twitch.tv/kraken/channels/<userID>
https://api.twitch.tv/kraken/users?login=<channelName>
The “Invalid format” response is due to it not being a userID.
Your use of “https://api.twitch.tv/kraken/channels/elynia_gaming” does still work for v3 though.

(While I’m at it, for future use by either yourself or someone who comes here at a later point, I might aswell say that for the v5 use, you can also get multiple channels returned using
https://api.twitch.tv/kraken/users?login=<channelName>,<channelName2>,<channelName3> … etc etc)

Hope I’ve been of some help!

edit: Fixed link terms not being visible
edit2+3: Accidentally put channel?channels instead of users?login … twice

2 Likes

Thanks Scott,

It works indeed ! Thanks

And another way I just found,
I have to retrieve an App access tokens beside of my User access token and then request the channel to get the ID. It’s longer than your answer but maybe having the right (token) will give me more ressources ? Don’t know yet :slight_smile:

The app access tokens are mainly relevant for the new Helix API, as with a client id only you’re limited to 30 requests a minute where as if you use an OAuth token you can make 120 requests per minute. The app access token is just a way to have an OAuth token to use for endpoints that require no authentication.

1 Like

Thank you for the information :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.