PHPackages                             cranbri/livepeer-php - 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. cranbri/livepeer-php

ActiveLibrary[API Development](/categories/api)

cranbri/livepeer-php
====================

PHP client for the Livepeer Studio API

1.0.1(1y ago)044MITPHPPHP ^8.2CI passing

Since May 5Pushed 1y agoCompare

[ Source](https://github.com/cranbri/livepeer-php)[ Packagist](https://packagist.org/packages/cranbri/livepeer-php)[ Docs](https://github.com/cranbri/livepeer-php)[ GitHub Sponsors](https://github.com/sponsors/just-tom)[ RSS](/packages/cranbri-livepeer-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Livepeer PHP SDK
================

[](#livepeer-php-sdk)

[![Latest Version on Packagist](https://camo.githubusercontent.com/537bb62c48fcc0a1a46a7f7d527fed2a5104efca08605b83378a2db7458c0dd1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6372616e6272692f6c697665706565722d7068702e737667)](https://packagist.org/packages/cranbri/livepeer-php)[![Tests](https://github.com/cranbri/livepeer-php/actions/workflows/tests.yml/badge.svg)](https://github.com/cranbri/livepeer-php/actions/workflows/tests.yml)[![PHPStan](https://github.com/cranbri/livepeer-php/actions/workflows/phpstan.yml/badge.svg)](https://github.com/cranbri/livepeer-php/actions/workflows/phpstan.yml)[![Check Styling](https://github.com/cranbri/livepeer-php/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/cranbri/livepeer-php/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/23aed2c9879104b6846ce217133d608528a08705d0a1d8fe5fdfe23dcc7e8486/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6372616e6272692f6c697665706565722d7068702e737667)](https://packagist.org/packages/cranbri/livepeer-php)[![License](https://camo.githubusercontent.com/5b6256a5077ceacc0461b07d9fba4db4f1e934ba7880c6b46097da651c55890b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6372616e6272692f6c697665706565722d706870)](https://github.com/cranbri/livepeer-php/blob/main/LICENSE.md)

A modern PHP client for the [Livepeer Studio API](https://docs.livepeer.org/reference/api/overview), built on [Saloon](https://docs.saloon.dev/).

Features
--------

[](#features)

- Full API coverage for Livepeer Studio
- Type-safe request/response handling
- Modern PHP 8.2+ with strict typing
- Comprehensive test suite
- Exception handling
- Expressive fluent interface
- PSR-12 compliant

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Composer

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

[](#installation)

You can install the package via composer:

```
composer require cranbri/livepeer-php
```

Usage
-----

[](#usage)

### Initializing the Client

[](#initializing-the-client)

```
use Cranbri\Livepeer\Livepeer;

// Initialize with your Livepeer API key
$livepeer = new Livepeer('your-api-key');
```

### Asset Management

[](#asset-management)

```
// Request asset upload
$upload = $livepeer->requestAssetUpload(new UploadAssetData(
    name: 'My Video',
    playbackPolicy: PlaybackPolicyData::public()
));

// Upload an asset via URL
$asset = $livepeer->uploadAssetFromUrl(new UrlUploadAssetData(
    name: 'My Video',
    url: 'https://example.com/video.mp4',
    playbackPolicy: PlaybackPolicyData::public()
));

// Get an asset by ID
$asset = $livepeer->getAsset('asset-id');

// List all assets
$assets = $livepeer->listAssets();

// Update an asset
$livepeer->updateAsset('asset-id', new UpdateAssetData(
    name: 'Updated Video Name',
    playbackPolicy: PlaybackPolicyData::public()
));

// Delete an asset
$livepeer->deleteAsset('asset-id');
```

### Livestreaming

[](#livestreaming)

```
// Create a new livestream
$stream = $livepeer->createLivestream(new CreateLivestreamData(
    name: 'My Livestream',
    record: true,
    playbackPolicy: PlaybackPolicyData::public()
));

// Get stream details
$stream = $livepeer->getLivestream('stream-id');

// Update a stream
$livepeer->updateLivestream('stream-id', new UpdateLivestreamData(
    name: 'Updated Stream Name',
    record: true
));

// List all streams
$streams = $livepeer->listLivestreams();

// List with filters
$filteredStreams = $livepeer->listLivestreams([
    'record' => true,
    'creatorId' => 'creator-123'
]);

// Delete a stream
$livepeer->deleteLivestream('stream-id');

// Terminate an active stream
$livepeer->terminateLivestream('stream-id');

// Create a clip from livestream
$clip = $livepeer->createClip(new CreateClipData(
    playbackId: 'playback-id',
    startTime: 60000,  // in milliseconds
    endTime: 120000,   // in milliseconds
    name: 'My Clip'
));

// List clips for a stream
$clips = $livepeer->listClips('stream-id');
```

### Multistreaming

[](#multistreaming)

```
// Create a multistream target
$target = $livepeer->createMultistreamTarget(new CreateTargetData(
    url: 'rtmp://example.com/live',
    name: 'YouTube Target'
));

// Get a target by ID
$target = $livepeer->getMultistreamTarget('target-id');

// Update a target
$livepeer->updateMultistreamTarget('target-id', new UpdateTargetData(
    url: 'rtmp://example.com/updated',
    name: 'Updated Target',
    disabled: false
));

// List all targets
$targets = $livepeer->listMultistreamTargets();

// Delete a target
$livepeer->deleteMultistreamTarget('target-id');

// Add a target to a stream
$livepeer->addMultistreamTarget('stream-id', new AddMultistreamTargetData(
    source: 'source',
    id: 'target-id'
));

// Remove a target from a stream
$livepeer->removeMultistreamTarget('stream-id', 'target-id');
```

### Webhooks

[](#webhooks)

```
// Create a webhook
$webhook = $livepeer->createWebhook(new CreateWebhookData(
    name: 'Stream Events',
    url: 'https://example.com/webhook',
    events: [
        WebhookEvent::STREAM_STARTED,
        WebhookEvent::STREAM_IDLE
    ]
));

// Get a webhook
$webhook = $livepeer->getWebhook('webhook-id');

// Update a webhook
$livepeer->updateWebhook('webhook-id', new UpdateWebhookData(
    name: 'Updated Stream Events',
    url: 'https://example.com/updated-webhook',
    events: [
        WebhookEvent::STREAM_STARTED,
        WebhookEvent::STREAM_IDLE,
        WebhookEvent::RECORDING_READY
    ]
));

// List all webhooks
$webhooks = $livepeer->listWebhooks();

// Delete a webhook
$livepeer->deleteWebhook('webhook-id');
```

### Sessions and Playback

[](#sessions-and-playback)

```
// Get a session by ID
$session = $livepeer->getSession('session-id');

// List all sessions
$sessions = $livepeer->listSessions();

// List recorded sessions for a stream
$recordedSessions = $livepeer->listRecordedSessions('stream-id');

// List clips for a session
$sessionClips = $livepeer->listSessionClips('session-id');

// Get playback info
$playbackInfo = $livepeer->getPlaybackInfo('playback-id');
```

### Tasks

[](#tasks)

```
// Get a task by ID
$task = $livepeer->getTask('task-id');

// List all tasks
$tasks = $livepeer->listTasks();

// Transcode a video
$task = $livepeer->transcodeVideo(new CreateTranscodingData(
    input: new UrlInputData('https://example.com/video.mp4'),
    storage: new Web3StorageData(new Web3CredentialsData('your-token')),
    outputs: new TranscodeOutputData(
        hls: ['path' => '/path/to/hls'],
        mp4: ['path' => '/path/to/mp4'],
        fmp4: ['path' => '/path/to/fmp4']
    )
));
```

### Access Control

[](#access-control)

```
// Create a signing key
$key = $livepeer->createSigningKey();

// Get a signing key
$key = $livepeer->getSigningKey('key-id');

// Update a signing key
$livepeer->updateSigningKey('key-id', new UpdateSigningKeyData(
    name: 'Updated Key',
    disabled: false
));

// List signing keys
$keys = $livepeer->listSigningKeys();

// Delete a signing key
$livepeer->deleteSigningKey('key-id');
```

### Analytics

[](#analytics)

```
// Query realtime viewership
$viewers = $livepeer->queryRealtimeViewership([
    'playbackId' => 'playback-id',
    'breakdownBy' => 'country'
]);

// Query viewership metrics
$viewershipMetrics = $livepeer->queryViewershipMetrics([
    'fromTime' => '2024-01-01T00:00:00Z',
    'toTime' => '2024-01-31T23:59:59Z',
    'playbackId' => 'playback-id',
    'breakdownBy' => 'browser'
]);

// Query usage metrics
$usageMetrics = $livepeer->queryUsageMetrics([
    'fromTime' => '2024-01-01T00:00:00Z',
    'toTime' => '2024-01-31T23:59:59Z',
    'timeStep' => '1d'
]);

// Query public total views metrics
$totalViews = $livepeer->queryPublicTotalViewsMetrics('playback-id');

// Query creator viewership metrics
$creatorViewership = $livepeer->queryCreatorViewershipMetrics([
    'fromTime' => '2024-01-01T00:00:00Z',
    'toTime' => '2024-01-31T23:59:59Z',
    'creatorId' => 'creator-id'
]);
```

Advanced Usage
--------------

[](#advanced-usage)

### Stream Profiles

[](#stream-profiles)

```
// Create a stream with specific profiles
$stream = $livepeer->createLivestream(new CreateLivestreamData(
    name: 'HD Stream',
    profiles: [
        StreamProfileData::hd720(),
        StreamProfileData::sd480(),
        StreamProfileData::hd1080(),
        StreamProfileData::uhd4k()
    ]
));

// Custom stream profile
$customProfile = new StreamProfileData(
    bitrate: 2500000,
    name: 'custom-720p',
    width: 1280,
    height: 720,
    fps: 30,
    encoder: EncoderType::H264
);
```

### Playback Policies

[](#playback-policies)

```
// Public playback (default)
$publicPolicy = PlaybackPolicyData::public();

// JWT playback (requires signing key)
$jwtPolicy = PlaybackPolicyData::jwt();

// Webhook playback
$webhookPolicy = PlaybackPolicyData::webhook(
    webhookId: 'webhook-id',
    webhookContext: ['user' => 'user-123']
);

// With custom allowed origins
$customPolicy = new PlaybackPolicyData(
    type: PlaybackPolicyType::PUBLIC,
    allowedOrigins: ['https://example.com', 'https://app.example.com']
);
```

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

[](#error-handling)

All API errors are converted to `LivepeerException` instances:

```
use Cranbri\Livepeer\Livepeer;
use Cranbri\Livepeer\Exceptions\LivepeerException;

try {
    $livepeer = new Livepeer('invalid-api-key');
    $assets = $livepeer->listAssets();
} catch (LivepeerException $e) {
    echo "Error: " . $e->getMessage();
    echo "HTTP Status: " . $e->getCode();

    // Get the full response if available
    if ($response = $e->getResponse()) {
        $responseBody = $e->getResponseBody();
        // Handle error details
    }
}
```

API Reference
-------------

[](#api-reference)

For detailed information about all available methods and data structures, please refer to the [API Documentation](https://docs.livepeer.org/api-reference).

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Tom Burman](https://github.com/yourusername)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance49

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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 ~0 days

Total

2

Last Release

377d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d9d47d3153558ce1f9e345d91e2a0421eeecbbb433587b08134ccb88559d8c87?d=identicon)[just-tom](/maintainers/just-tom)

---

Tags

apisdkstreamingvideolivepeer

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cranbri-livepeer-php/health.svg)

```
[![Health](https://phpackages.com/badges/cranbri-livepeer-php/health.svg)](https://phpackages.com/packages/cranbri-livepeer-php)
```

###  Alternatives

[saloonphp/laravel-plugin

The official Laravel plugin for Saloon

805.7M125](/packages/saloonphp-laravel-plugin)[muxinc/mux-php

Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before.

522.1M11](/packages/muxinc-mux-php)

PHPackages © 2026

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