You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.1 KiB

import ApiRequestManager from "./ApiRequestManager";
import * as Schema from "./schema";
export default class TheMovieDb
{
/**
* The APi request manager
*/
protected requestManager!: ApiRequestManager;
/**
* Create a new TheMovieDB API instance
*/
public constructor(apiKey: string) {
this.requestManager = new ApiRequestManager(apiKey);
}
/**
* Get the API configuration details
*/
public async configuration() {
return await this.requestManager.get("/configuration");
}
/**
* Search for a movie
*/
public async searchMovie(query: string, year?: number, page?: number) {
return await this.requestManager.get<Schema.IPaginatedResponse<Schema.IMovieSearchResult>>("/search/movie", { query, year });
}
/**
* Get the details of a movie
*/
public async movie(id: number) {
return await this.requestManager.get<Schema.IMovieDetails>(`/movie/${id}`);
}
/**
* Find a movie given an external ID
*/
public async findMovie(id: string, externalSource: Schema.ExternalSource) {
return await this.requestManager.get<Schema.IFindResult>(`/find/${id}`, { external_source: externalSource });
}
}