laahudra / twitch-api-php
A Twitch API client for PHP.
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 47
pkg:composer/laahudra/twitch-api-php
Requires
- php: >=5.6.0
Requires (Dev)
- phpunit/phpunit: ^5.7
README
A Twitch API client for PHP.
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
- Bits
- Channel Feed
- Channels
- Chat
- Clips
- Collections
- 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
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.