PHPackages                             notwonderful/trovo-sdk - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. notwonderful/trovo-sdk

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

notwonderful/trovo-sdk
======================

PHP SDK for Trovo.live API — OAuth, channels, users, chat, clips, drops and more

0.1.0(3mo ago)00MITPHPPHP ^8.3CI passing

Since Feb 11Pushed 3mo agoCompare

[ Source](https://github.com/notwonderful/trovo-sdk)[ Packagist](https://packagist.org/packages/notwonderful/trovo-sdk)[ RSS](/packages/notwonderful-trovo-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

[![Logo](.github/assets/logo.png)](.github/assets/logo.png)[![PHP Version](https://camo.githubusercontent.com/0e636722677a61c567dcf28f72172c051f915f26834f465b398b26d6da4ea5d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c75653f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://camo.githubusercontent.com/0e636722677a61c567dcf28f72172c051f915f26834f465b398b26d6da4ea5d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c75653f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)[![License](https://camo.githubusercontent.com/153acf9dff19deb8abfc598c53bac50a4ceae0f5c83a552711060d3d78d2c057/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e3f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/153acf9dff19deb8abfc598c53bac50a4ceae0f5c83a552711060d3d78d2c057/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e3f7374796c653d666f722d7468652d6261646765)

PHP 8.3+ SDK for the [Trovo.live API](https://developer.trovo.live/docs/APIs.html).

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

[](#installation)

```
composer require notwonderful/trovo-sdk
```

Quick Start
-----------

[](#quick-start)

```
use Notwonderful\TrovoSdk\TrovoClient;
use Notwonderful\TrovoSdk\Config;
use Notwonderful\TrovoSdk\Enum\Scope;

$trovo = new TrovoClient(new Config(
    clientId: 'your_client_id',
    clientSecret: 'your_client_secret',
    redirectUri: 'https://example.com/callback',
));
```

Authentication
--------------

[](#authentication)

### OAuth 2.0 Authorization Code Flow

[](#oauth-20-authorization-code-flow)

```
// 1. Redirect user to Trovo login
$url = $trovo->getAuthorizationCodeUrl(
    scopes: [Scope::UserDetailsSelf, Scope::ChannelDetailsSelf],
    state: 'random_csrf_token',
);

// 2. After redirect, exchange code for tokens
$token = $trovo->exchangeCode($_GET['code']);
// $token->accessToken, $token->refreshToken, $token->expiresIn

// 3. Set the token for subsequent API calls
$trovo->setAccessToken($token->accessToken);
```

### OAuth 2.0 Implicit Flow

[](#oauth-20-implicit-flow)

```
$url = $trovo->getImplicitFlowUrl(
    scopes: [Scope::UserDetailsSelf],
    state: 'random_csrf_token',
);
// Access token will be in the URL fragment after redirect
```

### Token Management

[](#token-management)

```
// Refresh
$newToken = $trovo->refreshToken($token->refreshToken);

// Validate
$info = $trovo->validateToken($token->accessToken);
// $info->uid, $info->scopes, $info->expireTs, $info->isExpired()

// Revoke
$trovo->revokeToken($token->accessToken);
```

API Usage
---------

[](#api-usage)

### Categories

[](#categories)

```
// Top categories (sorted by popularity)
$categories = $trovo->categories()->getTopCategories();
// returns Category[] — id, name, shortName, iconUrl, desc

// Search
$result = $trovo->categories()->search(query: 'apex', limit: 10);
// $result->items (Category[]), $result->hasMore
```

### Channels

[](#channels)

```
// Top live channels with pagination
$page = $trovo->channels()->getTopChannels(limit: 20);
// $page->items (Channel[]), $page->totalPage, $page->cursor, $page->token

// Next page
$page2 = $trovo->channels()->getTopChannels(
    limit: 20,
    after: true,
    token: $page->token,
    cursor: $page->cursor,
);

// Channel info by ID or username
$channel = $trovo->channels()->getById(channelId: 100000031);
$channel = $trovo->channels()->getById(username: 'username');

// Own channel with stream key (requires channel_details_self)
$my = $trovo->channels()->getMy();
// $my->streamKey, $my->isLive, $my->title, ...

// Update channel (requires channel_update_self)
use Notwonderful\TrovoSdk\Enum\AudienceType;

$trovo->channels()->update(
    channelId: 100000031,
    liveTitle: 'New title',
    categoryId: '10023',
    languageCode: 'EN',
    audiType: AudienceType::Teen,
);

// Followers
$followers = $trovo->channels()->getFollowers(channelId: 100000031, limit: 50);
// $followers->items (Follower[]), $followers->total, $followers->totalPage

// Viewers (grouped by role)
$viewers = $trovo->channels()->getViewers(channelId: 100000031);
// $viewers['chatters']['moderators']['viewers'], $viewers['total'], ...
```

### Users

[](#users)

```
// Lookup by usernames
$users = $trovo->users()->getByUsernames(['user1', 'user2']);
// returns User[] — userId, userName, nickName, channelId

// Authenticated user info (requires user_details_self)
$me = $trovo->users()->getUserInfo();
// $me->userId, $me->userName, $me->email, $me->profilePic
```

### Subscribers

[](#subscribers)

```
use Notwonderful\TrovoSdk\Enum\SortDirection;

// Requires channel_subscriptions scope
$subs = $trovo->subscribers()->get(
    channelId: 100000031,
    limit: 50,
    offset: 0,
    direction: SortDirection::Desc,
);
// $subs->items (Subscriber[]), $subs->total
// Subscriber: userId, username, displayName, subCreatedAt, subLv, subTier
```

### Emotes

[](#emotes)

```
use Notwonderful\TrovoSdk\Enum\EmoteType;

$emotes = $trovo->emotes()->get(
    emoteType: EmoteType::All,
    channelIds: [100000031],
);
// Raw array: globalEmotes, eventEmotes, customizedEmotes
```

### Streams &amp; Past Streams

[](#streams--past-streams)

```
// Live stream URLs (restricted access)
$urls = $trovo->streams()->getLiveStreamUrls(channelId: 100000031);
// returns StreamUrl[] — playUrl, desc (resolution)

// Past streams
use Notwonderful\TrovoSdk\Enum\Period;

$past = $trovo->streams()->getPastStreams(
    channelId: 100000031,
    period: Period::Month,
    limit: 10,
);
// $past->items (PastStream[]), $past->total, $past->totalPage
```

### Clips

[](#clips)

```
$clips = $trovo->clips()->get(
    channelId: 100000031,
    period: Period::Week,
    limit: 20,
);
// $clips->items (Clip[]) — clipId, title, url, thumbnail, duration, views, likes
```

### Chat

[](#chat)

```
// Send to own channel (requires chat_send_self)
$trovo->chat()->sendToMyChannel('Hello!');

// Send to another channel (requires chat_send_self + send_to_my_channel)
$trovo->chat()->sendToChannel('Hello!', channelId: 100000031);

// Delete message (requires manage_messages)
$trovo->chat()->deleteMessage(
    channelId: '100000031',
    messageId: 'msg_123',
    userId: '100000021',
);

// Chat commands (requires manage_messages)
$result = $trovo->chat()->performCommand('mod @username', channelId: 100000031);
// $result->isSuccess, $result->displayMsg
```

### Drops (App Access Token)

[](#drops-app-access-token)

Drops APIs use Trovo Signature (HMAC-SHA1) automatically:

```
use Notwonderful\TrovoSdk\Enum\FulfillmentStatus;

$drops = $trovo->drops()->getEntitlements(
    limit: 50,
    fulfillmentStatus: FulfillmentStatus::Claimed,
);
// $drops->items (DropEntitlement[]), $drops->total, $drops->hasMore

$results = $trovo->drops()->updateEntitlements(
    entitlementIds: ['ent_1', 'ent_2'],
    fulfillmentStatus: FulfillmentStatus::Fulfilled,
);
// returns DropUpdateResult[] — entitlementId, status, isSuccess()
```

Laravel Integration
-------------------

[](#laravel-integration)

The package auto-registers its ServiceProvider via Laravel's package discovery.

Add credentials to your `.env`:

```
TROVO_CLIENT_ID=your_client_id
TROVO_CLIENT_SECRET=your_client_secret
TROVO_REDIRECT_URI=https://example.com/callback
```

Optionally publish the config:

```
php artisan vendor:publish --tag=trovo-config
```

Then resolve from the container:

```
use Notwonderful\TrovoSdk\TrovoClient;

$trovo = app(TrovoClient::class);
$categories = $trovo->categories()->getTopCategories();
```

Or inject via constructor:

```
public function __construct(private TrovoClient $trovo) {}
```

Error Handling
--------------

[](#error-handling)

```
use Notwonderful\TrovoSdk\Exception\ApiException;
use Notwonderful\TrovoSdk\Exception\AuthenticationException;
use Notwonderful\TrovoSdk\Exception\RateLimitException;

try {
    $user = $trovo->users()->getUserInfo();
} catch (RateLimitException $e) {
    // $e->limit, $e->remaining, $e->resetsAt, $e->getSecondsUntilReset()
    sleep($e->getSecondsUntilReset());
} catch (AuthenticationException $e) {
    // Access token missing or not set
} catch (ApiException $e) {
    // $e->statusCode (HTTP), $e->trovoErrorCode, $e->trovoError, $e->getMessage()
}
```

Custom HTTP Client
------------------

[](#custom-http-client)

Implement `HttpClientInterface` to use your own HTTP client or for testing:

```
use Notwonderful\TrovoSdk\Http\HttpClientInterface;

$trovo = new TrovoClient($config, new MyCustomHttpClient());
```

Available Scopes
----------------

[](#available-scopes)

EnumValueDescription`Scope::UserDetailsSelf``user_details_self`View email and user profile`Scope::ChannelDetailsSelf``channel_details_self`View channel details + stream key`Scope::ChannelUpdateSelf``channel_update_self`Update channel settings`Scope::ChannelSubscriptions``channel_subscriptions`Get subscribers list`Scope::ChatSendSelf``chat_send_self`Send chat messages`Scope::SendToMyChannel``send_to_my_channel`Allow others to send to your channel`Scope::ManageMessages``manage_messages`Delete messages and chat commandsSupport
-------

[](#support)

If you like this package, please consider giving it a star ⭐ on GitHub!

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance82

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

96d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d8d32e96910a3e8d0794abc7ca155b2299f0fb046145221a9e1733dfe19c181d?d=identicon)[notwonderful](/maintainers/notwonderful)

---

Top Contributors

[![notwonderful](https://avatars.githubusercontent.com/u/102656911?v=4)](https://github.com/notwonderful "notwonderful (1 commits)")

---

Tags

api-clientlive-streamingoauth2phpphp-sdksdktrovotrovo-apitrovo-toolapisdkstreamingoauthtrovo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/notwonderful-trovo-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/notwonderful-trovo-sdk/health.svg)](https://phpackages.com/packages/notwonderful-trovo-sdk)
```

###  Alternatives

[happyr/linkedin-api-client

LinkedIn API client. Handles OAuth, CSRF protection. Easy to implement and extend. This is a standalone library for any composer project.

1991.6M12](/packages/happyr-linkedin-api-client)[bocharsky-bw/vkontakte-php-sdk

Vkontakte PHP SDK

3259.2k1](/packages/bocharsky-bw-vkontakte-php-sdk)[acuityscheduling/acuityscheduling

Acuity Scheduling PHP SDK. Examples and a standard library for Acuity Scheduling integration.

11294.8k](/packages/acuityscheduling-acuityscheduling)[surfoo/geocaching-php-sdk

Geocaching PHP SDK

143.4k1](/packages/surfoo-geocaching-php-sdk)

PHPackages © 2026

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