Complete beginner examples for getting started with the ČSFD API
This guide covers the fundamental operations you’ll need to get started with the ČSFD API. All examples use real, working code from the library’s demo files.
Retrieve comprehensive information about a movie or TV series by its ČSFD ID:
import { csfd } from 'node-csfd-api';// Using async/awaitconst movie = await csfd.movie(621073);console.log(movie.title);console.log(movie.rating);console.log(movie.genres);
Finding Movie IDs: You can find the movie ID in the ČSFD URL. For example, https://www.csfd.cz/film/535121 has ID 535121.
Search for movies, TV series, and users across the ČSFD database:
import { csfd } from 'node-csfd-api';const results = await csfd.search('Tarantino');// Access different result typesconsole.log(results.movies); // Array of moviesconsole.log(results.tvSeries); // Array of TV seriesconsole.log(results.users); // Array of users
1
Import the library
import { csfd } from 'node-csfd-api';
2
Execute search
const results = await csfd.search('matrix');
3
Access results by type
// Loop through moviesresults.movies.forEach(movie => { console.log(`${movie.title} (${movie.year})`);});
Always implement proper error handling when working with the API:
import { csfd } from 'node-csfd-api';try { const movie = await csfd.movie(535121); console.log(movie.title);} catch (error) { console.error('Failed to fetch movie:', error); // Handle the error appropriately}
This is a scraping library. ČSFD may change their HTML structure at any time, which could break the parser. Always implement error handling in production.