PHPackages                             jmartin/tmdb-php-api - 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. jmartin/tmdb-php-api

ActiveLibrary[API Development](/categories/api)

jmartin/tmdb-php-api
====================

A PHP 5.3 library for scraping TMDb.

071PHP

Since Oct 16Pushed 11y ago2 watchersCompare

[ Source](https://github.com/jmartin82/TMDb-PHP-API)[ Packagist](https://packagist.org/packages/jmartin/tmdb-php-api)[ RSS](/packages/jmartin-tmdb-php-api/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

TMDb PHP API
============

[](#tmdb-php-api)

Why this class
--------------

[](#why-this-class)

This class has been started with the old API version (2.1) because of the lack of a general and recent php class for TMDb at the time. The second reason why this class is made is very simple: I love the work they do at [TMDb](http://themoviedb.org). They provide a great API so everyone can use their database to make cool applications. Now there's a new API v3 and it's supported too. The old version you can find on a [different branch at github](https://github.com/glamorous/TMDb-PHP-API/tree/apiv2).

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

[](#requirements)

- PHP 5.2.x or higher
- cURL
- TMDb API-key

Available methods
-----------------

[](#available-methods)

All methods are listed here, for use, look into the code, everything is documentated. Optional parameters are between brackets \[\]. Also look into the TMDb-documentation for better unstanding of the possible methods.

### Collection

[](#collection)

- getCollection($id, \[$lang\])

### Company

[](#company)

- searchCompany($query, \[$page\])
- getMoviesByCompany($id, \[$page\], \[$lang\])

### Genres

[](#genres)

- getGenres(\[$lang\])
- getMoviesByGenre($id, \[$page\], \[$lang\])

### Movies &amp; TV Series

[](#movies--tv-series)

- getTopRated(\[$page\], \[$type\], \[$lang\])
- getPopular(\[$page\], \[$type\], \[$lang\])

### Movies

[](#movies)

- searchMovie($query, \[$page\], \[$adult\], \[$lang\])
- getMovie($id, \[$lang\])
- getMovieCast($id)
- getMovieImages($id, \[$lang\])
- getMovieKeywords($id)
- getMovieReleases($id)
- getMovieTitles($id, \[$country\])
- getMovieTrailers($id, \[$lang\])
- getMovieTranslations($id)
- getMoviesByCompany($id, \[$page\], \[$lang\])
- getMoviesByGenre($id, \[$page\], \[$lang\])
- getLatestMovie()
- getUpcomingMovies(\[$page\], \[$lang\])
- getNowPlayingMovies(\[$page\], \[$lang\])
- getSimilarMovies($id, \[$page\], \[$lang\])
- getChangedMovies(\[$page\], \[$start\_date\], \[$end\_date\])
- getMovieChanges($id)

### TV Series

[](#tv-series)

- searchTV($query, \[$page\], \[$air\_date\_year\], \[$lang\])
- getTV\[$id, \[$lang\])
- getTVSeason\[$id, $season\_id, \[$lang\])
- getTVSeasonCredits\[$id, $season\_id, \[$lang\])
- getTVSeasonImages\[$id, $season\_id, \[$lang\])
- getTVEpisode\[$id, $episode\_id, \[$lang\])
- getTVEpisodeCredits\[$id, $episode\_id, \[$lang\])
- getTVEpisodeImages\[$id, $episode\_id, \[$lang\])

### Persons

[](#persons)

- searchPerson($query, \[$page\], \[$adult\])
- getPerson($id)
- getPersonCredits($id, \[$type\], \[$lang\])
- getPersonImages($id)
- getChangedPersons(\[$page\], \[$start\_date\], \[$end\_date\])
- getPersonChanges($id)

### Authentication

[](#authentication)

- getAuthToken()
- getAuthSession($token)
- setAuthSession($id)

### Account

[](#account)

- addFavoriteMovie($account\_id, $session\_id, $movie\_id, TRUE)
- addMovieRating($session\_id, $movie\_id, $value)
- addMovieToWatchlist($account\_id, $session\_id, $movie\_id)
- getAccount($session\_id)
- getAccountFavoriteMovies($account\_id, $session\_id, \[$page\], \[$lang\])
- getAccountRatedMovies($account\_id, $session\_id, \[$page\], \[$lang\])
- getAccountWatchlistMovies($account\_id, $session\_id, \[$page\], \[$lang\])

### Misc

[](#misc)

- getAvailableImageSizes($imagetype)
- getConfig()
- getConfiguration()
- getImageUrl($filepath, $imagetype, $size)
- getLang()
- setLang($languague)
- getVersion($uri)

How to use
----------

[](#how-to-use)

### Initialize the class

[](#initialize-the-class)

```

```

### Authentication

[](#authentication-1)

It's important to read the TMDb-documentation about this one. The necessary methods are available to retrieve a valid token and session\_id (more information on the [TMDb Knowledge Base](http://help.themoviedb.org/kb/api/user-authentication))

```

```

Then you have to redirect the user to TMDb-website with the `Authentication-Callback` find in the `$token`-variable received from the method `getAuthToken` so the user can autorise your app.

```

```

Store the session\_id securely for that particular user and use it for authenticated calls.

IF you have saved the session\_id, you can use it (optional) set it with every authenticated request for every user or you can set it globally with the method `setAuthSession`.

### Configuration

[](#configuration)

The configuration is something new in API v3. It's used to retrieve information from TMDb so you only have to request it once. It's your task to save it (or cache) and sometimes retrieve a new version.

```

```

### Images

[](#images)

The way to retrieve images is a little bit different then before. You retrieve filepaths in you request. To parse an url you need to use the configuration and some extra methods.

```

```

There are now 3 formats available for the images: `TMDb::IMAGE_BACKDROP`, `TMDb::IMAGE_POSTER`, `TMDb::IMAGE_PROFILE`. To retrieve all available image size for a particular imagetype you can use the method `getAvailableImageSizes`.

```

```

### Versions

[](#versions)

With the new version of the API (v3) there aren't specific methods to track the state of a movie or a person. Like [TMDb suggested](http://help.themoviedb.org/kb/api/content-versioning) you can now use the header information, especially the ETag to check the state of the content of a specific method.

```

```

### HTTPS / SSL

[](#https--ssl)

With the new version of the API (v3) there's support for SSL. This class supports working with `https` too.

```

```

Issues/Bugs
-----------

[](#issuesbugs)

It's always possible to find some issues. If you find one, please inform us with the issue tracker on [github](http://github.com/glamorous/TMDb-PHP-API/issues). Please don't use this to ask question how to use this class. It's straight forward and easy to understand for everyone with a basic knowledge of PHP.

Changelog
---------

[](#changelog)

**TMDb 1.6.1 - 20/11/2013**

- \[feature\] New method for retrieving movie credits: `getMovieCredits`

**TMDb 1.6.0 - 05/11/2013**

- \[improvement\] Updated method for retreiving top rated content. Now supports a type (movie or tv): `getTopRated`
- \[improvement\] Updated method for retreiving popular content. Now supports a type (movie or tv): `getPopular`
- \[improvement\] Updated method for retreiving a person's credits. Now supports a type (combined, movie or tv): `getPersonCredits`
- \[feature\] New method for searching TV shows: `searchTV`
- \[feature\] New method for retrieving a TV show: `getTV`
- \[feature\] New method for retrieving a TV show season: `getTVSeason`
- \[feature\] New method for retrieving a TV show season credits: `getTVSeasonCredits`
- \[feature\] New method for retrieving a TV show season images: `getTVSeasonImages`
- \[feature\] New method for retrieving a TV show episode: `getTVEpisode`
- \[feature\] New method for retrieving a TV show episode credits: `getTVEpisodeCredits`
- \[feature\] New method for retrieving a TV show episode images: `getTVEpisodeImages`

**TMDb 1.5.2 - 09/04/2013**

- \[feature\] Added a request limitation handling with a retry mechanism. Thanks to the github user [betonme](https://github.com/betonme). Closed issue [\#17](https://github.com/glamorous/TMDb-PHP-API/issues/17).

**TMDb 1.5.1 - 16/11/2012**

- \[bug\] getPersonCredits wasn't working the correct way. Thanks to the github user [caa007](https://github.com/caa007). Closed issue [\#11](https://github.com/glamorous/TMDb-PHP-API/issues/11).

**TMDb 1.5.0 - 16/11/2012**

- \[feature\] Support for SSL

**TMDb 1.4.0 - 11/10/2012**

- \[feature\] New method for retrieving a movie changes: `getMovieChanges`
- \[feature\] New method for retrieving all changed movies: `getChangedMovies`
- \[feature\] New method for retrieving a person changes: `getPersonChanges`
- \[feature\] New method for retrieving all changed persons: `getChangedPersons`

**TMDb 1.3.0 - 22/08/2012**

- \[feature\] Get ETag from a method to keep track of state of content, for more information go to [TMDb kb-article](http://help.themoviedb.org/kb/api/content-versioning)

**TMDb 1.2.0 - 21/08/2012**

- \[bug\]\[feature\] It wasn't possible to use some methods without a language parameter. Now you can pass `FALSE` to it to retrieve all the results without thinking about any language.

**TMDb 1.1.1 - 20/08/2012**

- \[bug\] Deleted some debugging content

**TMDb 1.1.0 - 12/08/2012**

- \[feature\] New method for retrieving movie trailers: `getMovieTrailers` It was being forgotten in the first release for the new API (Closed issue #10)

**TMDb 1.0.2 - 07/08/2012**

- \[bug\] On some recent servers the `&` were replaced with `&amp;` so a `POST` to an old Tomcat java server wouldn't be properly handled. (Closed issue #9)

**TMDb 1.0.1 - 01/08/2012**

- \[improvement\] `addMovieRating` works better now, whatever you pass trough, it's been casted to `0` or a decent float.

**TMDb 1.0.0 - 30/07/2012**

- The class works now only with API v3.
- All available methods from API v3 are supported by the API
- Old changelog (API v2) is available at [github](https://github.com/glamorous/TMDb-PHP-API/tree/apiv2)

Handle Errors
-------------

[](#handle-errors)

This class throws an TMDbException when an error is in the class is made by the CURL request or if there's a problem with the TMDb-API).

License
-------

[](#license)

This plugin has a [BSD License](http://www.opensource.org/licenses/bsd-license.php). You can find the license in license.txt that is included with class-package

[![githalytics.com alpha](https://camo.githubusercontent.com/974bedfb752dd53fda14679a6945c9c448d7fb6bcfcc3cbf7ea9849353d3d237/68747470733a2f2f637275656c2d6361726c6f74612e7061676f6461626f782e636f6d2f6638313166636634363337353639353931306136643539383764313561353566)](https://camo.githubusercontent.com/974bedfb752dd53fda14679a6945c9c448d7fb6bcfcc3cbf7ea9849353d3d237/68747470733a2f2f637275656c2d6361726c6f74612e7061676f6461626f782e636f6d2f6638313166636634363337353639353931306136643539383764313561353566)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.4% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2aacc90e51565217e93f5a55a420470a6c801585348a3f77f6278301f526cbfd?d=identicon)[muertet](/maintainers/muertet)

---

Top Contributors

[![glamorous](https://avatars.githubusercontent.com/u/62723?v=4)](https://github.com/glamorous "glamorous (38 commits)")[![jmartin82](https://avatars.githubusercontent.com/u/152270?v=4)](https://github.com/jmartin82 "jmartin82 (6 commits)")[![betonme](https://avatars.githubusercontent.com/u/942288?v=4)](https://github.com/betonme "betonme (2 commits)")[![lordotter](https://avatars.githubusercontent.com/u/1105342?v=4)](https://github.com/lordotter "lordotter (2 commits)")[![mihaeu](https://avatars.githubusercontent.com/u/2168701?v=4)](https://github.com/mihaeu "mihaeu (2 commits)")[![turanct](https://avatars.githubusercontent.com/u/1728360?v=4)](https://github.com/turanct "turanct (1 commits)")[![muertet](https://avatars.githubusercontent.com/u/1410120?v=4)](https://github.com/muertet "muertet (1 commits)")[![Big-Shark](https://avatars.githubusercontent.com/u/646054?v=4)](https://github.com/Big-Shark "Big-Shark (1 commits)")[![ndsmyter](https://avatars.githubusercontent.com/u/648669?v=4)](https://github.com/ndsmyter "ndsmyter (1 commits)")

### Embed Badge

![Health badge](/badges/jmartin-tmdb-php-api/health.svg)

```
[![Health](https://phpackages.com/badges/jmartin-tmdb-php-api/health.svg)](https://phpackages.com/packages/jmartin-tmdb-php-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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