chiiya/tmdb-php

PHP SDK for the TMDB API

Fund package maintenance!
chiiya

0.2.9 2023-06-20 21:58 UTC

README

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

PHP SDK for the TMDB API.

Looking for a Laravel package? Check out chiiya/laravel-tmdb.

Features

  • Complete coverage of all non-user related APIv3 endpoints (see here)
  • Strongly typed API responses

Installation

Install the package via composer:

composer require chiiya/tmdb-php

You will also need to create a v4 auth token for the TMDB API. You can find it under API > API Read Access Token in your TMDB account settings.

Usage

Create an authenticated client, then use a repository with the client you just created:

use Chiiya\Tmdb\Http\Client;
use Chiiya\Tmdb\Repositories\MovieRepository;

$client = Client::createAuthenticatedClient('your_v4_bearer_token');
$repository = new MovieRepository($client);
$movie = $repository->getMovie(550);
dump($movie->title); // "Fight Club"

$movie = $this->movies->getMovie(550, [
    new AppendToResponse([
        AppendToResponse::IMAGES,
        AppendToResponse::WATCH_PROVIDERS,
    ]),
]);
$movie->watch_providers['US']->flatrate[0]->provider_name;

$repository->getPopular();
$repository->getNowPlaying();
// ...

API Coverage

This package covers all non-account-related API endpoints. Specifically, this means that all V3 endpoints except for the following ones are supported:

  • Account > *
  • Authentication > *
  • Guest Sessions > *
  • Lists > *
  • * > Get Account States
  • * > Rate Movie/TV
  • * > Delete Rating
  • * > Get Lists

Similarly, no v4 API endpoints are covered.

Changelog

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

Contributing

Please see CONTRIBUTING for details.

License

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