Overview
The common types module contains shared TypeScript interfaces and types that are used across multiple parts of the API, including base screening data, film types, ratings, and cinema information.
CSFDScreening
The base interface for any film or TV show representation. Most movie-related interfaces extend this.
Title of the film or show
Full ČSFD URL to the page
Type of content (film, series, tv-show, etc.)
Overall aggregated rating represented by color
Many interfaces in the API extend CSFDScreening and add additional properties. For example: CSFDMovie, CSFDSearchMovie, CSFDUserRatings, etc.
Type Definitions
CSFDColorRating
Color-based rating system used throughout ČSFD:
type CSFDColorRating = 'bad' | 'average' | 'good' | 'unknown' ;
Rating ranges:
bad: 0% - 29% (black color on ČSFD)
average: 30% - 69% (blue color on ČSFD)
good: 70% - 100% (red color on ČSFD)
unknown: Not enough ratings (gray color on ČSFD)
CSFDStars
User star ratings:
type CSFDStars = 0 | 1 | 2 | 3 | 4 | 5 ;
CSFDFilmTypes
All possible content types on ČSFD:
type CSFDFilmTypes =
| 'film'
| 'tv-film'
| 'tv-show'
| 'series'
| 'theatrical'
| 'concert'
| 'season'
| 'student-film'
| 'amateur-film'
| 'music-video'
| 'episode'
| 'video-compilation' ;
Cinema Types
Types related to cinema showtimes and screenings.
CSFDCinema
Represents a cinema with its current screenings.
City where the cinema is located
Geographic coordinates with lat and lng numbers
screenings
CSFDCinemaGroupedFilmsByDate[]
required
Films grouped by date
CSFDCinemaGroupedFilmsByDate
Groups films by screening date.
CSFDCinemaGroupedFilmsByDate
films
CSFDCinemaMovie[]
required
Films showing on this date
CSFDCinemaMovie
Represents a movie screening at a cinema.
Screening metadata (dubbing, 3D, subtitles, etc.)
Metadata tags for cinema screenings:
type CSFDCinemaMeta = 'dubbing' | '3D' | 'subtitles' | string ;
CSFDCinemaPeriod
Time periods for cinema listings:
type CSFDCinemaPeriod = 'today' | 'weekend' | 'week' | 'tomorrow' | 'month' ;
Import Example
import type {
CSFDScreening ,
CSFDColorRating ,
CSFDStars ,
CSFDFilmTypes ,
CSFDCinema ,
CSFDCinemaGroupedFilmsByDate ,
CSFDCinemaMovie ,
CSFDCinemaMeta ,
CSFDCinemaPeriod ,
} from 'node-csfd-api' ;
TypeScript Interface
export interface CSFDScreening {
id : number ;
title : string ;
year : number ;
url : string ;
type : CSFDFilmTypes ;
colorRating : CSFDColorRating ;
}
export type CSFDColorRating = 'bad' | 'average' | 'good' | 'unknown' ;
export type CSFDStars = 0 | 1 | 2 | 3 | 4 | 5 ;
export type CSFDFilmTypes =
| 'film'
| 'tv-film'
| 'tv-show'
| 'series'
| 'theatrical'
| 'concert'
| 'season'
| 'student-film'
| 'amateur-film'
| 'music-video'
| 'episode'
| 'video-compilation' ;
export interface CSFDCinema {
id : number ;
name : string ;
city : string ;
url : string ;
coords : { lat : number ; lng : number };
region ?: string ;
screenings : CSFDCinemaGroupedFilmsByDate [];
}
export interface CSFDCinemaGroupedFilmsByDate {
date : string ;
films : CSFDCinemaMovie [];
}
export interface CSFDCinemaMovie extends CSFDMovieListItem {
meta : CSFDCinemaMeta [];
showTimes : string [];
}
export type CSFDCinemaMeta = 'dubbing' | '3D' | 'subtitles' | string ;
export type CSFDCinemaPeriod = 'today' | 'weekend' | 'week' | 'tomorrow' | 'month' ;
Usage Example
import { CSFD } from 'node-csfd-api' ;
import type { CSFDFilmTypes , CSFDColorRating } from 'node-csfd-api' ;
const csfd = new CSFD ();
// Filter by film type
const filterByType = ( type : CSFDFilmTypes ) => {
// Your filtering logic
};
// Get cinema screenings
const cinema = await csfd . cinema ( 123 , 'today' );
console . log ( ` ${ cinema . name } in ${ cinema . city } ` );
console . log ( `Location: ${ cinema . coords . lat } , ${ cinema . coords . lng } ` );
cinema . screenings . forEach (( day ) => {
console . log ( ` \n Date: ${ day . date } ` );
day . films . forEach (( film ) => {
console . log ( ` ${ film . title } ` );
console . log ( ` Meta: ${ film . meta . join ( ', ' ) } ` );
console . log ( ` Times: ${ film . showTimes . join ( ', ' ) } ` );
});
});