Get profil picture of viewers looking my stream

hello,
I new on twitch, I would like stream a animation as I did on tiktok,
but my english is bad and I not understand the doc :blush:
For my stream, I need:

  1. detect when viewers send message (it ok, easy to do with tmi.js) and detect when they send bits (is it detectable with tmi.js ?)

  2. found the profil picture of the viewer that was detected, to display it

How can I do ?

For now, I try to get picture of user name sardoche (for try) but it not work , return bad request, invalid)

axios.request({
  url: 'https://api.twitch.tv/helix/users?id=sardoche',
  method: 'get',
  headers: {
    'Client-Id': '8395wu945kt4444go8egina9mijgpr',
    'Authorization': 'Bearer REMOVED'
  }
}).then(console.log).catch(console.error)

the client id is from my console app,
the bearer is token that I generated with :

axios.post('https://id.twitch.tv/oauth2/token', {
    client_id: '8395wu945kt4444go8egina9mijgpr',
    client_secret: 'REMOVED',
    grant_type: 'client_credentials'
}).then(console.log).catch(console.error);

That not the good way it is ?
thank for help :slight_smile:

sardoche is not an β€œid” it’s a login

So as per Reference | Twitch Developers

You want https://api.twitch.tv/helix/users?login=sardoche

If you read the error message not just the code you’ll get information about your error.

You should also rotate your client secret as you just leaked it to the world.

1 Like

Thank you BarryCarlyon
It work now

axios.request({
  url: 'https://api.twitch.tv/helix/users?login=sardoche&login=teuf',
  method: 'get',
  headers: {
    'Client-Id': '<secret>',
    'Authorization': 'Bearer <secret>'
  }
}).then(function (data) {
  console.log(data.data.data[0].profile_image_url, data.data.data[1].profile_image_url);
});

get result:
https://static-cdn.jtvnw.net/jtv_user_pictures/2b1b9e13-5b9f-41ee-b375-54d3c6491bb2-profile_image-300x300.png https://static-cdn.jtvnw.net/jtv_user_pictures/3ebda7f8-ab67-4197-841a-9b8d58595c1d-profile_image-300x300.png

Do you have suggestion to detect when viewers send bits ?

if there is a IRCv3 tag present in the message of bits

1 Like

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