TheMovieDbWrapper 1.3.1
dotnet add package TheMovieDbWrapper --version 1.3.1
NuGet\Install-Package TheMovieDbWrapper -Version 1.3.1
<PackageReference Include="TheMovieDbWrapper" Version="1.3.1" />
paket add TheMovieDbWrapper --version 1.3.1
#r "nuget: TheMovieDbWrapper, 1.3.1"
// Install TheMovieDbWrapper as a Cake Addin #addin nuget:?package=TheMovieDbWrapper&version=1.3.1 // Install TheMovieDbWrapper as a Cake Tool #tool nuget:?package=TheMovieDbWrapper&version=1.3.1
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
- The recommened method of installation is to use the Nuget package manager for TheMovieDbWrapper.
- Alternatively, download the latest release from our Github repo.
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. |
IApiDiscoverRequest |
Api for discovering movies. |
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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 13.0.1)
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.3.1 | 1,488 | 8/17/2022 |
1.3.0 | 888 | 8/16/2022 |
1.2.0 | 955 | 6/27/2022 |
1.1.0 | 889 | 12/9/2021 |
1.0.1 | 914 | 10/28/2021 |
1.0.0 | 794 | 10/27/2021 |
0.9.0 | 1,126 | 10/28/2020 |
0.8.2 | 2,173 | 2/26/2017 |
0.8.1 | 1,616 | 12/11/2016 |
0.8.0 | 1,610 | 11/27/2016 |
0.7.2 | 1,436 | 11/26/2016 |
0.7.1 | 1,619 | 7/10/2016 |
0.7.0 | 1,568 | 7/10/2016 |
0.6.0 | 1,513 | 7/6/2016 |
0.5.1 | 1,759 | 6/16/2016 |
0.5.0 | 1,527 | 6/1/2016 |
0.4.0 | 1,597 | 5/30/2016 |
0.3.0 | 1,653 | 4/9/2016 |
0.2.0 | 1,499 | 4/6/2016 |
0.1.0 | 1,537 | 3/27/2016 |
v1.3.x adds support for movie recommendations and movie discovery. See v1.0.x release notes for a minor breaking change from releases < 1.0.