eihmels/twitch-helix-streams

implements the Twitch Api "GET https://api.twitch.tv/helix/streams"

1.1.0 2023-08-27 10:32 UTC

This package is auto-updated.

Last update: 2024-06-27 12:24:54 UTC


README

PHPUnit codeSniffer phpstan

twitch-helix-streams

implements the Twitch Api "GET https://api.twitch.tv/helix/streams"

you can find a complete Documentation of this Api here

requirements

  • >= PHP 8.1

Get Started

Composer Require

composer require eihmels/twitch-helix-streams

please take a look into the examples folder. change your credentials and tryit.

you will get a StreamCollection from the GetStreams class, looks like this:

StreamCollection:
    Streams[] streams;
    Pagination pagination

Streams

a Representation of one single stream with all Information from The Api. looks like this:

        Stream:
            StreamIdentifier streamIdentifier,
            UserIdentifier userIdentifier,
            UserLogin userLogin,
            UserName userName,
            Type type,
            Title title,
            Tags tags,
            ViewerCount viewerCount,
            StartedAt startedAt,
            Language language,
            ThumbnailUrl thumbnailUrl,
            TagIdentifiers tagIdentifiers,
            IsMature isMature

please take a look in the Twitch Streams Documentation about this.

Client

you have to initialize a client that holds the endpoint and your ClientId and a ClientInterface.

$client = new TwitchHelix('https://api.twitch.tv', '/helix/streams', '<yourClientId>', new Client());

Now you can initialize the Application that returns a list of streams like you see above:

 $application->execute(
        '<yourToken>',
        new QueryParameterCollection(
            [
                new UserIdentifier('123456')
            ],
            new First(2),
        )
    ));

Querys

you can Query the Streams with the Queryparameters in a QueryParameterCollection:

Available QueryParameters:

  • Language
  • GameIdentifiers
  • UserIdentifier
  • UserLogin
  • Type