Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More →
Socket
Sign inDemoInstall
Socket

@untidy/thetvdb

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@untidy/thetvdb - npm Package Compare versions

Comparing version 0.5.0 to 1.0.0

984

dist/index.d.ts

@@ -1,2 +0,982 @@

export { TheTVDBExtended } from './extended.js';
export { TheTVDB } from './main.js';
/// <reference types="node" resolution-mode="require"/>
import { URL } from 'node:url';
export interface Response<T> {
status: string;
data: T;
}
export interface ResponseLink<T> extends Response<T> {
links: {
prev: string | null;
self: string;
next: string | null;
total_items: number;
page_size: number;
};
}
export type Aliases = Record<'language' | 'name', string>;
export type CompanyRecord = Record<'studio' | 'network' | 'production' | 'distributor' | 'special_effects', Company[]>;
export type Entities = 'artwork' | 'award_nominees' | 'companies' | 'episodes' | 'lists' | 'people' | 'seasons' | 'series' | 'seriespeople' | 'artworktypes' | 'award_categories' | 'awards' | 'company_types' | 'content_ratings' | 'countries' | 'entity_types' | 'genres' | 'languages' | 'movies' | 'movie_genres' | 'movie_status' | 'peopletypes' | 'seasontypes' | 'sourcetypes' | 'tag_options' | 'tags' | 'translatedcharacters' | 'translatedcompanies' | 'translatedepisodes' | 'translatedlists' | 'translatedmovies' | 'translatedpeople' | 'translatedseasons' | 'translatedseries';
export interface IdName {
id: number;
name: string;
}
export interface Inspirations extends Record<'type' | 'type_name' | 'url', string> {
id: number;
}
export type NameImageYear = Record<'name' | 'image' | 'year', string>;
export interface ProductionCountries extends IdName {
country: string;
}
export interface RemoteId {
id: string;
type: number;
sourceName: string;
}
export interface SeasonType {
id: number;
name: string;
type: string;
alternateName: string | null;
}
export interface SharedProps {
id: number;
name: string | null;
image: string | null;
nameTranslations: string[] | null;
overviewTranslations: string[] | null;
}
export interface StatusHelper extends IdName {
keepUpdated: boolean;
recordType: string;
}
export interface StudiosHelper extends IdName {
parentStudio: number;
}
export interface TagOptions {
helpText: string | null;
id: number;
name: string;
tag: number;
tagName: string;
}
export interface Trailer {
id: number;
language: string;
name: string;
url: string;
runtime: number;
}
export interface TranslationHelper {
name: string;
overview: string;
language: string;
aliases?: string[];
isAlias?: boolean;
isPrimary?: boolean;
tagline?: string;
}
export interface Translations {
nameTranslations: TranslationHelper[];
overviewTranslations: TranslationHelper[];
aliases: string[] | null;
}
export interface Artwork {
height: number;
id: number;
image: string;
includesText: boolean;
language: string | null;
score: number;
thumbnail: string;
type: number;
width: number;
}
export interface ArtworkExtended extends Artwork {
thumbnailWidth: number;
thumbnailHeight: number;
updatedAt: number;
episodeId?: number;
seriesId?: number;
seriesPeopleId?: number;
movieId?: number;
status: IdName;
tagOptions: TagOptions[];
}
export interface ArtworkType {
height: number;
id: number;
imageFormat: string;
name: string;
recordType: string;
slug: string;
thumbHeight: number;
thumbWidth: number;
width: number;
}
export interface AwardCategory {
allowCoNominees: boolean;
award: IdName;
forMovies: boolean;
forSeries: boolean;
name: string;
id: number;
}
export interface AwardCategoryExtended extends AwardCategory {
nominees: Array<{
category: null;
character: null;
details: string;
episode: null;
id: number;
isWinner: boolean;
movie: Movie | null;
name: null;
series: Serie | null;
year: string;
}>;
}
export interface AwardExtended extends IdName {
categories: AwardCategory[];
}
export interface Character extends SharedProps {
peopleId: number;
seriesId: number | null;
series: NameImageYear | null;
movie: NameImageYear | null;
movieId: number | null;
episode?: NameImageYear | null;
episodeId: number | null;
type: number;
sort: number;
isFeatured: boolean;
url: string;
aliases: Aliases[] | null;
peopleType: string;
personName: string;
tagOptions: TagOptions[] | null;
personImgURL: string | null;
}
export interface Company extends Omit<SharedProps, 'image'> {
activeDate: string;
aliases: Aliases[];
companyType: CompanyType;
country: string;
inactiveDate: string;
primaryCompanyType: number;
slug: string;
parentCompany: {
id: number;
name: string;
relation: {
id: number;
typeName: string;
};
};
tagOptions: TagOptions[];
}
export interface CompanyType {
companyTypeId: number;
companyTypeName: string;
}
export type ContentRating = Record<'name' | 'country' | 'description' | 'contentType' | 'fullname', string> & Record<'id' | 'order', number>;
export type Country = Omit<Language, 'nativeName'>;
export interface Entity extends IdName {
hasSpecials: boolean;
}
export interface EpisodePage extends Omit<SharedProps, 'nameTranslations' | 'overviewTranslations'> {
aired: string;
finaleType: string | null;
imageType: null;
isMovie: number;
lastUpdated: string;
nameTranslations: null;
number: null;
overview: null;
overviewTranslations: null;
runtime: null;
seasons: null;
seasonNumber: null;
seriesId: number;
}
export interface Episode extends SharedProps {
aired: string;
airsAfterSeason?: number;
airsBeforeSeason?: number;
airsBeforeEpisode?: number;
finaleType: string | null;
imageType: number;
isMovie: number;
lastUpdated: string;
linkedMovie?: number;
number: number;
overview: string;
runtime: number | null;
seasons: SeasonPage[];
seasonNumber: number;
seriesId: number;
year: string;
}
export interface EpisodeExtended extends Episode {
productionCode: string;
nominations: null;
characters: Character[];
contentRatings: ContentRating[];
remoteIds: RemoteId[];
tagOptions: TagOptions[];
trailers: Trailer[];
networks: null;
studios: StudiosHelper[];
companies: Company[];
awards: IdName[];
}
export interface EpisodeExtendedTranslations extends EpisodeExtended {
translations: Translations;
}
export interface Genre extends IdName {
slug: string;
}
export interface Inspiration extends IdName {
description: string;
reference_name: string;
url: string;
}
export type Language = Record<'id' | 'name' | 'nativeName' | 'shortCode', string>;
export interface List extends SharedProps {
overview: string;
url: string;
isOfficial: boolean;
aliases: Aliases[];
score: number;
imageIsFallback: boolean;
remoteIds: null;
tags: null;
}
export interface ListExtended extends Omit<List, 'tags'> {
tags: TagOptions[];
entities: Array<Record<'order' | 'seriesId' | 'movieId', number | null>>;
}
export interface Movie extends SharedProps {
aliases: Aliases[];
lastUpdated: string;
runtime: number;
score: number;
slug: string;
status: StatusHelper;
year: string;
}
export interface MovieExtended extends Movie {
trailers: Trailer[];
genres: Genre[];
releases: Array<Record<'country' | 'date' | 'detail', string>>;
artworks: Artwork[];
remoteIds: RemoteId[];
characters: Character[];
budget: string;
boxOffice: string;
boxOfficeUS: string;
originalCountry: string;
originalLanguage: string;
audioLanguages: string[] | null;
subtitleLanguages: string[] | null;
studios: StudiosHelper[];
awards: IdName[];
tagOptions: TagOptions[];
lists: List[];
contentRatings: ContentRating[];
companies: CompanyRecord;
production_countries: ProductionCountries[];
inspirations: Inspirations[];
spoken_languages: string[];
first_release: Record<'country' | 'date' | 'detail', string>;
}
export interface MovieExtendedMeta extends MovieExtended {
translations: Translations;
}
export interface MovieExtendedMetaShort extends Omit<MovieExtendedMeta, 'characters' | 'artworks' | 'trailers'> {
characters: null;
artworks: null;
trailers: null;
}
export interface MovieExtendedShort extends Omit<MovieExtended, 'characters' | 'artworks' | 'trailers'> {
characters: null;
artworks: null;
trailers: null;
}
export interface People extends SharedProps {
aliases: Aliases[] | null;
lastUpdated: string;
score: number;
}
export interface PeopleExtended extends People {
birth: string | null;
death: string | null;
birthPlace: string | null;
remoteIds: RemoteId[];
gender: number;
characters: Character[];
biographies: Array<Record<'biography' | 'language', string>>;
awards: IdName[];
tagOptions: TagOptions[];
slug: string;
}
export interface PeopleExtendedTranslations extends PeopleExtended {
translations: Translations;
}
export interface SeasonPage extends Omit<SharedProps, 'name'> {
seriesId: number;
type: SeasonType;
number: number;
imageType: number;
companies: Record<'studio' | 'network' | 'production' | 'distributor' | 'special_effects', null>;
lastUpdated: string;
}
export interface Season extends SeasonPage {
year: string;
}
export interface SeasonExtended extends Omit<Season, 'companies'> {
artwork: Artwork[];
episodes: Episode[];
trailers: Trailer[];
tagOptions: TagOptions[];
companies: CompanyRecord;
}
export interface SeasonExtendedTranslations extends SeasonExtended {
translations: Translations;
}
export interface Search {
aliases: string[];
country: string;
director: string;
extended_title: string;
first_air_time: string;
genres: string[];
id: string;
image_url: string;
name: string;
network: string;
objectID: string;
overview: string;
overviews: Record<string, string>;
primary_language: string;
primary_type: string;
remote_ids: string[];
slug: string;
status: string;
studios: string[];
thumbnail: string;
translations: Record<string, string>;
tvdb_id: string;
type: string;
year: string;
}
export interface SearchRemote {
episode?: Episode;
company?: Company;
movie?: Movie;
people?: People;
series?: Serie;
}
export interface Serie extends Omit<Movie, 'runtime'> {
averageRuntime: number;
country: string;
defaultSeasonType: number;
episodes: null;
firstAired: string;
isOrderRandomized: boolean;
lastAired: string;
nextAired: string;
originalCountry: string;
originalLanguage: string;
overview: string;
}
export interface SerieExtended extends Serie {
airsDays: Record<string, boolean>;
airsTime: string;
artworks: ArtworkExtended[];
characters: Character[];
companies: Company[];
contentRatings: ContentRating[];
genres: Genre[];
latestNetwork: Company;
lists: List[];
originalNetwork: Company;
remoteIds: RemoteId[];
seasonTypes: SeasonType[];
seasons: SeasonPage[];
tags: TagOptions[];
trailers: Trailer[];
}
export interface SerieArtworks extends Serie {
airsDays: Record<string, boolean>;
airsTime: null;
artworks: ArtworkExtended[];
characters: null;
companies: null;
contentRatings: null;
genres: null;
lists: null;
remoteIds: null;
seasons: null;
tags: null;
trailers: null;
}
export interface SerieExtendedTranslations extends SerieExtended {
translations: Translations;
}
export interface SerieExtendedEpisodes extends Omit<SerieExtended, 'episodes'> {
episodes: Episode[];
}
export interface SerieExtendedShort extends Omit<SerieExtended, 'artworks' | 'characters'> {
artworks: null;
characters: null;
}
export interface SerieExtendedShortTranslations extends SerieExtendedShort {
translations: Translations;
}
export interface SerieExtendedShortEpisodes extends Omit<SerieExtendedShort, 'episodes'> {
episodes: Episode[];
}
export interface SerieSeasonType {
series: Serie;
episodes: Episode[];
}
export interface SerieSeasonTypeLanguage extends Omit<Serie, 'episodes'> {
episodes: Episode[];
}
export interface Source extends Genre {
postfix: string | null;
prefix: string | null;
sort: number;
}
export type Update = Record<'recordType' | 'method' | 'extraInfo' | 'entityType' | 'mergeToType', string> & Record<'recordId' | 'methodInt' | 'userId' | 'timeStamp' | 'mergeToId' | 'seriesId', number>;
export interface PathsSerieEpisodes {
id: string;
seasonType: string;
}
export interface PathsSerieEpisodesLanguage extends PathsSerieEpisodes {
language: string;
}
export interface QueriesMoviesFilter {
country?: string;
lang?: string;
company?: string;
contentRating?: string;
genre?: string;
sort?: 'score' | 'firstAired' | 'name';
status?: '1' | '2' | '3';
year?: string;
page?: string;
}
export interface QueriesMovieExtended {
meta?: 'translations';
short?: 'true' | 'false';
}
export interface QueriesSearch {
company?: string;
country?: string;
director?: string;
language?: string;
limit?: string;
network?: string;
offset?: string;
page?: string;
primaryType?: string;
query: string;
remote_id?: string;
type?: string;
year?: string;
}
export interface QueriesSerieArtworks {
lang?: string;
type?: string;
}
export interface QueriesSerieExtended {
meta?: 'translations' | 'episodes';
short?: 'true' | 'false';
}
export interface QueriesSeriesFilter extends Omit<QueriesMoviesFilter, 'sort'> {
sort?: 'score' | 'firstAired' | 'name' | 'lastAired';
sortType?: 'asc' | 'desc';
}
export interface QueriesSerieEpisodes {
airDate?: string;
episodeNumber?: string;
page?: string;
season?: string;
}
export interface QueriesUpdates {
since: string;
type?: Entities;
action?: 'create' | 'delete' | 'update';
page?: string;
}
export type GetArtwork = Response<Artwork>;
export type GetArtworkExtended = Response<ArtworkExtended>;
export type GetArtworkStatuses = Response<IdName[]>;
export type GetArtworkTypes = Response<ArtworkType[]>;
export type GetAwardsById = Response<IdName>;
export type GetAwardByIdExtended = Response<AwardExtended>;
export type GetAwardCategoryById = Response<AwardCategory>;
export type GetAwardCategoryByIdExtended = Response<AwardCategoryExtended>;
export type GetAwards = Response<IdName[]>;
export type GetCharacterById = Response<Character>;
export type GetCompanies = ResponseLink<Company[]>;
export type GetCompaniesTypes = Response<CompanyType[]>;
export type GetCompanyById = Response<Company>;
export type GetContentRatings = Response<ContentRating[]>;
export type GetCountries = Response<Country[]>;
export type GetEntities = Response<Entity[]>;
export type GetEpisodeById = Response<Episode>;
export type GetEpisodeByIdExtended<T> = T extends true ? Response<EpisodeExtendedTranslations> : Response<EpisodeExtended>;
export type GetEpisodeWithTranslation = Response<TranslationHelper>;
export type GetEpisodes = ResponseLink<EpisodePage[]>;
export type GetGenders = Response<IdName[]>;
export type GetGenreById = Response<Genre>;
export type GetGenres = Response<Genre[]>;
export type GetInspirationTypes = Response<Inspiration[]>;
export type GetLanguages = Response<Language[]>;
export type GetListById = Response<List>;
export type GetListByIdExtended = Response<ListExtended>;
export type GetListBySlug = Response<List>;
export type GetListWithTranslation = Response<TranslationHelper[]>;
export type GetLists = ResponseLink<List[]>;
export type GetMovieById = Response<Movie>;
export type GetMovieByIdExtended<Q extends QueriesMovieExtended> = Q['meta'] extends 'translations' ? Q['short'] extends 'true' ? Response<MovieExtendedMetaShort> : Response<MovieExtendedMeta> : Q['short'] extends 'true' ? Response<MovieExtendedShort> : Response<MovieExtended>;
export type GetMovieBySlug = Response<Movie>;
export type GetMovieStatuses = Response<StatusHelper[]>;
export type GetMovieWithTranslation = Response<TranslationHelper>;
export type GetMovies = ResponseLink<Movie[]>;
export type GetMoviesFilter = ResponseLink<Movie[]>;
export type GetPeople = ResponseLink<People[]>;
export type GetPeopleById = Response<People>;
export type GetPeopleByIdExtended<T> = T extends true ? Response<PeopleExtendedTranslations> : Response<PeopleExtended>;
export type GetPeopleTypes = Response<IdName[]>;
export type GetPeopleWithTranslation = Response<TranslationHelper>;
export type GetSearch = ResponseLink<Search[]>;
export type GetSearchRemoteId = Response<SearchRemote[]>;
export type GetSeasonById = Response<Season>;
export type GetSeasonByIdExtended<T> = T extends true ? Response<SeasonExtendedTranslations> : Response<SeasonExtended>;
export type GetSeasonTypes = Response<SeasonType[]>;
export type GetSeasonWithTranslation = Response<TranslationHelper>;
export type GetSeasons = ResponseLink<SeasonPage[]>;
export type GetSerieById = Response<Serie>;
export type GetSerieByIdArtworks = Response<SerieArtworks>;
export type GetSerieByIdExtended<Q extends QueriesSerieExtended> = Q['meta'] extends 'translations' ? Q['short'] extends 'true' ? Response<SerieExtendedShortTranslations> : Response<SerieExtendedTranslations> : Q['meta'] extends 'episodes' ? Q['short'] extends 'true' ? Response<SerieExtendedShortEpisodes> : Response<SerieExtendedEpisodes> : Q['short'] extends 'true' ? Response<SerieExtendedShort> : Response<SerieExtended>;
export type GetSerieByIdNextAired = Response<Serie>;
export type GetSerieBySlug = Response<Serie>;
export type GetSerieEpisodes = ResponseLink<SerieSeasonType>;
export type GetSerieEpisodesWithLanguage = ResponseLink<SerieSeasonTypeLanguage>;
export type GetSerieStatuses = Response<StatusHelper[]>;
export type GetSerieWithTranslation = Response<TranslationHelper>;
export type GetSeries = ResponseLink<Serie[]>;
export type GetSeriesFilter = ResponseLink<Serie[]>;
export type GetSourcesTypes = Response<Source[]>;
export type GetUpdates = ResponseLink<Update[]>;
/**
* Client library for TheTVDB API in Node.js
*/
export declare class TheTVDB {
private _token;
private readonly api;
/**
* @param token Bearer token for subsequent API calls.
*/
constructor(token: string);
/**
* @param url The URL target.
* @returns A promise with the fetching data.
* @throws Will throw an error if `response.ok` is false.
*/
protected fetcher<T>(url: string | URL): Promise<T>;
/**
* @param path paths for the URL.
* @returns The URL instance with paths.
*/
protected createURL(path: string): URL;
/**
* @param url The `URL` instance.
* @param queries The object with search parameters.
* @returns The URL with queries applied.
*/
protected createQuery(url: URL, queries?: object): string;
/**
* @param token The new token for making API calls.
*/
updateToken(token: string): void;
/**
* @param id The artwork `id`.
* @returns Single artwork record.
* @see {@link https://untidy-thetvdb.netlify.app/api/artwork/byid/ Docs}
*/
artworkById(id: string): Promise<GetArtwork>;
/**
* @param id The `artwork` id.
* @returns Single extended artwork record.
* @see {@link https://untidy-thetvdb.netlify.app/api/artwork/byidextended/ Docs}
*/
artworkByIdExtended(id: string): Promise<GetArtworkExtended>;
/**
* @returns A list of artwork status records.
* @see {@link https://untidy-thetvdb.netlify.app/api/artwork/statuses/ Docs}
*/
artworkStatuses(): Promise<GetArtworkStatuses>;
/**
* @returns A list of artwork types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/artwork/types/ Docs}
*/
artworkTypes(): Promise<GetArtworkTypes>;
/**
* @param id The award `id`.
* @returns Single award record.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/byid/ Docs}
*/
awardById(id: string): Promise<GetAwardsById>;
/**
* @param id The award `id`.
* @returns Single extended award record.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/byidextended/ Docs}
*/
awardByIdExtended(id: string): Promise<GetAwardByIdExtended>;
/**
* @param id The award category `id`.
* @returns Single award category record.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/categorybyid/ Docs}
*/
awardCategoryById(id: string): Promise<GetAwardCategoryById>;
/**
* @param id The award category `id`.
* @returns Single extended award category record.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/categorybyidextended/ Docs}
*/
awardCategoryByIdExtended(id: string): Promise<GetAwardCategoryByIdExtended>;
/**
* @returns A list of awards records.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/awards/ Docs}
*/
awards(): Promise<GetAwards>;
/**
* @param id The character `id`.
* @returns Single character record.
* @see {@link https://untidy-thetvdb.netlify.app/api/characterbyid/ Docs}
*/
characterById(id: string): Promise<GetCharacterById>;
/**
* @param page Restrict results to a specific page.
* @returns A list of companies records.
* @see {@link https://untidy-thetvdb.netlify.app/api/companies/companies/ Docs}
*/
companies(page?: string): Promise<GetCompanies>;
/**
* @returns A list of companies type records.
* @see {@link https://untidy-thetvdb.netlify.app/api/companies/types/ Docs}
*/
companiesTypes(): Promise<GetCompaniesTypes>;
/**
* @param id The company `id`.
* @returns Single company record.
* @see {@link https://untidy-thetvdb.netlify.app/api/companies/byid/ Docs}
*/
companyById(id: string): Promise<GetCompanyById>;
/**
* @returns A list of content ratings records.
* @see {@link https://untidy-thetvdb.netlify.app/api/contentratings/ Docs}
*/
contentRatings(): Promise<GetContentRatings>;
/**
* @returns A list of country records.
* @see {@link https://untidy-thetvdb.netlify.app/api/countries/ Docs}
*/
countries(): Promise<GetCountries>;
/**
* @returns A list of entity types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/entities/ Docs}
*/
entities(): Promise<GetEntities>;
/**
* @param id The episode `id`.
* @returns Single episode record.
* @see {@link https://untidy-thetvdb.netlify.app/api/episodes/byid/ Docs}
*/
episodeById(id: string): Promise<GetEpisodeById>;
/**
* @param id The episode `id`.
* @param translation Indicates whether to include translation information in the response.
* Set to `true` to include the `translations` property in the record.
* Defaults to `false` if not provided.
* @returns Single extended episode record.
* @see {@link https://untidy-thetvdb.netlify.app/api/episodes/byidextended/ Docs}
*/
episodeByIdExtended<T extends boolean = false>(id: string, translation?: T): Promise<GetEpisodeByIdExtended<T>>;
/**
* @param id The episode `id`.
* @param language The episode `language`.
* @returns Single episode translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/episodes/translations/ Docs}
*/
episodeWithTranslation(id: string, language: string): Promise<GetEpisodeWithTranslation>;
/**
* @param page Restrict results to a specific page.
* @returns A list of episode records.
* @see {@link https://untidy-thetvdb.netlify.app/api/episodes/episodes/ Docs}
*/
episodes(page?: string): Promise<GetEpisodes>;
/**
* @returns A list of gender records.
* @see {@link https://untidy-thetvdb.netlify.app/api/genders/ Docs}
*/
genders(): Promise<GetGenders>;
/**
* @param id The genre `id`.
* @returns Single genre record.
* @see {@link https://untidy-thetvdb.netlify.app/api/genres/byid/ Docs}
*/
genreById(id: string): Promise<GetGenreById>;
/**
* @returns A list of genre records.
* @see {@link https://untidy-thetvdb.netlify.app/api/genres/genres/ Docs}
*/
genres(): Promise<GetGenres>;
/**
* @returns A list of inspiration types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/inspirationtypes/ Docs}
*/
inspirationTypes(): Promise<GetInspirationTypes>;
/**
* @returns A list of language records.
* @see {@link https://untidy-thetvdb.netlify.app/api/languages/ Docs}
*/
languages(): Promise<GetLanguages>;
/**
* @param id The list `id`.
* @returns Single list record.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/byid/ Docs}
*/
listById(id: string): Promise<GetListById>;
/**
* @param id The list `id`.
* @returns Single extended list record.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/byidextended/ Docs}
*/
listByIdExtended(id: string): Promise<GetListByIdExtended>;
/**
* @param slug The list `slug`.
* @returns Single list record.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/slug/ Docs}
*/
listBySlug(slug: string): Promise<GetListBySlug>;
/**
* @param id The list `id`.
* @param language The list `language`.
* @returns Single list translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/translations/ Docs}
*/
listWithTranslation(id: string, language: string): Promise<GetListWithTranslation>;
/**
* @param page Restrict results to a specific page.
* @returns A list of list records.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/lists/ Docs}
*/
lists(page?: string): Promise<GetLists>;
/**
* @param id The movie `id`
* @returns Single movie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/byid/ Docs}
*/
movieById(id: string): Promise<GetMovieById>;
/**
* @param id The movie `id`
* @param queries An object containing search parameters to restrict the result.
* @returns Single extended movie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/byidextended/ Docs}
*/
movieByIdExtended<Q extends QueriesMovieExtended>(id: string, queries?: Q): Promise<GetMovieByIdExtended<Q>>;
/**
* @param slug The movie `slug`.
* @returns Single movie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/slug/ Docs}
*/
movieBySlug(slug: string): Promise<GetMovieBySlug>;
/**
* @returns A list of movie status records.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/statuses/ Docs}
*/
movieStatuses(): Promise<GetMovieStatuses>;
/**
* @param id The movie `id`.
* @param language The movie `language`.
* @returns Single movie translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/translations/ Docs}
*/
movieWithTranslation(id: string, language: string): Promise<GetMovieWithTranslation>;
/**
* @param page Restrict results to a specific page.
* @returns A list of movie records.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/movies/ Docs}
*/
movies(page?: string): Promise<GetMovies>;
/**
* @param queries An object containing query parameters to restrict the result.
* @returns A list of movie records.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/filter/ Docs}
*/
moviesFilter(queries?: QueriesMoviesFilter): Promise<GetMoviesFilter>;
/**
* @param page Restrict results to a specific page.
* @returns A list of people records.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/people/ Docs}
*/
people(page?: string): Promise<GetPeople>;
/**
* @param id The people `id`
* @returns Single people record.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/byid/ Docs}
*/
peopleById(id: string): Promise<GetPeopleById>;
/**
* @param id The people `id`.
* @param translation Indicates whether to include translation information in the response.
* Set to `true` to include the `translations` property in the record.
* Defaults to `false` if not provided.
* @returns Single extended people record.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/byidextended/ Docs}
*/
peopleByIdExtended<T extends boolean = false>(id: string, translation?: T): Promise<GetPeopleByIdExtended<T>>;
/**
* @returns A list of people types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/types/ Docs}
*/
peopleTypes(): Promise<GetPeopleTypes>;
/**
* @param id The people `id`.
* @param language The people `language`.
* @returns Single people translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/translations/ Docs}
*/
peopleWithTranslation(id: string, language: string): Promise<GetPeopleWithTranslation>;
/**
* @param queries An object containing query parameters to restrict the result.
* @returns A list of query search records.
* @see {@link https://untidy-thetvdb.netlify.app/api/search/search/ Docs}
*/
search(queries: QueriesSearch): Promise<GetSearch>;
/**
* @param id The remote `id`
* @returns A list of entity records based on remote id.
* @see {@link https://untidy-thetvdb.netlify.app/api/search/remote/ Docs}
*/
searchRemoteId(id: string): Promise<GetSearchRemoteId>;
/**
* @param id The season `id`
* @returns Single season record.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/byid/ Docs}
*/
seasonById(id: string): Promise<GetSeasonById>;
/**
* @param id The season `id`.
* @param translation Indicates whether to include translation information in the response.
* Set to `true` to include the `translations` property in the record.
* Defaults to `false` if not provided.
* @returns Single extended season record.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/byidextended/ Docs}
*/
seasonByIdExtended<T extends boolean = false>(id: string, translation?: T): Promise<GetSeasonByIdExtended<T>>;
/**
* @returns A list of season types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/types/ Docs}
*/
seasonTypes(): Promise<GetSeasonTypes>;
/**
* @param id The season `id`.
* @param language The season `language`.
* @returns Single season translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/translations/ Docs}
*/
seasonWithTranslation(id: string, language: string): Promise<GetSeasonWithTranslation>;
/**
* @param page Restrict results to a specific page.
* @returns A list of seasons records.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/seasons/ Docs}
*/
seasons(page?: string): Promise<GetSeasons>;
/**
* @param id The serie `id`
* @returns Single serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/byid/ Docs}
*/
serieById(id: string): Promise<GetSerieById>;
/**
* @param id The serie `id`
* @param queries An object containing search parameters to restrict the result.
* @returns Single serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/byidartworks/ Docs}
*/
serieByIdArtworks(id: string, queries?: QueriesSerieArtworks): Promise<GetSerieByIdArtworks>;
/**
* @param id The serie `id`
* @param queries An object containing search parameters to restrict the result.
* @returns Single extended serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/byidextended/ Docs}
*/
serieByIdExtended<Q extends QueriesSerieExtended>(id: string, queries?: Q): Promise<GetSerieByIdExtended<Q>>;
/**
* @param id The serie `id`
* @returns Single serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/byidnextaired/ Docs}
*/
serieByIdNextAired(id: string): Promise<GetSerieByIdNextAired>;
/**
* @param slug The serie `slug`.
* @returns Single serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/slug/ Docs}
*/
serieBySlug(slug: string): Promise<GetSerieBySlug>;
/**
* @param paths An object containing the `id` and `seasonType` of the serie.
* @param queries An object containing query parameters to restrict the result.
* @returns Episodes from the specified season type in a serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/episodes/ Docs}
*/
serieEpisodes(paths: PathsSerieEpisodes, queries?: QueriesSerieEpisodes): Promise<GetSerieEpisodes>;
/**
* @param paths An object containing the `id` and `seasonType` of the serie.
* @param page Restrict results to a specific page.
* @returns Episodes from the specified season type and language in a serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/episodeslanguage/ Docs}
*/
serieEpisodesWithLanguage(paths: PathsSerieEpisodesLanguage, page?: string): Promise<GetSerieEpisodesWithLanguage>;
/**
* @returns A list of serie status records.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/statuses/ Docs}
*/
serieStatuses(): Promise<GetSerieStatuses>;
/**
* @param id The serie `id`.
* @param language The serie `language`.
* @returns Single serie translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/translations/ Docs}
*/
serieWithTranslation(id: string, language: string): Promise<GetSerieWithTranslation>;
/**
* @param page Restrict results to a specific page.
* @returns A list of series records.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/series/ Docs}
*/
series(page?: string): Promise<GetSeries>;
/**
* @param queries An object containing query parameters to restrict the result.
* @returns A list of series records.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/filter/ Docs}
*/
seriesFilter(queries?: QueriesSeriesFilter): Promise<GetSeriesFilter>;
/**
* @returns A list of source types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/sourcestypes/ Docs}
*/
sourcesTypes(): Promise<GetSourcesTypes>;
/**
* @param queries An object containing query parameters to restrict the result.
* @returns A list of updated records.
* @see {@link https://untidy-thetvdb.netlify.app/api/updates/ Docs}
*/
updates(queries: QueriesUpdates): Promise<GetUpdates>;
}

@@ -1,2 +0,626 @@

export { TheTVDBExtended } from './extended.js';
export { TheTVDB } from './main.js';
import { URL } from 'node:url';
/**
* Client library for TheTVDB API in Node.js
*/
export class TheTVDB {
_token;
api = 'https://api4.thetvdb.com';
/**
* @param token Bearer token for subsequent API calls.
*/
constructor(token) {
if (typeof token !== 'string' || token.length === 0) {
throw new Error('Token is required');
}
this._token = token;
}
/**
* @param url The URL target.
* @returns A promise with the fetching data.
* @throws Will throw an error if `response.ok` is false.
*/
async fetcher(url) {
const response = await fetch(url, {
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${this._token}` },
});
if (!response.ok) {
const status = response.status;
const resJSON = await response.json();
throw new RangeError(`HTTP response status ${status} from thetvdb API.`, {
cause: {
status,
resJSON,
},
});
}
return (await response.json());
}
/**
* @param path paths for the URL.
* @returns The URL instance with paths.
*/
createURL(path) {
return new URL(path, this.api);
}
/**
* @param url The `URL` instance.
* @param queries The object with search parameters.
* @returns The URL with queries applied.
*/
createQuery(url, queries) {
if (typeof queries === 'object') {
for (const [key, value] of Object.entries(queries)) {
if (typeof value === 'string' && value.length >= 1) {
url.searchParams.set(key, value);
}
}
}
return url.href;
}
/**
* @param token The new token for making API calls.
*/
updateToken(token) {
this._token = token;
}
/**
* @param id The artwork `id`.
* @returns Single artwork record.
* @see {@link https://untidy-thetvdb.netlify.app/api/artwork/byid/ Docs}
*/
async artworkById(id) {
return await this.fetcher(`${this.api}/v4/artwork/${id}`);
}
/**
* @param id The `artwork` id.
* @returns Single extended artwork record.
* @see {@link https://untidy-thetvdb.netlify.app/api/artwork/byidextended/ Docs}
*/
async artworkByIdExtended(id) {
return await this.fetcher(`${this.api}/v4/artwork/${id}/extended`);
}
/**
* @returns A list of artwork status records.
* @see {@link https://untidy-thetvdb.netlify.app/api/artwork/statuses/ Docs}
*/
async artworkStatuses() {
return await this.fetcher(`${this.api}/v4/artwork/statuses`);
}
/**
* @returns A list of artwork types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/artwork/types/ Docs}
*/
async artworkTypes() {
return await this.fetcher(`${this.api}/v4/artwork/types`);
}
/**
* @param id The award `id`.
* @returns Single award record.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/byid/ Docs}
*/
async awardById(id) {
return await this.fetcher(`${this.api}/v4/awards/${id}`);
}
/**
* @param id The award `id`.
* @returns Single extended award record.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/byidextended/ Docs}
*/
async awardByIdExtended(id) {
return await this.fetcher(`${this.api}/v4/awards/${id}/extended`);
}
/**
* @param id The award category `id`.
* @returns Single award category record.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/categorybyid/ Docs}
*/
async awardCategoryById(id) {
return await this.fetcher(`${this.api}/v4/awards/categories/${id}`);
}
/**
* @param id The award category `id`.
* @returns Single extended award category record.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/categorybyidextended/ Docs}
*/
async awardCategoryByIdExtended(id) {
return await this.fetcher(`${this.api}/v4/awards/categories/${id}/extended`);
}
/**
* @returns A list of awards records.
* @see {@link https://untidy-thetvdb.netlify.app/api/awards/awards/ Docs}
*/
async awards() {
return await this.fetcher(`${this.api}/v4/awards`);
}
/**
* @param id The character `id`.
* @returns Single character record.
* @see {@link https://untidy-thetvdb.netlify.app/api/characterbyid/ Docs}
*/
async characterById(id) {
return await this.fetcher(`${this.api}/v4/characters/${id}`);
}
/**
* @param page Restrict results to a specific page.
* @returns A list of companies records.
* @see {@link https://untidy-thetvdb.netlify.app/api/companies/companies/ Docs}
*/
async companies(page) {
let endpoint = this.api + '/v4/companies';
if (typeof page === 'string' && page.length > 0 && page.length < 3) {
endpoint += `?page=${page}`;
}
return await this.fetcher(endpoint);
}
/**
* @returns A list of companies type records.
* @see {@link https://untidy-thetvdb.netlify.app/api/companies/types/ Docs}
*/
async companiesTypes() {
return await this.fetcher(`${this.api}/v4/companies/types`);
}
/**
* @param id The company `id`.
* @returns Single company record.
* @see {@link https://untidy-thetvdb.netlify.app/api/companies/byid/ Docs}
*/
async companyById(id) {
return await this.fetcher(`${this.api}/v4/companies/${id}`);
}
/**
* @returns A list of content ratings records.
* @see {@link https://untidy-thetvdb.netlify.app/api/contentratings/ Docs}
*/
async contentRatings() {
return await this.fetcher(`${this.api}/v4/content/ratings`);
}
/**
* @returns A list of country records.
* @see {@link https://untidy-thetvdb.netlify.app/api/countries/ Docs}
*/
async countries() {
return await this.fetcher(`${this.api}/v4/countries`);
}
/**
* @returns A list of entity types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/entities/ Docs}
*/
async entities() {
return await this.fetcher(`${this.api}/v4/entities`);
}
/**
* @param id The episode `id`.
* @returns Single episode record.
* @see {@link https://untidy-thetvdb.netlify.app/api/episodes/byid/ Docs}
*/
async episodeById(id) {
return await this.fetcher(`${this.api}/v4/episodes/${id}`);
}
/**
* @param id The episode `id`.
* @param translation Indicates whether to include translation information in the response.
* Set to `true` to include the `translations` property in the record.
* Defaults to `false` if not provided.
* @returns Single extended episode record.
* @see {@link https://untidy-thetvdb.netlify.app/api/episodes/byidextended/ Docs}
*/
async episodeByIdExtended(id, translation = false) {
let endpoint = `${this.api}/v4/episodes/${id}/extended`;
if (typeof translation === 'boolean' && translation) {
endpoint += '?meta=translations';
}
return await this.fetcher(endpoint);
}
/**
* @param id The episode `id`.
* @param language The episode `language`.
* @returns Single episode translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/episodes/translations/ Docs}
*/
async episodeWithTranslation(id, language) {
return await this.fetcher(`${this.api}/v4/episodes/${id}/translations/${language}`);
}
/**
* @param page Restrict results to a specific page.
* @returns A list of episode records.
* @see {@link https://untidy-thetvdb.netlify.app/api/episodes/episodes/ Docs}
*/
async episodes(page) {
let endpoint = this.api + '/v4/episodes';
if (typeof page === 'string' && page.length > 0 && page.length <= 5) {
endpoint += `?page=${page}`;
}
return await this.fetcher(endpoint);
}
/**
* @returns A list of gender records.
* @see {@link https://untidy-thetvdb.netlify.app/api/genders/ Docs}
*/
async genders() {
return await this.fetcher(`${this.api}/v4/genders`);
}
/**
* @param id The genre `id`.
* @returns Single genre record.
* @see {@link https://untidy-thetvdb.netlify.app/api/genres/byid/ Docs}
*/
async genreById(id) {
return await this.fetcher(`${this.api}/v4/genres/${id}`);
}
/**
* @returns A list of genre records.
* @see {@link https://untidy-thetvdb.netlify.app/api/genres/genres/ Docs}
*/
async genres() {
return await this.fetcher(`${this.api}/v4/genres`);
}
/**
* @returns A list of inspiration types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/inspirationtypes/ Docs}
*/
async inspirationTypes() {
return await this.fetcher(`${this.api}/v4/inspiration/types`);
}
/**
* @returns A list of language records.
* @see {@link https://untidy-thetvdb.netlify.app/api/languages/ Docs}
*/
async languages() {
return await this.fetcher(`${this.api}/v4/languages`);
}
/**
* @param id The list `id`.
* @returns Single list record.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/byid/ Docs}
*/
async listById(id) {
return await this.fetcher(`${this.api}/v4/lists/${id}`);
}
/**
* @param id The list `id`.
* @returns Single extended list record.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/byidextended/ Docs}
*/
async listByIdExtended(id) {
return await this.fetcher(`${this.api}/v4/lists/${id}/extended`);
}
/**
* @param slug The list `slug`.
* @returns Single list record.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/slug/ Docs}
*/
async listBySlug(slug) {
return await this.fetcher(`${this.api}/v4/lists/slug/${slug}`);
}
/**
* @param id The list `id`.
* @param language The list `language`.
* @returns Single list translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/translations/ Docs}
*/
async listWithTranslation(id, language) {
return await this.fetcher(`${this.api}/v4/lists/${id}/translations/${language}`);
}
/**
* @param page Restrict results to a specific page.
* @returns A list of list records.
* @see {@link https://untidy-thetvdb.netlify.app/api/lists/lists/ Docs}
*/
async lists(page) {
let endpoint = `${this.api}/v4/lists`;
if (typeof page === 'string' && page.length > 0 && page.length < 3) {
endpoint += `?page=${page}`;
}
return await this.fetcher(endpoint);
}
/**
* @param id The movie `id`
* @returns Single movie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/byid/ Docs}
*/
async movieById(id) {
return await this.fetcher(`${this.api}/v4/movies/${id}`);
}
/**
* @param id The movie `id`
* @param queries An object containing search parameters to restrict the result.
* @returns Single extended movie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/byidextended/ Docs}
*/
async movieByIdExtended(id, queries) {
const url = this.createURL(`/v4/movies/${id}/extended`);
const endpoint = this.createQuery(url, queries);
return await this.fetcher(endpoint);
}
/**
* @param slug The movie `slug`.
* @returns Single movie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/slug/ Docs}
*/
async movieBySlug(slug) {
return await this.fetcher(`${this.api}/v4/movies/slug/${slug}`);
}
/**
* @returns A list of movie status records.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/statuses/ Docs}
*/
async movieStatuses() {
return await this.fetcher(`${this.api}/v4/movies/statuses`);
}
/**
* @param id The movie `id`.
* @param language The movie `language`.
* @returns Single movie translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/translations/ Docs}
*/
async movieWithTranslation(id, language) {
return await this.fetcher(`${this.api}/v4/movies/${id}/translations/${language}`);
}
/**
* @param page Restrict results to a specific page.
* @returns A list of movie records.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/movies/ Docs}
*/
async movies(page) {
let endpoint = `${this.api}/v4/movies`;
if (typeof page === 'string' && page.length > 0 && page.length <= 3) {
endpoint += `?page=${page}`;
}
return await this.fetcher(endpoint);
}
/**
* @param queries An object containing query parameters to restrict the result.
* @returns A list of movie records.
* @see {@link https://untidy-thetvdb.netlify.app/api/movies/filter/ Docs}
*/
async moviesFilter(queries) {
const url = this.createURL('/v4/movies/filter');
const endpoint = this.createQuery(url, queries);
return await this.fetcher(endpoint);
}
/**
* @param page Restrict results to a specific page.
* @returns A list of people records.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/people/ Docs}
*/
async people(page) {
let endpoint = `${this.api}/v4/people`;
if (typeof page === 'string' && page.length > 0 && page.length <= 4) {
endpoint += `?page=${page}`;
}
return await this.fetcher(endpoint);
}
/**
* @param id The people `id`
* @returns Single people record.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/byid/ Docs}
*/
async peopleById(id) {
return await this.fetcher(`${this.api}/v4/people/${id}`);
}
/**
* @param id The people `id`.
* @param translation Indicates whether to include translation information in the response.
* Set to `true` to include the `translations` property in the record.
* Defaults to `false` if not provided.
* @returns Single extended people record.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/byidextended/ Docs}
*/
async peopleByIdExtended(id, translation = false) {
let endpoint = `${this.api}/v4/people/${id}/extended`;
if (typeof translation === 'boolean' && translation) {
endpoint += '?meta=translations';
}
return await this.fetcher(endpoint);
}
/**
* @returns A list of people types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/types/ Docs}
*/
async peopleTypes() {
return await this.fetcher(`${this.api}/v4/people/types`);
}
/**
* @param id The people `id`.
* @param language The people `language`.
* @returns Single people translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/people/translations/ Docs}
*/
async peopleWithTranslation(id, language) {
return await this.fetcher(`${this.api}/v4/people/${id}/translations/${language}`);
}
/**
* @param queries An object containing query parameters to restrict the result.
* @returns A list of query search records.
* @see {@link https://untidy-thetvdb.netlify.app/api/search/search/ Docs}
*/
async search(queries) {
const endpoint = this.createURL('/v4/search');
const query = this.createQuery(endpoint, queries);
return await this.fetcher(query);
}
/**
* @param id The remote `id`
* @returns A list of entity records based on remote id.
* @see {@link https://untidy-thetvdb.netlify.app/api/search/remote/ Docs}
*/
async searchRemoteId(id) {
return await this.fetcher(`${this.api}/v4/search/remoteid/${id}`);
}
/**
* @param id The season `id`
* @returns Single season record.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/byid/ Docs}
*/
async seasonById(id) {
return await this.fetcher(`${this.api}/v4/seasons/${id}`);
}
/**
* @param id The season `id`.
* @param translation Indicates whether to include translation information in the response.
* Set to `true` to include the `translations` property in the record.
* Defaults to `false` if not provided.
* @returns Single extended season record.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/byidextended/ Docs}
*/
async seasonByIdExtended(id, translation = false) {
let endpoint = `${this.api}/v4/seasons/${id}/extended`;
if (typeof translation === 'boolean' && translation) {
endpoint += '?meta=translations';
}
return await this.fetcher(endpoint);
}
/**
* @returns A list of season types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/types/ Docs}
*/
async seasonTypes() {
return await this.fetcher(`${this.api}/v4/seasons/types`);
}
/**
* @param id The season `id`.
* @param language The season `language`.
* @returns Single season translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/translations/ Docs}
*/
async seasonWithTranslation(id, language) {
return await this.fetcher(`${this.api}/v4/seasons/${id}/translations/${language}`);
}
/**
* @param page Restrict results to a specific page.
* @returns A list of seasons records.
* @see {@link https://untidy-thetvdb.netlify.app/api/seasons/seasons/ Docs}
*/
async seasons(page) {
let endpoint = `${this.api}/v4/seasons`;
if (typeof page === 'string' && page.length > 0 && page.length <= 4) {
endpoint += `?page=${page}`;
}
return await this.fetcher(endpoint);
}
/**
* @param id The serie `id`
* @returns Single serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/byid/ Docs}
*/
async serieById(id) {
return await this.fetcher(`${this.api}/v4/series/${id}`);
}
/**
* @param id The serie `id`
* @param queries An object containing search parameters to restrict the result.
* @returns Single serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/byidartworks/ Docs}
*/
async serieByIdArtworks(id, queries) {
const url = this.createURL(`/v4/series/${id}/artworks`);
const endpoint = this.createQuery(url, queries);
return await this.fetcher(endpoint);
}
/**
* @param id The serie `id`
* @param queries An object containing search parameters to restrict the result.
* @returns Single extended serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/byidextended/ Docs}
*/
async serieByIdExtended(id, queries) {
const url = this.createURL(`/v4/series/${id}/extended`);
const endpoint = this.createQuery(url, queries);
return await this.fetcher(endpoint);
}
/**
* @param id The serie `id`
* @returns Single serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/byidnextaired/ Docs}
*/
async serieByIdNextAired(id) {
return await this.fetcher(`${this.api}/v4/series/${id}/nextAired`);
}
/**
* @param slug The serie `slug`.
* @returns Single serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/slug/ Docs}
*/
async serieBySlug(slug) {
return await this.fetcher(`${this.api}/v4/series/slug/${slug}`);
}
/**
* @param paths An object containing the `id` and `seasonType` of the serie.
* @param queries An object containing query parameters to restrict the result.
* @returns Episodes from the specified season type in a serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/episodes/ Docs}
*/
async serieEpisodes(paths, queries) {
const url = this.createURL(`/v4/series/${paths.id}/episodes/${paths.seasonType}`);
const endpoint = this.createQuery(url, queries);
return await this.fetcher(endpoint);
}
/**
* @param paths An object containing the `id` and `seasonType` of the serie.
* @param page Restrict results to a specific page.
* @returns Episodes from the specified season type and language in a serie record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/episodeslanguage/ Docs}
*/
async serieEpisodesWithLanguage(paths, page) {
let endpoint = `${this.api}/v4/series/${paths.id}/episodes/${paths.seasonType}/${paths.language}`;
if (typeof page === 'string' && page.length > 0 && page.length <= 3) {
endpoint += `?page=${page}`;
}
return await this.fetcher(endpoint);
}
/**
* @returns A list of serie status records.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/statuses/ Docs}
*/
async serieStatuses() {
return await this.fetcher(`${this.api}/v4/series/statuses`);
}
/**
* @param id The serie `id`.
* @param language The serie `language`.
* @returns Single serie translation record.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/translations/ Docs}
*/
async serieWithTranslation(id, language) {
return await this.fetcher(`${this.api}/v4/series/${id}/translations/${language}`);
}
/**
* @param page Restrict results to a specific page.
* @returns A list of series records.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/series/ Docs}
*/
async series(page) {
let endpoint = `${this.api}/v4/series`;
if (typeof page === 'string' && page.length > 0 && page.length <= 3) {
endpoint += `?page=${page}`;
}
return await this.fetcher(endpoint);
}
/**
* @param queries An object containing query parameters to restrict the result.
* @returns A list of series records.
* @see {@link https://untidy-thetvdb.netlify.app/api/series/filter/ Docs}
*/
async seriesFilter(queries) {
const url = this.createURL('/v4/series/filter');
const endpoint = this.createQuery(url, queries);
return await this.fetcher(endpoint);
}
/**
* @returns A list of source types records.
* @see {@link https://untidy-thetvdb.netlify.app/api/sourcestypes/ Docs}
*/
async sourcesTypes() {
return await this.fetcher(`${this.api}/v4/sources/types`);
}
/**
* @param queries An object containing query parameters to restrict the result.
* @returns A list of updated records.
* @see {@link https://untidy-thetvdb.netlify.app/api/updates/ Docs}
*/
async updates(queries) {
const url = this.createURL('/v4/updates');
const endpoint = this.createQuery(url, queries);
return await this.fetcher(endpoint);
}
}

52

package.json
{
"name": "@untidy/thetvdb",
"description": "fully-typed client for accessing the TheTVDB API V4 for Node.js",
"version": "0.5.0",
"description": "Client library for TheTVDB API in Node.js",
"version": "1.0.0",
"type": "module",

@@ -17,6 +17,7 @@ "exports": {

"keywords": [
"thetvdb",
"api",
"database",
"movies",
"series",
"movies",
"api"
"thetvdb"
],

@@ -27,31 +28,12 @@ "author": "falsepopsky",

"devDependencies": {
"@changesets/cli": "^2.26.2",
"@swc/core": "^1.3.96",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.8",
"@types/node": "^20.9.0",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"dotenv": "^16.3.1",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.7.0",
"msw": "^2.0.6",
"prettier": "^3.1.0",
"tsx": "^4.1.1",
"typescript": "^5.2.2",
"vitepress": "1.0.0-rc.25"
"@types/node": "^20.11.5",
"typescript": "^5.3.3"
},
"engines": {
"node": "^18.16.1 || ^20.0.0",
"pnpm": ">=8"
"node": "^18.17.0 || ^20.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/falsepopsky/thetvdb.git"
"url": "https://github.com/falsepopsky/thetvdb.git",
"directory": "packages/api"
},

@@ -61,18 +43,8 @@ "bugs": {

},
"packageManager": "pnpm@8.10.4",
"scripts": {
"dev": "tsx src/playground.ts",
"format": "prettier --cache -w .",
"lint": "eslint . --cache --cache-location \"./node_modules/.cache/eslint/\"",
"clean:workspace": "rm -rf node_modules dist",
"clean:build": "rm -rf dist",
"prebuild": "pnpm run clean:build",
"build": "tsc --project tsconfig.build.json",
"test": "jest",
"test:coverage": "jest --coverage",
"release": "pnpm run build && changeset publish",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
"test": "jest --coverage"
}
}
# @untidy/thetvdb
![thetvdb logo](https://github.com/falsepopsky/thetvdb/blob/main/docs/public/favicon.png)
![thetvdb logo](https://github.com/falsepopsky/thetvdb/blob/main/packages/web/src/assets/favicon.png)
## :information_source: About
## ℹī¸ About

@@ -14,6 +14,6 @@ A lightweight and fully-typed client for accessing the TheTVDB API V4 for Node.js. This package

## :sparkles: Features
## ✨ Features
- Access multiple endpoints of the TheTVDB API
[(check supported endpoints)](https://github.com/falsepopsky/thetvdb/blob/main/docs/endpoints.md)
[(check supported endpoints)](https://untidy-thetvdb.netlify.app/guides/supported-endpoints)
- Built with TypeScript for full typing support

@@ -23,3 +23,3 @@ - Uses the native `fetch` module from Node.js for making HTTP requests

## :package: Install
## đŸ“Ļ Install

@@ -46,6 +46,6 @@ You can install `@untidy/thetvdb` package using your preferred package manager:

## :beginner: Usage
## 🔰 Usage
`@untidy/thetvdb` is easy to use, simply create an instance of the class with your API token, and
call any of the available methods to retrieve data from the TheTVDB API.
`@untidy/thetvdb` is easy to use, simply create an instance of the TheTVDB class with your API
token, and call any of the available methods to retrieve data from the TheTVDB API.

@@ -57,5 +57,4 @@ Example usage:

const token = 'your secret jwt token';
const client = new TheTVDB(token);
const { data } = await client.getCharacter('64140522');
const client = new TheTVDB('access token');
const { data } = await client.characterById('64140522');

@@ -65,13 +64,12 @@ console.log(data);

## :page_facing_up: Docs
## 📄 Docs
- [API](https://untidy-thetvdb.netlify.app/api)
- [Supported endpoints](https://untidy-thetvdb.netlify.app/guide/supported-endpoints)
- [TheTVDB Examples](https://untidy-thetvdb.netlify.app/api/thetvdb)
- [TheTVDBExtended Examples](https://untidy-thetvdb.netlify.app/api/thetvdb-extended)
- [Supported endpoints](https://untidy-thetvdb.netlify.app/guides/supported-endpoints)
- [Examples](https://untidy-thetvdb.netlify.app/guides/examples)
## :scroll: License
## 📜 License
`@untidy/thetvdb` is licensed under the
[Apache-2.0](https://github.com/falsepopsky/thetvdb/blob/main/LICENSE) license - Š 2023
[falsepopsky](https://github.com/falsepopsky).
[Apache-2.0](https://github.com/falsepopsky/thetvdb/blob/main/packages/api/LICENSE) license - Š
2023, 2024 [falsepopsky](https://github.com/falsepopsky).

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡ī¸ by Socket Inc