
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
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 2 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.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.