The userRatings() method fetches a user’s movie and TV series ratings from their ČSFD profile. It supports pagination, filtering, and bulk fetching.
Signature
csfd . userRatings (
user : string | number ,
config ?: CSFDUserRatingConfig ,
options ?: CSFDOptions
): Promise < CSFDUserRatings [] >
Parameters
User identifier. Can be:
User ID as number: 912
Username string: '912-bart'
Username without ID: 'bart'
You can find this in the user’s profile URL:
https://www.csfd.cz/uzivatel/912-bart/
Configuration options for filtering and pagination Specific page number to fetch (default: 1)
Fetch all rating pages (default: false) Use with caution! Set allPagesDelay to avoid rate limiting.
Delay between page requests in milliseconds (default: 0) Recommended: 2000-5000ms when using allPages: true
Include only specific content types Available types: ‘film’, ‘series’, ‘tv-film’, ‘tv-show’, ‘episode’, ‘season’, ‘theatrical’, ‘concert’, ‘student-film’, ‘amateur-film’, ‘music-video’, ‘video-compilation’
Exclude specific content types includesOnly and excludes are mutually exclusive. If both are provided, includesOnly takes precedence.
Override default options for this request Preferred language for content (default: ‘cs’)
Custom fetch request options (headers, timeout, etc.)
Returns
Array of user ratings Full URL to the movie page
Content type (e.g., ‘film’, ‘series’, ‘episode’)
colorRating
'bad' | 'average' | 'good' | 'unknown'
Overall ČSFD rating indicator
Date when the user rated the movie (format: DD.MM.YYYY)
Examples
Basic Usage
import { csfd } from 'node-csfd-api' ;
// Get latest ratings (first page)
const ratings = await csfd . userRatings ( '912-bart' );
ratings . forEach ( rating => {
console . log ( ` ${ rating . title } ( ${ rating . year } ): ${ rating . userRating } /5` );
});
Get Specific Page
// Get second page of ratings
const page2 = await csfd . userRatings ( '912-bart' , { page: 2 });
// Get third page
const page3 = await csfd . userRatings ( '912-bart' , { page: 3 });
Fetch All Ratings with Rate Limiting
// Fetch all ratings with 2-second delay between requests
const allRatings = await csfd . userRatings ( '912-bart' , {
allPages: true ,
allPagesDelay: 2000 // 2 seconds between requests
});
console . log ( `User has rated ${ allRatings . length } items` );
Filter by Content Type
// Get only movie ratings (exclude series, episodes, etc.)
const onlyMovies = await csfd . userRatings ( '912-bart' , {
includesOnly: [ 'film' ]
});
// Get movies and TV films
const moviesAndTvFilms = await csfd . userRatings ( '912-bart' , {
includesOnly: [ 'film' , 'tv-film' ]
});
// Exclude episodes and seasons
const noEpisodes = await csfd . userRatings ( '912-bart' , {
excludes: [ 'episode' , 'season' ]
});
Calculate Statistics
const ratings = await csfd . userRatings ( '912' , {
allPages: true ,
allPagesDelay: 2000
});
// Calculate average rating
const totalStars = ratings . reduce (( sum , r ) => sum + r . userRating , 0 );
const average = totalStars / ratings . length ;
console . log ( `Average rating: ${ average . toFixed ( 2 ) } /5` );
// Count by star rating
const starCounts = ratings . reduce (( acc , r ) => {
acc [ r . userRating ] = ( acc [ r . userRating ] || 0 ) + 1 ;
return acc ;
}, {} as Record < number , number >);
console . log ( 'Ratings distribution:' , starCounts );
Find Highly Rated Films
const ratings = await csfd . userRatings ( '912-bart' );
// Get 5-star ratings only
const fiveStars = ratings . filter ( r => r . userRating === 5 );
console . log ( '5-star movies:' );
fiveStars . forEach ( movie => {
console . log ( ` - ${ movie . title } ( ${ movie . year } )` );
});
Export Ratings
import { csfd } from 'node-csfd-api' ;
import { writeFileSync } from 'fs' ;
async function exportRatings ( username : string ) {
const ratings = await csfd . userRatings ( username , {
allPages: true ,
allPagesDelay: 2000 ,
includesOnly: [ 'film' ] // Only export movies
});
// Convert to CSV
const csv = [
'Title,Year,Rating,Date' ,
... ratings . map ( r =>
`" ${ r . title } ", ${ r . year } , ${ r . userRating } , ${ r . userDate } `
)
]. join ( ' \n ' );
writeFileSync ( ` ${ username } -ratings.csv` , csv );
console . log ( `Exported ${ ratings . length } ratings` );
}
await exportRatings ( '912-bart' );
Using User ID
// All of these are valid:
const ratings1 = await csfd . userRatings ( 912 );
const ratings2 = await csfd . userRatings ( '912' );
const ratings3 = await csfd . userRatings ( '912-bart' );
Rate Limiting
When using allPages: true, ČSFD may detect automated requests and temporarily block your IP. Always use allPagesDelay with a reasonable value (2000-5000ms recommended).
// Good - with delay
const ratings = await csfd . userRatings ( '912-bart' , {
allPages: true ,
allPagesDelay: 3000 // 3 seconds
});
// Bad - no delay (may get blocked)
const ratings = await csfd . userRatings ( '912-bart' , {
allPages: true
});