
Product
Socket Now Protects the Chrome Extension Ecosystem
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
tmdb-ts-sdk
Advanced tools
A robust, type-safe, and user-friendly TypeScript SDK for The Movie Database (TMDB) API. This SDK provides comprehensive access to TMDB's endpoints while following modern TypeScript and JavaScript best practices.
npm install tmdb-typescript-sdk
or
yarn add tmdb-typescript-sdk
import { TMDBClient } from 'tmdb-typescript-sdk';
// Initialize the client with your API key
const tmdb = new TMDBClient({
auth: {
apiKey: 'your_api_key_here'
}
});
// Get popular movies
async function getPopularMovies() {
try {
const movies = await tmdb.movies.getPopular();
console.log(movies.results);
} catch (error) {
console.error('Error fetching popular movies:', error);
}
}
// Get movie details
async function getMovieDetails(movieId: number) {
try {
const movie = await tmdb.movies.getDetails({ movieId });
console.log(`${movie.title} (${movie.release_date.split('-')[0]})`);
console.log(movie.overview);
} catch (error) {
console.error('Error fetching movie details:', error);
}
}
// Search for movies
async function searchMovies(query: string) {
try {
const results = await tmdb.search.movies({ query });
console.log(`Found ${results.total_results} movies matching "${query}"`);
results.results.forEach(movie => {
console.log(`${movie.title} (${movie.release_date?.split('-')[0] || 'N/A'})`);
});
} catch (error) {
console.error('Error searching movies:', error);
}
}
For full documentation and examples, please see the API Reference.
// Get a poster image URL
const posterUrl = tmdb.images.getPosterUrl({
path: movie.poster_path,
size: 'w500'
});
// Get a backdrop image URL
const backdropUrl = tmdb.images.getBackdropUrl({
path: movie.backdrop_path,
size: 'original'
});
// Initialize with caching enabled
const tmdb = new TMDBClient({
auth: {
apiKey: 'your_api_key_here'
},
cache: {
enabled: true,
maxSize: 100, // Maximum cache entries
ttl: 300000 // Cache TTL in milliseconds (5 minutes)
}
});
try {
const movie = await tmdb.movies.getDetails({ movieId: 123 });
// Process movie data
} catch (error) {
if (error instanceof HttpError) {
console.error(`HTTP Error ${error.status}: ${error.message}`);
} else if (error instanceof RateLimitError) {
console.error(`Rate limit exceeded. Retry after ${error.retryAfter}ms`);
} else {
console.error('Unexpected error:', error);
}
}
See the examples directory for more usage examples.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A TypeScript SDK for The Movie Database (TMDB) API
The npm package tmdb-ts-sdk receives a total of 0 weekly downloads. As such, tmdb-ts-sdk popularity was classified as not popular.
We found that tmdb-ts-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.