PHPackages                             pvguerra/laravel-trakt - 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. pvguerra/laravel-trakt

ActiveLibrary[API Development](/categories/api)

pvguerra/laravel-trakt
======================

Integrate Laravel with Trakt API

v2.0.0(10mo ago)337MITPHPPHP ^8.3||^8.4CI passing

Since May 1Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/pvguerra/laravel-trakt)[ Packagist](https://packagist.org/packages/pvguerra/laravel-trakt)[ Docs](https://github.com/pvguerra/laravel-trakt)[ RSS](/packages/pvguerra-laravel-trakt/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (10)Versions (6)Used By (0)

Laravel Trakt
=============

[](#laravel-trakt)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9ec93a69fecd761277b4e0e813a96ae01ad2cda61df5eff87774ccece4d5909a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70766775657272612f6c61726176656c2d7472616b742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pvguerra/laravel-trakt)[![Tests](https://camo.githubusercontent.com/53f2923ab44b91528d79ba3914df6b11461de7bab7bf3db98e8277cee88da8f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70766775657272612f6c61726176656c2d7472616b742f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265266576656e743d70757368)](https://github.com/pvguerra/laravel-trakt/actions/workflows/ci.yml)[![PHPStan](https://camo.githubusercontent.com/9251adc779997218c95e99dd73e2466ab544cf35d4220bf384d3e4321b6006fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70766775657272612f6c61726176656c2d7472616b742f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d5048505374616e2532304c35267374796c653d666c61742d737175617265)](https://github.com/pvguerra/laravel-trakt/actions/workflows/ci.yml)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/563d7205d6831de722bcea1f1b0d3cb3424a266dd60cd4c3f32713924a377b11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f70766775657272612f6c61726176656c2d7472616b742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pvguerra/laravel-trakt)[![Total Downloads](https://camo.githubusercontent.com/a6e3e563071a0e404bb9595e61116a5c44690d71d7934a949b7570c8b58d3cfa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70766775657272612f6c61726176656c2d7472616b742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pvguerra/laravel-trakt)

This package provides a convenient way to integrate the [Trakt.tv API](https://trakt.docs.apiary.io/) with your Laravel application.

The whole package was developed following the official [Trakt API Documentation](https://trakt.docs.apiary.io/).

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

[](#installation)

You can install the package via composer:

```
composer require pvguerra/laravel-trakt
```

You can publish the config file with:

```
php artisan vendor:publish --tag="trakt-config"
```

This will publish the `trakt.php` config file to your `config` directory:

```
// config/trakt.php

return [
    'api_url' => env('TRAKT_API_URL', 'https://api.trakt.tv'),
    'client_id' => env('TRAKT_CLIENT_ID'),
    'client_secret' => env('TRAKT_CLIENT_SECRET'),
    'redirect_url' => env('TRAKT_REDIRECT_URL'),
    'staging_api_url' => env('STAGING_TRAKT_API_URL', 'https://api-staging.trakt.tv'),
];
```

You should add your Trakt API credentials and redirect URI to your `.env` file:

```
TRAKT_CLIENT_ID=your-trakt-client-id
TRAKT_CLIENT_SECRET=your-trakt-client-secret
TRAKT_REDIRECT_URL=your-trakt-redirect-url
```

If you don't have a Trakt client ID, you'll need to [create a new API app](https://trakt.tv/oauth/applications/new).

Usage
-----

[](#usage)

This package provides a fluent interface to interact with the Trakt API. You can either use the `Trakt` facade or dependency injection to access the client.

Most methods return a `Illuminate\Http\Client\Response` object. You can call `->json()` or `->object()` on the response to get the data.

Here is a list of available classes you can use:

- `TraktCalendar`
- `TraktCertification`
- `TraktCheckIn`
- `TraktCountry`
- `TraktEpisode`
- `TraktGenre`
- `TraktLanguage`
- `TraktList`
- `TraktMovie`
- `TraktNetwork`
- `TraktPerson`
- `TraktRecommendation`
- `TraktSearch`
- `TraktSeason`
- `TraktShow`
- `TraktSync`
- `TraktUser`

### Authentication

[](#authentication)

Some endpoints require authentication. This package does not handle the OAuth2 flow for you, but it's easy to integrate with [Laravel Socialite](https://laravel.com/docs/socialite) and the [Trakt Socialite Provider](https://socialiteproviders.com/Trakt/).

#### Using with Laravel Socialite

[](#using-with-laravel-socialite)

```
use Laravel\Socialite\Facades\Socialite;

public function redirect()
{
    return Socialite::driver('trakt')->redirect();
}

// Receiving the callback from the provider after authentication.
public function callback()
{
    $socialiteUser = Socialite::driver('trakt')->user();

    // Store the token in your database
    $user = auth()->user();
    $user->trakt_token = $socialiteUser->token;
    $user->trakt_id = $socialiteUser->id;
    $user->save();

    return redirect()->route('dashboard');
}
```

#### Using the token

[](#using-the-token)

Once you have an access token, you can set it on the client:

```
use Pvguerra\LaravelTrakt\Facades\Trakt;

// Using the facade
Trakt::setToken('your-access-token');

// Now you can make authenticated requests
$history = Trakt::sync()->history();

// Or using dependency injection
use Pvguerra\LaravelTrakt\TraktUser;

$user = auth()->user();
$traktUser = new TraktUser($user->trakt_token);
return $traktUser->collection($user->trakt_id, 'movies');
```

### Examples

[](#examples)

#### Movies

[](#movies)

Get a single movie:

```
use Pvguerra\LaravelTrakt\Facades\Trakt;

$movie = Trakt::movie()->get('the-batman-2022');
```

Get popular movies:

```
use Pvguerra\LaravelTrakt\Facades\Trakt;

$popularMovies = Trakt::movie()->popular();
```

#### TV Shows

[](#tv-shows)

Get a single show:

```
use Pvguerra\LaravelTrakt\Facades\Trakt;

$show = Trakt::show()->get('game-of-thrones');
```

Get trending shows:

```
use Pvguerra\LaravelTrakt\Facades\Trakt;

$trendingShows = Trakt::show()->trending();
```

#### Search

[](#search)

Search for a movie, show, person, etc.

```
use Pvguerra\LaravelTrakt\Facades\Trakt;

$results = Trakt::search()->query('batman', 'movie');
```

#### User

[](#user)

Get a user's profile (requires authentication):

```
use Pvguerra\LaravelTrakt\Facades\Trakt;

Trakt::setToken('user-access-token');
$profile = Trakt::user()->profile('me');
```

Get a user's watched history (requires authentication):

```
use Pvguerra\LaravelTrakt\Facades\Trakt;

Trakt::setToken('user-access-token');
$history = Trakt::user()->history('me', 'movies');
```

#### Calendar

[](#calendar)

Get all shows airing in the next 7 days:

```
use Pvguerra\LaravelTrakt\Facades\Trakt;

$calendar = Trakt::calendar()->myShows();
```

Quality Assurance
-----------------

[](#quality-assurance)

### Testing

[](#testing)

This package uses [Pest](https://pestphp.com/) for testing. Run the tests with:

```
composer test
```

### Static Analysis

[](#static-analysis)

This package uses [PHPStan](https://phpstan.org/) level 5 for static code analysis. Run the analysis with:

```
composer analyse
```

### CI/CD

[](#cicd)

This package uses GitHub Actions to run tests and static analysis on each pull request and push to the main branch. The CI pipeline ensures that:

1. All tests pass
2. PHPStan analysis passes with no errors
3. Branch protection rules prevent merging to main if tests or analysis fail

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

[](#requirements)

- PHP 8.1 or higher
- Laravel 9.0 or higher

Compatibility
-------------

[](#compatibility)

LaravelPHP9.x8.1, 8.210.x8.1, 8.2, 8.3Documentation
-------------

[](#documentation)

Full documentation will be available soon.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

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

Pull requests are welcome!

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Paulo Guerra](https://github.com/pvguerra)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance54

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 94.6% of commits — single point of failure

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

Total

4

Last Release

315d ago

Major Versions

v1.2.0 → v2.0.02025-07-01

PHP version history (3 changes)v1.0.0PHP ^8.1

v1.1.0PHP ^8.3

v1.2.0PHP ^8.3||^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf5f7308b206002e8dbc2fc2d0551bf0ba1a76b2add7acac9226dc8f62bb99a2?d=identicon)[pvguerra](/maintainers/pvguerra)

---

Top Contributors

[![pvguerra](https://avatars.githubusercontent.com/u/17501080?v=4)](https://github.com/pvguerra "pvguerra (88 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laraveltraktpvguerralaravel-trakt

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pvguerra-laravel-trakt/health.svg)

```
[![Health](https://phpackages.com/badges/pvguerra-laravel-trakt/health.svg)](https://phpackages.com/packages/pvguerra-laravel-trakt)
```

###  Alternatives

[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)

PHPackages © 2026

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