Overview
The user types module contains TypeScript interfaces for user-specific data, including user ratings, reviews, and their configuration options.
CSFDUserRatings
Represents a user’s rating for a movie or TV show.
Full ČSFD URL to the movie page
Type of film (film, series, tv-show, etc.)
Overall aggregated rating color: ‘bad’, ‘average’, ‘good’, or ‘unknown’
Date when the rating was given (formatted string)
CSFDUserRatingConfig
Configuration options for fetching user ratings.
Only include these film types in results
Exclude these film types from results
Fetch all ratings across all pages. Warning: Use wisely to avoid detection and bans. Consider using with allPagesDelay.
Delay between page requests in milliseconds (when using allPages)
Specific page number to fetch (e.g., 2 for second page)
CSFDUserReviews
Represents a user’s written review for a movie or TV show.
Full ČSFD URL to the movie page
Type of film (film, series, tv-show, etc.)
Overall aggregated rating color: ‘bad’, ‘average’, ‘good’, or ‘unknown’
Date when the review was written, or null if not available
CSFDUserReviewsConfig
Configuration options for fetching user reviews.
Only include these film types in results
Exclude these film types from results
Fetch all reviews across all pages. Warning: Use wisely to avoid detection and bans. Consider using with allPagesDelay.
Delay between page requests in milliseconds (when using allPages)
Specific page number to fetch (e.g., 2 for second page)
Type Definitions
CSFDColors
Colors used in the ČSFD interface:
type CSFDColors = 'lightgrey' | 'blue' | 'red' | 'grey';
Import Example
import type {
CSFDUserRatings,
CSFDUserRatingConfig,
CSFDUserReviews,
CSFDUserReviewsConfig,
CSFDColors,
} from 'node-csfd-api';
TypeScript Interface
import { CSFDFilmTypes, CSFDScreening, CSFDStars } from './global';
export interface CSFDUserRatings extends CSFDScreening {
userRating: CSFDStars;
userDate: string;
}
export interface CSFDUserRatingConfig {
includesOnly?: CSFDFilmTypes[];
excludes?: CSFDFilmTypes[];
allPages?: boolean;
allPagesDelay?: number;
page?: number;
}
export interface CSFDUserReviews extends CSFDScreening {
userRating: CSFDStars;
userDate: string | null;
text: string;
poster: string;
}
export interface CSFDUserReviewsConfig {
includesOnly?: CSFDFilmTypes[];
excludes?: CSFDFilmTypes[];
allPages?: boolean;
allPagesDelay?: number;
page?: number;
}
export type CSFDColors = 'lightgrey' | 'blue' | 'red' | 'grey';
Usage Example
import { CSFD } from 'node-csfd-api';
const csfd = new CSFD();
// Fetch user ratings with configuration
const ratings = await csfd.userRatings('username', {
includesOnly: ['film', 'series'],
page: 1,
});
ratings.forEach((rating) => {
console.log(`${rating.title} (${rating.year})`);
console.log(`User rating: ${rating.userRating} stars`);
console.log(`Rated on: ${rating.userDate}`);
});
// Fetch user reviews with pagination
const reviews = await csfd.userReviews('username', {
excludes: ['episode'],
page: 1,
allPages: false,
});
reviews.forEach((review) => {
console.log(`${review.title} (${review.year})`);
console.log(`Rating: ${review.userRating} stars`);
console.log(`Review: ${review.text.substring(0, 100)}...`);
});
// Fetch all ratings with delay (use carefully!)
const allRatings = await csfd.userRatings('username', {
allPages: true,
allPagesDelay: 2000, // 2 seconds between requests
});
When using allPages: true, always set a reasonable allPagesDelay to avoid being detected as a bot and potentially banned from ČSFD.