Aller au contenu
← Retour aux projets

Laravel Wistia

Laravel Wistia

#Laravel Wistia

Tests PHPStan Code Style Latest Version on Packagist Total Downloads License

A lightweight Wistia Data API client for Laravel. It wraps the api.wistia.com v1 endpoints behind a small static client, threads your API password as HTTP basic auth, and defensively returns null (rather than throwing) on network failures or non-2xx responses.

#Features

  • Accountaccount(), accountStats()
  • Projectsprojects(), project(), createProject(), updateProject(), deleteProject(), projectStats()
  • Mediasmedias(), media(), updateMedia(), deleteMedia(), copyMedia(), mediaStats()
  • StatsmediaStatsByDate(), mediaEngagement(), visitors(), visitor(), events()
  • Captionscaptions(), createCaption()

#Installation

composer require jeffersongoncalves/laravel-wistia

Optionally publish the config file:

php artisan vendor:publish --tag="laravel-wistia-config"

#Configuration

Add to your .env:

WISTIA_API_KEY=...

Create an API password from your Wistia account API settings.

#Config Options

// config/wistia.php
return [
    'token' => env('WISTIA_API_KEY'),
    'timeout' => (int) env('WISTIA_TIMEOUT', 8),
];

When wistia.token is null the client falls back to config('services.wistia.token').

#Usage

use JeffersonGoncalves\Wistia\WistiaClient;

// Account
$account = WistiaClient::account();
$accountStats = WistiaClient::accountStats();

// Projects
$projects = WistiaClient::projects(['per_page' => 50]);
$project = WistiaClient::project('abc123');
$created = WistiaClient::createProject('Onboarding', public: true, description: 'Customer onboarding videos');
WistiaClient::updateProject('abc123', ['name' => 'Onboarding 2026']);
WistiaClient::deleteProject('abc123');
$projectStats = WistiaClient::projectStats('abc123');

// Medias
$medias = WistiaClient::medias(['project_id' => 'abc123', 'type' => 'Video']);
$media = WistiaClient::media('vid1');
WistiaClient::updateMedia('vid1', ['name' => 'Intro', 'description' => 'Welcome']);
WistiaClient::copyMedia('vid1', targetProjectId: 'def456');
WistiaClient::deleteMedia('vid1');
$mediaStats = WistiaClient::mediaStats('vid1');

// Stats
$byDate = WistiaClient::mediaStatsByDate('vid1', startDate: '2026-09-01', endDate: '2026-09-07');
$engagement = WistiaClient::mediaEngagement('vid1');
$visitors = WistiaClient::visitors(['search' => 'jane', 'per_page' => 50]);
$visitor = WistiaClient::visitor('visitor_key');
$events = WistiaClient::events(['media_id' => 'vid1']);

// Captions
$captions = WistiaClient::captions('vid1');
WistiaClient::createCaption('vid1', 'eng', file_get_contents('subtitles.srt'));

Single-resource methods return array<string, mixed>|null, collection methods return list<array<string, mixed>>|null, and deleteProject()/deleteMedia() return boolnull/false on any network failure or non-2xx response instead of throwing. Null arguments are stripped from the payload before it is sent, so optional fields are simply omitted.

#Testing

composer test

#Static Analysis

composer analyse

#Code Formatting

composer format

#Changelog

Please see CHANGELOG for more information on what has changed recently.

#License

The MIT License (MIT). Please see License File for more information.

Nouvelle version disponible.