TheMovieDbWrapper 1.0.1

Install-Package TheMovieDbWrapper -Version 1.0.1
dotnet add package TheMovieDbWrapper --version 1.0.1
<PackageReference Include="TheMovieDbWrapper" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TheMovieDbWrapper --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TheMovieDbWrapper, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install TheMovieDbWrapper as a Cake Addin
#addin nuget:?package=TheMovieDbWrapper&version=1.0.1

// Install TheMovieDbWrapper as a Cake Tool
#tool nuget:?package=TheMovieDbWrapper&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

TheMovieDb.org Wrapper

TheMovieDbWrapper is a C# wrapper for TheMovieDb.org API providing cross-platform support for Xamarin, iOS, Android, and all flavors of .NET.

A nuget package is available directly through Visual Studio: https://www.nuget.org/packages/TheMovieDbWrapper/

v1.0 Breaking Changes 🤮

The v1.0 release on 2021-10-27 introduces a minor breaking change when 
registering your TheMovieDb.org credentials with our MovieDbFactory.
  • IMovieDbSettings has been completely eliminated and simplifies the process of registering your credentials.
    • You no longer need to create a concrete implementation of the interface when registering your credentials.
    • You no longer need to provide TheMovieDb.org api url.
  • Your TheMovieDb.org credentials now use their updated authentication using a Bearer Token.
    • Your Bearer token is found in your TheMovieDb.org account page, under the API section: "API Read Access Token (v4 auth)".
    • Note: This token IS NOT the same as the old "API Key (v3 auth)".

Common API Requests

The current release supports common requests for movie, tv, and other information, such as:

  • TheMovieDb.org configuration
  • Movies 🎥
  • Movie Ratings
  • TV Shows 📺
  • Movie and TV Genres
  • Movie/TV Industry Specific Professions
  • Production Companies
  • People such as Actors, Actresses, Directors, etc...

Basic Usage

The MovieDbFactory class is the single entry point for retrieving information from TheMovieDb.org API. Before making any requests, you simply need to register your TheMovieDb.org Bearer Token with our MovieDbFactory class:

// your bearer token can be found on TheMovieDb.org's website under your account settings
// https://www.themoviedb.org/settings/api
string bearerToken = "your-bearer-token-from-TheMovieDb.org";

// RegisterSettings only needs to be called one time when your application starts-up.
MovieDbFactory.RegisterSettings( bearerToken );

Once your Bearer Token has been registered, you will then use the .Create<T>() method to get a specific API request type. The full signature of the method is:

Lazy<T> MovieDbFactory.Create<T>() where T : IApiRequest

The IApiRequest is simply an Interface providing a constraint for all our request interfaces/classes used in the factory. For example, to retrieve the API about movies:

// as the factory returns a Lazy<T> instance, simply grab the Value out of the Lazy<T>
// and assign to a local variable.
var movieApi = MovieDbFactory.Create<IApiMovieRequest>().Value;

API Interfaces

The following interfaces are used with the MovieDbFactory.Create<T>() method:

IApiRequest Description
IApiConfigurationRequest Provides access for retrieving TheMovieDb.org configuration information.
IApiMovieRequest Provides access for retrieving information about Movies.
IApiMovieRatingRequest Provides access for retrieving movie rating information.
IApiTVShowRequest Provides access for retrieving information about TV shows.
IApiGenreRequest Provides access for retrieving Movie and TV genres.
IApiCompanyRequest Provides access for retrieving production company information.
IApiProfessionRequest Provides access for retrieving information about Movie/TV industry specific professions.
IApiPeopleRequest Provides access for retrieving information about People.

More Examples

Search by Movie Title

string bearerToken = "your-bearer-token-from-TheMovieDb.org";

// RegisterSettings only needs to be called one time when your application starts-up.
MovieDbFactory.RegisterSettings( bearerToken );

var movieApi = MovieDbFactory.Create<IApiMovieRequest>().Value;

ApiSearchResponse<MovieInfo> response = await movieApi.SearchByTitleAsync( "Star Trek" );

foreach( MovieInfo info in response.Results )
{
    Console.WriteLine( $"{info.Title} ({info.ReleaseDate}): {info.Overview}" );
}

The above example returns an ApiSearchResponse<T> which provides rich information about the results of your search:

Member Description
IReadOnlyList<T> Results The list of results from the search.
int PageNumber The current page number of the search result.
int TotalPages The total number of pages found from the search result.
int TotalResults The total number of results from the search.
ToString() returns "Page x of y (z total results)".
ApiError Error Contains specific error information if an error was encountered during the API call to TheMovieDb.org.
ApiRateLimit RateLimit Contains the current rate limits from your most recent API call to TheMovieDb.org. Note: TheMovieDb.org has removed all rate limits as of December of 2019.
nevermind_this_sad_little_nobr nothing to see here

Find Movie By Id

string bearerToken = "your-bearer-token-from-TheMovieDb.org";

// RegisterSettings only needs to be called one time when your application starts-up.
MovieDbFactory.RegisterSettings( bearerToken );

var movieApi = MovieDbFactory.Create<IApiMovieRequest>().Value;

ApiQueryResponse<Movie> response = await movieApi.FindByIdAsync( 140607 );

Movie movie = response.Item;

Console.WriteLine( movie.Id );
Console.WriteLine( movie.Title );
Console.WriteLine( movie.Tagline );
Console.WriteLine( movie.ReleaseDate );
Console.WriteLine( movie.Budget );

The above query returns an ApiQueryResponse<T> which returns a single result as well as some common information seen in the ApiSearchResponse in the prior example:

Member Description
T Item The item returned from the API call, where T is the specific query such as MovieInfo, Movie, MovieCredit, etc..
ToString() Typically returns a well formatted string of T.
ApiError Error If an error was encountered, this will provide specific error information from the API call to TheMovieDb.org.
ApiRateLimit RateLimit Contains the current rate limits from your most recent API call to TheMovieDb.org. Note: TheMovieDb.org has removed all rate limits as of December of 2019.
nevermind_this_sad_little_nobr nothing to see here

Paging a search result

string bearerToken = "your-bearer-token-from-TheMovieDb.org";

// RegisterSettings only needs to be called one time when your application starts-up.
MovieDbFactory.RegisterSettings( bearerToken );

var movieApi = MovieDbFactory.Create<IApiMovieRequest>().Value;

int pageNumber = 1;
int totalPages;
do
{
    ApiSearchResponse<MovieInfo> response = await movieApi.SearchByTitleAsync( "Harry", pageNumber );

    // alternatively, just call response.ToString() which will provide the same paged information format as below:
    Console.WriteLine( $"Page {response.PageNumber} of {response.TotalPages} ({response.TotalResults} total results)" );

    foreach( MovieInfo info in response.Results )
    {
        Console.WriteLine( $"{info.Title} ({info.ReleaseDate}): {info.Overview}" );
    }

    totalPages = response.TotalPages;
} while( pageNumber++ < totalPages );

Do you have a comprehensive list of examples?

  • The API we've exposed should be fairly straight forward. All interfaces, classes, methods, properties, etc... have full intellisense support. If you need more detailed examples, just ask!
  • You may also browse the suite of integration tests covering all usages of the API.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 0 10/28/2021
1.0.0 0 10/27/2021
0.9.0 305 10/28/2020
0.8.2 1,299 2/26/2017
0.8.1 755 12/11/2016
0.8.0 708 11/27/2016
0.7.2 586 11/26/2016
0.7.1 703 7/10/2016
0.7.0 635 7/10/2016
0.6.0 617 7/6/2016
0.5.1 611 6/16/2016
0.5.0 627 6/1/2016
0.4.0 707 5/30/2016
0.3.0 631 4/9/2016
0.2.0 602 4/6/2016
0.1.0 629 3/27/2016

v1.0.x is a full upgrade to net5.0. This release now uses TheMovieDb.org's Bearer Token for authentication; this change introduces a minor breaking change from the prior releases. See the github ReadMe for full details as you will need to update your implmentation to provide the new Bearer Token with the RegisterSettings method.