Skip to content

RickyNotaro/twitch-api-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twitch-api-php

A Twitch API client for PHP.

Build Status

Supported APIs

This library aims to support v3, v4 and v5 of the Twitch API until each one becomes deprecated. If an API version is not specified, v5 will be used as the default.

Features Completed

Main API Endpoints:

  • Authentication
  • Channel Feed
  • Channels
  • Chat
  • Clips
  • Communities
  • Games
  • Ingests
  • Search
  • Streams
  • Teams
  • Users
  • Videos

Any endpoints missing? Open an issue here.

Other Features:

  • IRC Client
  • Pub/Sub (ie. Bits & Whispers)
  • Video Upload

Additional Integrations:

Basic Example

$options = [
    'client_id' => 'YOUR-CLIENT-ID',
];

$twitchApi = new \TwitchApi\TwitchApi($options);
$user = $twitchApi->getUser(26490481);

// By default API responses are returned as an array, but if you want the raw JSON instead:
$twitchApi->setReturnJson(true);
$user = $twitchApi->getUser(26490481);

// If you want to switch between API versions on the fly:
$twitchApi->setApiVersion(3);
$user = $twitchApi->getUser('summit1g');

See the examples directory for more common use cases.

Requirements

PHP 5.6 or higher is required.

Installation

Either pull in the library via composer:

$ composer require nicklaw5/twitch-api-php

or add the following dependency to your composer.json file and run composer install:

"nicklaw5/twitch-api-php": "0.1.*"

Tests

All unit tests can be run with the following command:

$ vendor/bin/phpunit # or simply "phpunit" if you have it installed globally

Documentation

The Twitch API docs can be found here.

As for the documentation of this library, that is still on the to-do list. In the meantime, most modern IDEs by default, or through the use of plugins, will provide class property and method auto-completion. Or you can simple look through the source code.

License

Distributed under the MIT license.

Packages

No packages published

Languages

  • PHP 100.0%