Getting usage of channel point

I’ve got a led strip in my room, and I’ve made a command so my viewers can change the color of it.
But I would like to use channel point to do it, so I can prevent spamming etc…

Is there a way to get the usage of the channel points?

I’m using NodeJS

Use EventSub to recieve notifications in real time

Eventsub, is a transport agnostic notification system, which currently only offers a webhook transport (so your server would need to be web accessable + a Real SSL Cert)

Heres a nodeJS example on how to setup the basics

Alternatively you can repeat poll the Get Custom Reward Redemption API.
You’ll also need to use this to catch missed rewards between “server restarts” on your side

For both you’ll need to use the Update Redemption Status endpoint to mark redeems as processed.

Imma try this, thanks !

When I try to do this, I got an error :

  let getRewards = new XMLHttpRequest();

  getRewards.open("GET", `https://api.twitch.tv/helix/channel_points/custom_rewards?broadcaster_id=${broadcaster_id}`, true);
  getRewards.setRequestHeader('Client-ID', `myid`);
  getRewards.setRequestHeader('Authorization', `Bearer myoauth`)
  getRewards.send();
  
  getRewards.addEventListener('load', function() {
    const rewards = JSON.parse(getRewards.response);
    console.log(rewards)
  })

{
error: ‘Unauthorized’,
status: 401,
message: ‘Missing User OAUTH Token’
}

{
  error: 'Unauthorized',
  status: 401,
  message: 'Missing User OAUTH Token'
}

I just refreshed my OAuth, and it still doesn’t work

You did generate a user token with the relevant scopes and not used an app access/client creds token?

The error suggests you used a App Access Token

rather than

You can check the token type by calling the validate endpoint

Which’ll return the userID and any scopes on that token (if any)

An initial user oAuth token will require opening a webpage to grant link permission between the user and the ClientID

I’ve generated it with the twitch api cli, by using twitch token, is there a way to use this command with scopes in the args?

This call will generate an app access token now a user token

twitch token -u

Will request a user token

And

twitch token -u -s “channel:read:redemptions channel:manage:redemptions”

Should generate a User Token with the required scopes

Heres the twitch cli docs on token gen

The only problem I got now is that it send me to my localhost, which seems to not work

IMPORTANT

To use user tokens, you will need to set up your Client ID provided during configure with a redirect URI of http://localhost:3000. App access tokens will work without this step. You can configure that on the Twitch Developer console.

Noted the linked CLI guide

Oh yeah my bad, thanks for the quick answers, this works
Thanks a lot !

Seems like I got a new error, when I do the full request to get the reward

https://api.twitch.tv/helix/channel_points/custom_rewards/redemptions?broadcaster_id=${broadcaster_id}&reward_id=${reward_id}&status=FULFILLED`

I got this error

  error: 'Forbidden',
  status: 403,
  message: 'custom reward was created by a different client_id or channel points are not available for the broadcaster'
}

You you can only access/manage rewards created by the same clientID.

EventSub will broadcast all the reward redeems, but of course you can’t really do a catch up for redeems the clientID doesn’t own.

But the API will only let you get the reward redeems for rewards created by the clientID

This prevents two clientID’s messing with each others redemptions.

So you’d probably to delete the dashboard created rewards and use the API to create the reward. After it has been created via the API you can modify any part of the reward via the dashboard.