TMDB (The Movie DataBase) API Wrapper for Delphi - Written by Jerry Dodge
This library is currently in active develoment, and not guaranteed for use at this time.
This library is written in Delphi 10.4. While it should work fine on other version of Delphi, there are no guarantees. The older the Delphi version, the less likely this library will be compatible.
https://developer.themoviedb.org/reference/intro/getting-started
You are required to obtain your own API key from TMDB.
You are able to login to a TMDB user account in the API through a variety of authentication methods:
- Embedded Browser - Opens the TMDB auth page dynamically and feeds a callback URL
- Credentials - Provide username and password directly
- Guest- Login as a guest with a guest sesion ID
The goal of this library is to have 3 layers of wrappers - Raw JSON API (in JD.TMDB.API.pas
), Interface/Implementation Translation (in JD.TMDB.Intf.pas
and JD.TMDB.Impl.pas
), and Delphi Component (in JD.TMDB.pas
).
At the heart of this project is the unit JD.TMDB.API.pas
which wraps the entire TMDB API. This is encapsulated in the TTMDBAPI
component. This provides raw access to all possible services / requests, and returns raw JSON data via ISuperObject
or ISuperArray
, parts of the X-SuperObject
JSON library for Delphi.
A second-level wrapper is being written which further adds an interface-oriented layer around the API. All possible services and objects are implemented via interfaces in JD.TMDB.Intf.pas
, and implemented in JD.TMDB.Impl.pas
. The base API interface is ITMDBClient
.
A final third-level wrapper is a component you can install into the Delphi IDE. It is reponsible for everything necessary, including pre-fetching configuration data, API authentication, user authentication, language and locale options, etc. This will ultimately be the main component to integrate your Delphi project with the TMDB API.
There is a test application to demonstrate the usage of the TMDB API wrapper. Note that this app is in very active development at this time, and is far from ready. However, it does feature a few major features, such as:
- User Authentication
- Search (All media types)
- Movie Detail
- Genres (Movie and TV)
- Certifications (Movie and TV)
The test applications uses controls from JDLib, a separate repository of mine.
The test application uses the TChromeTabs
control.
IMPORTANT: In order to use any of the "Watch Providers" features, you must attribute "JustWatch" in your solution.
- Obtain an API key of your own
- Create an instance of the
TTMDB
component. This may be installed in your component palette. - Assign your key(s) via the component's
APIKey
and/orAccessToken
properties.- NOTE: Another property
AuthMethod
controls which key gets used.
- NOTE: Another property
- You're ready to use a majority of the API functions now via the
Client
property.- Access each possible namespace with its corresponding function, such as
Search
,Movies
,Account
, etc.
- Access each possible namespace with its corresponding function, such as
- You may additionally login using
LoginState
in runtime to access account-related functionality.
var
TMDB: TTMDB;
begin
TMDB:= TTMDB.Create(nil);
//EITHER...
TMDB.APIKey:= YOUR_TMDB_API_KEY;
TMDB.AuthMethod:= amAPIKey;
//...OR...
TMDB.AccessToken:= YOUR_TMDB_ACCESS_TOKEN;
TMDB.AuthMethod:= amAccessToken;
//Now you can access most of the library / API...
var Results: ITMDBMoviePage;
Result:= TMDB.Client.Search.Movies('Star Wars', 'en-US');
var Movie: ITMDBMovieDetail;
Movie:= TMDB.Client.Movies.GetDetail(11, 'en-US');
var Credits: ITMDBCredits;
Credits:= TMDB.Client.Movies.GetCredits(11);
end;