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.

Installation

Nuget Stats for TheMovieDbWrapper

Nuget Install Options

Option 1: Install from Visual Studio

In the Nuget package manager UI, search for: TheMovieDbWrapper and then click the install button.

Option 2: Install from the Nuget Package Manger CLI

PM> Install-Package TheMovieDbWrapper

Option 3: Install with the .NET CLI

> dotnet add package 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 must 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 a basic Interface providing a constraint for all our request interfaces/classes used in the factory. For example, to retrieve the API for movies:

// as the factory returns a Lazy<T> instance, just grab the Value from 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 Api for retrieving TheMovieDb.org configuration information.
IApiMovieRequest Api for retrieving Movies.
IApiMovieRatingRequest Api for retrieving movie ratings.
IApiTVShowRequest Api for retrieving TV shows.
IApiGenreRequest Api for retrieving Movie and TV genres.
IApiCompanyRequest Api for retrieving production companies.
IApiProfessionRequest Api for retrieving Movie/TV industry specific professions.
IApiPeopleRequest Api for retrieving 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, including the following:

Member Type Description
Results IReadOnlyList<T> The list of results from the search.
PageNumber int The current page number of the search result.
TotalPages int The total number of pages found from the search result.
TotalResults int The total number of results from the search.
ToString() string Returns Page x of y (z total results).
Error ApiError Contains specific error information if an error was encountered during the API call to TheMovieDb.org.
RateLimit ApiRateLimit 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.

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 previously seen in the ApiSearchResponse:

Member Type Description
Item T The item returned from the API call, where T is the specific type returned from the query, such as MovieInfo, Movie, MovieCredit, etc..
ToString() string Typically returns a well formatted string representation of T.
Error ApiError If an error was encountered, the Error property will provide specific error information about the API call to TheMovieDb.org.
RateLimit ApiRateLimit 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.

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 145 10/28/2021
1.0.0 89 10/27/2021
0.9.0 339 10/28/2020
0.8.2 1,328 2/26/2017
0.8.1 784 12/11/2016
0.8.0 747 11/27/2016
0.7.2 620 11/26/2016
0.7.1 732 7/10/2016
0.7.0 674 7/10/2016
0.6.0 646 7/6/2016
0.5.1 641 6/16/2016
0.5.0 656 6/1/2016
0.4.0 741 5/30/2016
0.3.0 665 4/9/2016
0.2.0 636 4/6/2016
0.1.0 663 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.