Webhook subs json response empty

Hey guys this is my first API and this should be simple I’m just trying to get the total amount of subscriptions in a channel, but I’m getting this response from the request: {“total”:0,“data”:[],“pagination”:{}}

this is my code:

$OAuth_temp = self::GetTwitchToken($client_id, $tw_oauth);

	 $channelsApi = 'https://api.twitch.tv/helix/webhooks/subscriptions';
	 $channelName = $tw_channel_username;
	 $clientId = $client_id;
	 $ch = curl_init();
	 
	 curl_setopt_array($ch, array(
	    CURLOPT_HTTPHEADER => array(
	       'Authorization: Bearer ' . $OAuth_temp['access_token']		       
	    ),
	    CURLOPT_RETURNTRANSFER => true,
	    CURLOPT_URL => $channelsApi
	 ));
	 
	 $response = curl_exec($ch);
	 curl_close($ch);

	// $response = json_decode($response, true);
	 return $response;

any thoughts ?

The reason you’re getting an empty data array back is because the endpoint you’re using, Get Webhook Subscriptions, has nothing to do with getting the number of subscriptions to a channel. That endpoint is for listing the webhook subscriptions your app has, and as you’re getting an empty data array that means your app isn’t subscribed to any topics.

if you want to get the total amount of users subscribed to a channel you need to use the Get Broadcaster Subscriptions endpoint which you will need an access token with the channel:read:subscriptions scope that has been granted to you by the channel you’re attempting to access data for.

1 Like

Thanks Dist I just figured that out this morning!

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