Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Twitch API class

Updated for OAuth usage!

Feature packed, easy to use PHP class for the latest Twitch API.

You will need your free Twitch client id to use, see here to obtain.

To get your authorization code see here.

This class will automatically refresh access token once it expires!


  • Get top streams
  • Get top streams for game
  • Get popular games
  • Get details for username
  • Get user id for username
  • Get users emotes
  • Get emote image
  • Get chat for a VOD
  • Check if user is live
  • Get users streaming game
  • Get users streaming title
  • Get users streaming id
  • Get streaming thumbnail
  • Get users view count
  • Get users streaming description
  • Get users stream start time
  • Get users stream tags
  • Get clips for game
  • Get users clips
  • Get game name for game id
  • Get game artwork for game id


Fetch with composer:

composer require corbpie/twitch-api-class

To use:


use Corbpie\TwitchApiClass\twitchWrapper;

$call = new twitchWrapper();

Add your Twitch client id and client secret into src/twitchWrapper.php (lines 7-8)

Add your redirect URI info (line 10)

Change the token filename constant, however keep it as a .txt extension (line 11)

Access code can be obtained with

echo $call->accessCodeUrl();

Upon going to the link You will find the access code in the URL:



Get current top (view count) streams array


Get current top (view count) streams for a game array


Get top (view count) streamer for a game string

echo $call->getTopStreamerForGame();

Get viewer count for the top stream for a game string

echo $call->getTopViewersForGame();

Get top games array

(Good way to get gameid's)


Get details for username array


Get user id for username string

$user_id = $call->idForUser();

Get emotes for username array


Get image for emote id string


Get chat for VOD array

$call->chatForVod($vod_id, $offset);

Get users stream details (If live) array


Check if a user is live and streaming boolean

$call->userIsLive();//true for live | false for not live

If user is streaming:

Get game id string


Get viewer count string


Get stream title string


Get stream id string


Get stream start time string


Get stream thumbnail string


Get stream thumbnail array


Get top clips for game id array


Get users top clips array


Get users videos (most recent first) array


Get users videos for game id array

$call->getUserVideosForGame($user, $game_id);

Get game data for game id array


Get game name string

$game_name = $call->gameName();

Get game artwork string

$game_name = $call->gameArtwork();

Get game artwork string

$game_name = $call->gameArtwork();

Custom array access string

//array return call here Eg:$call->getUserDetails('shroud');
$custom = $call->getCustom(0, 'type');


Feature-packed PHP class for the latest Twitch API







No packages published