Hello,
I am using Pircbot in Java for a chat bot and am having trouble getting a list of current subs for a particular channel. This is how I am currently attempting it. Any advice?
URL subs = new URL(“https://api.twitch.tv/kraken/channels/channel_name/subscriptions/”);
HttpURLConnection conn = (HttpURLConnection) subs.openConnection();
// Set Headers
conn.setRequestProperty(“authorization”, “OAuth -token-”);
conn.setRequestProperty(“accept”, “application/vnd.twitchtv.v5+json”);
conn.setRequestProperty(“client-id”, “client_id”);
Thanks!
Under v5 you should send channel_id not channel_name
URL subs = new URL(“https://api.twitch.tv/kraken/channels/channel_id/subscriptions/”);
I have tried both and neither has worked. Sorry, should have said that.
I get a 401 error code.
A 401 indicates that you don’t have permission to access the requested channel_id’s subscribers. You can check the body response for more information
You need a token with the relevant oAuth scope applied to it
The scope for this subscriber end point is channel_subscriptions
Scopes are noted here: https://dev.twitch.tv/docs/authentication/#scopes
Authentication here: https://dev.twitch.tv/docs/authentication/#getting-tokens
Channel Subscribers here: https://dev.twitch.tv/docs/v5/reference/channels/#get-channel-subscribers
Authentication
Required scope: channel_subscriptions
URL
GET https://api.twitch.tv/kraken/channels/<channel ID>/subscriptions