Is it possible to get user_ID without login?

I’m trying to get the user_ID of a famous streamer on twitch cause I’m creating a bot on Telegram that should notify to the group chat when his streaming goes live. I’ve created an app from glass.twitch.tv and now I’m wondering what to do.

I’ve tried to use a chrome extension called Twitch Username and User ID Translator that gave me an user_ID, but then using the query founded on the official twitch dev docs.

https://api.twitch.tv/helix/streams?user_id=5678

but doing this the loaded page said

{"error":"Unauthorized","status":401,"message":"Must provide a valid Client-ID or OAuth token"}

I’ve tried more times: the first time I didn’t insert mine Client_ID into the Header, then the second one I’ve filled the header sain Client_ID = myclientid but both times I’ve received that error.

See

For an example. You are not sending a header correctly, and can’t tell you how to fix that since you didn’t provide what language you are using or sample code.

See also

curl -H 'Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2' \
-X GET 'https://api.twitch.tv/helix/streams?first=20'

I’m currently using a website called API Tester to apply these request to the twitch servers, that’s why I didn’t post any code. Did you understand that I’m doing it without the streamer login infos and also without any information of his twitch account apart of the nome of his channel? Cause I don’t know why but I feel that you didn’t.

Any thoughts?

image
In this picture where you see

`-X GET https://api.twitch.tv/kraken/users?login=dallas,dallasnchains`

what this “dallas,dallasnchains” means? Like if I want to check the xxx user_ID do I have to write xxx instead of dallas,dallasnchains ?

Are you trying to GET for 2 users?

You can’t seperate the users by a coma. they each need to have ‘login=’ or ‘id=’

A request can include a mixture of login names and user ID. If specifying multiple values (any combination of id and/or login values), separate them with ampersands; e.g.,
GET https://api.twitch.tv/helix/users?login=<login name>&id=<user ID>...
GET https://api.twitch.tv/helix/users?id=<user ID>&id=<user ID>...GET https://api.twitch.tv/helix/users?login=<login name>&login=<login name>...

Source: https://dev.twitch.tv/docs/api/reference/#get-users

so instead of
-X GET https://api.twitch.tv/kraken/users?login=dallas,dallasnchains

try this
-X GET https://api.twitch.tv/kraken/users?login=dallas&login=dallasnchains

UPDATE: I was thinking you were using Helix, not Kraken. Going to leave this for a reference in case anyone needs it in the future.

1 Like

Thanks to the replies I finally got the streamer user_ID using this code

-H 'Accept: application/vnd.twitchtv.v5+json' \
-H 'Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2' \
-X GET https://api.twitch.tv/kraken/users?streamer_name

Ok, now I’m wondering which is the correct link to see when he goes on live? Cause I’ve searched into the link that BarryCarlyon has sent (the second one) and there are only ways to get lists of most watched streamer.

So now I’m searching for the request to see when he’s in live.

To get Stream data you need to use the /streams/ endpoint as the /users/ endpoint does not pull stream data.

Change:
https://api.twitch.tv/kraken/users?streamer_name
to:
https://api.twitch.tv/kraken/streams/<channel ID> where = username

According to the Get Stream by User Endpoint

Example Response if the Channel is Live Broadcasting

{
   "stream": {
      "_id": 23932774784,
      "game": "BATMAN - The Telltale Series",
      "viewers": 7254,
      "video_height": 720,
      "average_fps": 60,
      "delay": 0,
      "created_at": "2016-12-14T22:49:56Z",
      "is_playlist": false,
      "preview": {
         "small": "https://static-cdn.jtvnw.net/previews-ttv/live_user_dansgaming-80x45.jpg",
         "medium": "https://static-cdn.jtvnw.net/previews-ttv/live_user_dansgaming-320x180.jpg",
         "large": "https://static-cdn.jtvnw.net/previews-ttv/live_user_dansgaming-640x360.jpg",
         "template": "https://static-cdn.jtvnw.net/previews-ttv/live_user_dansgaming-{width}x{height}.jpg"
      },
      "channel": {
         "mature": false,
         "status": "Dan is Batman? - Telltale's Batman",
         "broadcaster_language": "en",
         "display_name": "DansGaming",
         "game": "BATMAN - The Telltale Series",
         "language": "en",
         "_id": 7236692,
         "name": "dansgaming",
         "created_at": "2009-07-15T03:02:41Z",
         "updated_at": "2016-12-15T01:33:58Z",
         "partner": true,
         "logo": "https://static-cdn.jtvnw.net/jtv_user_pictures/dansgaming-profile_image-76e4a4ab9388bc9c-300x300.png",
         "video_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/dansgaming-channel_offline_image-d3551503c24c08ad-1920x1080.png",
         "profile_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/dansgaming-profile_banner-4c2b8ece8cd010b4-480.jpeg",
         "profile_banner_background_color": null,
         "url": "https://www.twitch.tv/dansgaming",
         "views": 63906830,
         "followers": 538598
      }
   }
}

Example Response if the Channel is Offline

{
   "stream":null
}
1 Like

That’s perfect thanks.

1 Like

I’m glad we could help. Any other questions, just ask! :slightly_smiling_face:

I’m building a script that send the GET request every x minutes, does Twitch have a cooldown time?
What the best range of time to wait between one request and the next one?

I am not aware of the cool down times for the API, However, you should not have any issues hitting the limit. There are projects that hit it up to once every second and still don’t hit the limit.

1 Like

Twitch API has a Rate Limit for the number of Requests you can do in a certain time

Helix:

Kraken:

No more than once per second (honors system, wheatons law applies)

The Streams end point has a 3/5 minute delay to ensure the data is accurate and to have passed thru caching.

You may want to consider webhooks instead of long polling

https://dev.twitch.tv/docs/api/webhooks-guide/

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