PHPackages                             corbpie/twitch-api-class - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. corbpie/twitch-api-class

ActiveLibrary[API Development](/categories/api)

corbpie/twitch-api-class
========================

A PHP Twitch API wrapper

1.1(4y ago)2181[2 issues](https://github.com/cp6/Twitch-API-class/issues)MITPHPPHP &gt;=8.0

Since Aug 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/cp6/Twitch-API-class)[ Packagist](https://packagist.org/packages/corbpie/twitch-api-class)[ RSS](/packages/corbpie-twitch-api-class/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Twitch API class
================

[](#twitch-api-class)

### Updated for OAuth usage!

[](#updated-for-oauth-usage)

Feature packed, easy to use PHP class for the [latest](https://dev.twitch.tv/docs/api/) Twitch API.

You will need your free Twitch client id to use, see [here](https://dev.twitch.tv/docs/api/#step-1-setup) to obtain.

To get your authorization code see [here](https://write.corbpie.com/twitch-api-authentication-with-oauth-using-php/).

This class will automatically refresh access token once it expires!

Features
--------

[](#features)

- 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

Usage
-----

[](#usage)

**Fetch with composer:**

```
composer require corbpie/twitch-api-class
```

To use:

```
require_once('vendor/autoload.php');

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](https://write.corbpie.com/twitch-api-authentication-with-oauth-using-php/) (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:

`http://localhost/?code=THEISACCESSCODE`

### Calls

[](#calls)

Get current top (view count) streams `array`

```
$call->getTopStreams();
```

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

```
$call->getGameTopStreams($gameid);
```

Get top (view count) streamer for a game `string`

```
$call->getGameTopStreams($gameid);
echo $call->getTopStreamerForGame();
```

Get viewer count for the top stream for a game `string`

```
$call->getGameTopStreams($gameid);
echo $call->getTopViewersForGame();
```

Get top games `array`

(Good way to get gameid's)

```
$call->getTopGames();
```

Get details for username `array`

```
$call->getUserDetails($username);
```

Get user id for username `string`

```
$call->getUserDetails($username);
$user_id = $call->idForUser();
```

Get emotes for username `array`

```
$call->getUserEmotes($username);
```

Get image for emote id `string`

```
$call->emoteImage($emoteid);
```

Get chat for VOD `array`

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

Get users stream details (If live) `array`

```
$call->getUserStream($username);
```

Check if a user is live and streaming `boolean`

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

**If user is streaming:**

Get game id `string`

```
$call->streamGameId();
```

Get viewer count `string`

```
$call->streamViewers();
```

Get stream title `string`

```
$call->streamTitle();
```

Get stream id `string`

```
$call->streamId();
```

Get stream start time `string`

```
$call->streamStart();
```

Get stream thumbnail `string`

```
$call->streamThumbnail();
```

Get stream thumbnail `array`

```
$call->getStreamTags($streamid);
```

Get top clips for game id `array`

```
$call->getGameClips($gameid);
```

Get users top clips `array`

```
$call->getUserClips($user);
```

Get users videos (most recent first) `array`

```
$call->getUserVideos($user);
```

Get users videos for game id `array`

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

Get game data for game id `array`

```
$call->getGameData($game_id);
```

Get game name `string`

```
$call->getGameData($game_id);
$game_name = $call->gameName();
```

Get game artwork `string`

```
$call->getGameData($game_id);
$game_name = $call->gameArtwork();
```

Get game artwork `string`

```
$call->getGameData($game_id);
$game_name = $call->gameArtwork();
```

Custom array access `string`

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

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1783d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d10a4771b8a6b05a8892e38d902bd35e3f05b0009b58360edf158cda1b1c221b?d=identicon)[corbpie](/maintainers/corbpie)

---

Top Contributors

[![cp6](https://avatars.githubusercontent.com/u/9095402?v=4)](https://github.com/cp6 "cp6 (16 commits)")

---

Tags

twitchtwitch-api

### Embed Badge

![Health badge](/badges/corbpie-twitch-api-class/health.svg)

```
[![Health](https://phpackages.com/badges/corbpie-twitch-api-class/health.svg)](https://phpackages.com/packages/corbpie-twitch-api-class)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k12](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
