PHPackages                             simply-stream/twitch-api - 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. simply-stream/twitch-api

ActiveLibrary[API Development](/categories/api)

simply-stream/twitch-api
========================

1.1.2(2y ago)0404[1 issues](https://github.com/Simply-Stream/TwitchApi/issues)MITPHPPHP ^8.2CI failing

Since Nov 26Pushed 2mo agoCompare

[ Source](https://github.com/Simply-Stream/TwitchApi)[ Packagist](https://packagist.org/packages/simply-stream/twitch-api)[ RSS](/packages/simply-stream-twitch-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (11)Versions (10)Used By (0)

PHP Twitch API implementation (by Simply-Stream.com)
====================================================

[](#php-twitch-api-implementation-by-simply-streamcom)

[![QA](https://github.com/Simply-Stream/TwitchApi/actions/workflows/qa.yaml/badge.svg?branch=main)](https://github.com/Simply-Stream/TwitchApi/actions/workflows/qa.yaml) [![codecov](https://camo.githubusercontent.com/980fe5d559d68be1b64d57833ee638aad13e8f4db486dbb5966b5ef53acefde4/68747470733a2f2f636f6465636f762e696f2f67682f53696d706c792d53747265616d2f5477697463684170692f67726170682f62616467652e7376673f746f6b656e3d48543649554a4b4d3937)](https://codecov.io/gh/Simply-Stream/TwitchApi)

---

Welcome to the PHP Twitch Helix API Library, a powerful and developer-friendly implementation of the new Twitch API " Helix," complete with robust EventSub functionality. This library seamlessly integrates the latest features from Twitch, providing a straightforward and efficient way to interact with the Twitch platform in your PHP projects.

Key Features
------------

[](#key-features)

**Helix API Support**: Harness the full potential of the Twitch Helix API with ease. Retrieve user information, access streams, and more, all through a clean and intuitive PHP interface.

**EventSub Functionality**: Embrace the future of Twitch event handling with our comprehensive EventSub implementation. Keep your application in sync with real-time events, ensuring timely and accurate updates.

**Webhook Integration**: Our library fully supports webhook communication for EventSub, enabling seamless communication between Twitch and your application. Stay informed about user activities and channel events effortlessly.

**Data Transfer Objects (DTOs)**: Differentiating itself from traditional approaches, our library employs Data Transfer Objects (DTOs) to map incoming JSON responses to PHP objects. This abstraction simplifies the handling of Twitch data, enhancing code readability and maintainability.

To see a full list of implemented APIs, have a look at the [Implemented APIs](#implemented-apis) section.

Installation
------------

[](#installation)

```
composer req simplystream/twitch-api
```

Implemented APIs
----------------

[](#implemented-apis)

APIImplementedTestedAdsApi✅ℹ️AnalyticsApi✅❗BitsApi✅ℹ️ChannelPointsApi✅✅ChannelsApi✅✅CharityApi✅✅ChatApi✅✅ClipsApi✅✅ContentClassificationApi✅✅EntitlementsApi✅✅EventSubApi✅❗EventSub system✅✅ExtensionsApi✅❗GamesApi✅✅GoalsApi✅✅GuestStarApi (Beta)✅❗HypeTrainApi✅✅ModerationApi✅ℹ️PollsApi✅✅PredictionsApi✅✅RaidsApi✅✅ScheduleApi✅✅SearchApi✅✅StreamsApi✅✅SubscriptionsApi✅✅TeamsApi✅✅UsersApi✅ℹ️VideosApi✅✅WhispersApi✅✅❗ = Tests can't be implemented due to lack of mock-api-data. Mapping should work on Twitch prod systems ️️ℹ️ = Some tests are available, some are missing due to lack of mock-api data. Mapping should work on Twitch prod systems

**Tested in this case means, that functional or unit tests exist.**

There's also a container api service that can hold all the APIs implemented. See [TwitchApi](src/Helix/Api/TwitchApi.php).

### EventSub

[](#eventsub)

Besides the APIs, there's also a service available for the EventSub handling. This service will handle the registration to an event and also the webhook callbacks by validating the challenge send by Twitch.

**Please note, that this package only supports the webhook implementation!**This is due to the fact, that PHP might not be the ideal programming language to use for long running processes like a websocket.

#### Websocket

[](#websocket)

To use the websocket implementation, you should check out the following projects:

- [TwitchLib (C#)](https://github.com/TwitchLib/TwitchLib)
- [Twurple (TypeScript)](https://github.com/twurple/twurple)and [docs](https://twurple.js.org/docs/getting-data/eventsub/listener-setup.html)
- More will follow

Usage
-----

[](#usage)

To get everything up and running, you need to set some things up.

```
$client = new Client();
// Same for the request factory, it just needs to implement the RequestFactoryInterface&StreamFactoryInterface.
// Optionally the UriFactoryInterface, too, if you want to use the same object for the UriFactory.
$requestFactory = new RequestFactory();

$apiClient = new ApiClient(
    $client,
    $requestFactory,
    new \CuyZ\Valinor\MapperBuilder(),
    $requestFactory,
    ['clientId' => 'YOUR_CLIENT_ID', 'webhook' => ['secret' => 'YOUR_SECRET']]
);

$usersApi = new UsersApi($apiClient)
$response = $usersApi->getUsers(logins: ['some_login_name'], accessToken: $accessToken);

foreach($response->getData() as $user) {
    echo $user->getDisplayName();
}
```

### Bring your own client

[](#bring-your-own-client)

Instead of forcing you to implement yet another HTTP client, this library gives you the opportunity to use your own. The only restriction you got: It has to be PSR-18 compliant and implement the interface `\Psr\Http\Client\ClientInterface`.

We recommend either using the all in one package [Guzzlehttp](https://packagist.org/packages/guzzlehttp/guzzle%5D)or [PHP-HTTP](https://packagist.org/packages/php-http/curl-client) with the PSR7 implementation [Nyholm/PSR7](https://github.com/Nyholm/psr7)or [Guzzle/PSR7](https://packagist.org/packages/guzzlehttp/psr7).

### AccessToken

[](#accesstoken)

In older versions, the AccessToken have been autogenerated by the sendRequest method by a TwitchProvider that has been build into this library. This provider is now removed and you need to give the `$api->sendRequest(...)` method an AccessToken yourself!

Due to the fact that this library still requires the PHP league implementation of an AccessTokenInterface, we recommend using  to generate an AccessToken.

Supported Frameworks
--------------------

[](#supported-frameworks)

Currently, there is only an integration for [Symfony](https://symfony.com).

- [simplystream/twitch-api-bundle](https://github.com/Simply-Stream/TwitchApiBundle) (Still WIP, most of the code there has been moved to this repository)

TODO List
---------

[](#todo-list)

Even though most of this library is ready to use, there's still a lot to do. Here is a brief overview of what will come next ordered more or less by priority:

- Factories/Builder to easily instantiate the APIs and maybe some DTOs, especially the TwitchApi class
- Middleware features, to easily extend requests (e.g.: RateLimitMiddleware)
- A guideline for contributions

Contribution
------------

[](#contribution)

We welcome contributions! Feel free to open issues, submit pull requests, or join our community discussions. A short guide for contribution will follow.

Support
-------

[](#support)

You really like this project and want to support us in a different way than contribution? Feel free to support me on Ko-fi ♥️

[![ko-fi](https://camo.githubusercontent.com/201ef269611db7eb6b5d08e9f756ab8980df3014b64492770bdf13a6ed924641/68747470733a2f2f6b6f2d66692e636f6d2f696d672f676974687562627574746f6e5f736d2e737667)](https://ko-fi.com/R6R0HV2IO)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance56

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~16 days

Total

9

Last Release

774d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/18c6767492a70168de59c05177d123e5da5ef149c7bf920ea7fa73ffabc82fdc?d=identicon)[aaricdev](/maintainers/aaricdev)

---

Top Contributors

[![aaricdev](https://avatars.githubusercontent.com/u/84964307?v=4)](https://github.com/aaricdev "aaricdev (70 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/simply-stream-twitch-api/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[deeplcom/deepl-php

Official DeepL API Client Library

2616.2M66](/packages/deeplcom-deepl-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[n1ebieski/ksef-php-client

PHP API client that allows you to interact with the API Krajowego Systemu e-Faktur

7228.4k](/packages/n1ebieski-ksef-php-client)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

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