A TVDB API wrapper for Laravel.

v1.0.2 2019-01-21 11:04 UTC

This package is auto-updated.

Last update: 2020-05-21 14:26:32 UTC


Latest Version on Packagist Quality Score Total Downloads

The musa11971/laravel-tvdb package provides easy to use functions that help you interact with the TVDB API.


You can install the package via composer:

composer require musa11971/laravel-tvdb

Publish the config file with the following artisan command:

php artisan vendor:publish --provider="musa11971\TVDB\TVDBServiceProvider"


The publish command above will publish a tvdb.php config file to your Laravel config folder. Be sure to tweak the values with your personal API details.
I recommend not touching the config file, but rather defining your API details in your project's .env file, like so:


Don't forget to clear recache your config. (php artisan config:cache)


Finding series by ID

The getSeries function returns a Series object.

// Find a series by its TVDB ID
// ID: 73739 (Lost)
$result = TVDB::getSeries(73739);

echo $result->title; // "Lost"

Searching for series

The search function returns an array of Series objects, or an empty array if no results are found.

// Search by title
$results = TVDB::search('Planet Earth');

// Search by IMDB ID
$results = TVDB::search(['imdbId' => 'tt5491994']);

// Search by zap2it ID
$results = TVDB::search(['zap2itId' => 'SH303483']);

Getting series images

In order get an array of a series' images, you need to specify the type of image you'd like to retrieve. Available types are listed below.

 * Get the images of the series by TVDB ID
 * ID: 73739 (Lost)
 * Available image types:
$images = TVDB::getSeriesImages(73739, TVDB::IMAGE_TYPE_POSTER);

// Or get the images directly from a "Series" object
$series = TVDB::getSeries(73739);
$images = $series->getImages(TVDB::IMAGE_TYPE_FANART);

Getting series actors

The following options are available for retrieving an array of actors.

 * Get the actors of the series by TVDB ID
 * ID: 73739 (Lost)
$actors = TVDB::getSeriesActors(73739);

// Or get the actors directly from a "Series" object
$series = TVDB::getSeries(73739);
$actors = $series->getActors();

Getting series episodes

The TVDB API endpoint for retrieving episodes is paginated. This means that you will need to specify a page number when retrieving episodes.

 * Get the episodes of the series by TVDB ID
 * ID: 73739 (Lost)
 * The second parameter specifies the page (page 1 by default)
$episodes = TVDB::getSeriesEpisodes(73739, 2);

// Or get the episodes directly from a "Series" object
$series = TVDB::getSeries(73739);

$episodes = $series->getEpisodes(2);

Example 1 - iterating over all episodes:

$page = 1;

do {
    $episodes = TVDB::getSeriesEpisodes(73739, $page);

    echo "Page $page has " . count($episodes) . " episodes. <br />";

} while($episodes->hasNextPage());

 * Output:
 * Page 1 has 100 episodes.
 * Page 2 has 49 episodes.

Example 2:

$episodes = TVDB::getSeriesEpisodes(73739);

foreach($episodes as $episode) {
    echo $episode->name . '<br />';

Getting individual episodes

 * Retrieve the episode with ID 127131
 * .. returns an "Episode" object
$episode = TVDB::getEpisode(127131);

echo $episode->name; //  "Pilot (1)"

Getting your TVDB JWT token

Sometimes it can be useful to retrieve your TVDB JWT token (for testing the API, for example).

echo TVDB::getToken();



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