A Twitch API client for PHP.
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.
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:
- StreamsLabs:
- Alerts
- Authentication
- Donations
- Users
$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.
PHP 5.6 or higher is required.
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.*"
All unit tests can be run with the following command:
$ vendor/bin/phpunit # or simply "phpunit" if you have it installed globally
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.
Distributed under the MIT license.