canihavesomecoffee / thetvdbapi
PHP implementation for the 4th version of the TheTVDb API.
Installs: 13 203
Dependents: 1
Suggesters: 0
Security: 0
Stars: 11
Watchers: 2
Forks: 8
Open Issues: 3
Requires
- php: >=7.4
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- phpdocumentor/reflection-docblock: ^5.3
- symfony/property-access: ^5.4|^6.0
- symfony/property-info: ^5.4|^6.0
- symfony/serializer: ^5.4|^6.0
Requires (Dev)
- phpunit/phpunit: ^9.0
- dev-master
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0.beta9
- 2.0.0.beta8
- 2.0.0.beta7
- 2.0.0.beta6
- 2.0.0.beta5
- 2.0.0.beta4
- 2.0.0.beta3
- 2.0.0.beta2
- 2.0.0.beta1
- 2.0.0.beta
- 1.3.0
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/composer/symfony/property-info-tw-5.4tw-6.0tw-7.0
- dev-dependabot/composer/symfony/property-access-tw-5.4tw-6.0tw-7.0
- dev-dependabot/composer/symfony/serializer-tw-5.4tw-6.0tw-7.0
This package is auto-updated.
Last update: 2024-11-18 05:17:36 UTC
README
This is an API client for the thetvdb.com website. It's using the 4th version of the theTVDb API. In order to be able to access this API you'll have to register on theTVDb first and obtain a project key.
API Key Registration
To use this PHP package, you need to request an API Key from the thetvdb.com website: https://thetvdb.com/dashboard/account/apikeys.
We have two models for API access, both that provide funding that allows us to continue running and improving the site. The first is our negotiated license model, which allows commercial companies to negotiate access with us. The second is a user-subscription model, which allows end users to access the API if they are subscribed. We reserve the right to change our interfaces, fees, or licensing terms at any point without notice.
To create an API key, create an account and visit the API keys page on your dashboard.
Installation
Install this package using composer:
$ composer require canihavesomecoffee/thetvdbapi
Documentation
The official API documentation can be found here: https://thetvdb.github.io/v4-api/.
For usage examples of the API, please refer to the examples' folder.
API-wide translations
You can pass a primary and secondary (fallback) language to the API constructor.
For example, if you want translations in Dutch, but a fallback to English if no Dutch translations exist, you can set this as follows:
$theTVDbAPI = new \CanIHaveSomeCoffee\TheTVDbAPI\TheTVDbAPI("nld", "eng");
By default, the primary language is set to English without a fallback language.
Authentication
$theTVDbAPI = new \CanIHaveSomeCoffee\TheTVDbAPI\TheTVDbAPI();
// Obtain a token. Optionally you can pass a user pin through as well.
$token = $theTVDbAPI->authentication()->login($apiKey);
// Set the token
$theTVDbAPI->setToken($token);
Routes
The TheTVDbAPI
offers access to the same routes that the API provides. A few usage examples are listed below:
Authentication
$theTVDbAPI->authentication()->login($apiKey);
// or in case it's a project with user-specific subscriptions
$theTVDbAPI->authentication()->login($apiKey, $pin);
Languages
$theTVDbAPI->languages()->all();
Episodes
$theTVDbAPI->episodes()->simple(6347388);
$theTVDbAPI->episodes()->extended(8366715);
$theTVDbAPI->episodes()->translations(8366715, "nld");
Series
$theTVDbAPI->series()->list();
$theTVDbAPI->series()->simple(280258);
$theTVDbAPI->series()->extended(280258);
$theTVDbAPI->series()->translate(280258);
$theTVDbAPI->series()->episodes(280258); // Paginated
$theTVDbAPI->series()->allEpisodes(280258); // All episodes, translated
Search
$theTVDbAPI->search()->search("Ideale");
$theTVDbAPI->search()->search("Ideale", ["year" => 2014]);
$theTVDbAPI->search()->search("Ideale Wereld", ["type" => "series"]);
Updates
Fetch a list of entities that have been recently updated:
$now = new DateTime();
$now->sub(new DateInterval("PT2H"));
$theTVDbAPI->updates()->query($now);
Some wrapper methods are available to restrict results:
$now = new DateTime();
$now->sub(new DateInterval("PT2H"));
$theTVDbAPI->updates()->fetchSerieUpdates($now);
$theTVDbAPI->updates()->fetchEpisodeUpdates($now);
Artwork
$theTVDbAPI->artwork()->simple(62001533);
$theTVDbAPI->artwork()->extended(62001533);
$theTVDbAPI->artwork()->statuses();
$theTVDbAPI->artwork()->types();
Contributing
While the aim is to provide a ready-to-use API, it's possible that things are missing or outdated. If you think something is missing, or you want to add something, feel free to open up an issue, or even better, make a Pull Request (PR) with a fix or improvement. The PR's will be gladly accepted in order to improve this client API.