padhie/twitch-api-bundle

Simple Client for Twitch-Api https://dev.twitch.tv/docs/api/reference


Keywords
api, twitch, twitch.tv, twitch-tv, twitch-api
License
MIT

Documentation

TwitchApi

Simple Client for Twitch-Api https://dev.twitch.tv/docs/api/reference

How to use

Create Client

// see https://dev.twitch.tv/docs/authentication/getting-tokens-oauth
$clientId = 'CLIENT_ID';
$authorization = 'AUTHORIZATION';

$client = new \Padhie\TwitchApiBundle\TwitchClient(
    new \GuzzleHttp\Client(),
    new \Padhie\TwitchApiBundle\Request\RequestGenerator($clientId, $authorization),
    new \Padhie\TwitchApiBundle\Response\ResponseGenerator(),
);

send Single Request

$request = new \Padhie\TwitchApiBundle\Request\Channels\GetChannelInformationRequest($broadcasterId);

$response = $client->send($request);
assert($response instanceof \Padhie\TwitchApiBundle\Response\Channels\GetChannelInformationResponse);

$title = $response->getChannels()[0]->getTitle();

send Pagination Request

$request = new \Padhie\TwitchApiBundle\Request\Users\GetUsersFollowsRequest($broadcasterId);

$response = $client->sendWithPagination($request);
assert($response instanceof \Padhie\TwitchApiBundle\Request\Users\GetUsersFollowsResponse);

$users = $response->getUsers();

Todo

  • implement Namespaces
    • Ads
    • Analytics
    • Bits
    • ChannelPoints
    • Channels
    • Chat
    • Clips
    • Entitlements
    • EventSub
    • Extensions
    • Games
    • Goals
    • HypeTrain
    • Moderation
    • Music
    • Polls
    • Predictions
    • Schedule
    • Search
    • Streams
    • Subscriptions
    • Tags
    • Teams
    • Users
    • Videos
  • tests with Response Examples (from Documentation)
  • implement Parallel Request
  • implement Async Request