
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
@elselab-io/node-tmdb-sdk
Advanced tools
A lightweight JavaScript SDK for The Movie Database (TMDB) REST API
A lightweight JavaScript SDK for The Movie Database (TMDB) REST API. This SDK provides a simple and intuitive way to interact with TMDB's API endpoints.
npm install @elselab-io/node-tmdb-sdk
import TMDB from '@elselab-io/node-tmdb-sdk';
// Initialize the SDK with your API key
const tmdb = new TMDB('your-api-key');
// Get movie details
const movie = await tmdb.movie.getDetails('550'); // Fight Club
console.log(movie.title); // "Fight Club"
Check out the examples
directory for more detailed usage examples. Here's a quick example showing how to get movie details with additional data:
const movieDetails = await tmdb.movie.getDetails('238', {
language: 'en-US',
append_to_response: 'videos,credits'
});
console.log({
title: movieDetails.title,
director: movieDetails.credits.crew.find(person => person.job === 'Director')?.name,
cast: movieDetails.credits.cast.slice(0, 5).map(actor => actor.name)
});
The SDK includes a flexible caching system to improve performance and reduce API calls. You can use either file-based caching or Redis caching.
import TMDB, { FileCacheAdapter } from '@elselab-io/node-tmdb-sdk';
// Create a file cache adapter
const fileCache = new FileCacheAdapter({
directory: './tmdb-cache', // Cache directory (default: './cache')
defaultTTL: 3600 // Cache TTL in seconds (default: 1 hour)
});
// Initialize TMDB with the file cache
const tmdb = new TMDB('your-api-key', {
cache: fileCache,
enableCache: true, // Enable caching (default: true)
cacheTTL: 3600 // Default TTL in seconds (default: 1 hour)
});
// Use the SDK as usual - responses will be cached automatically
const movie = await tmdb.movie.getDetails('550');
import TMDB, { RedisCacheAdapter } from '@elselab-io/node-tmdb-sdk';
import { createClient } from 'redis'; // You need to install redis package
// Create Redis client
const redisClient = createClient();
await redisClient.connect();
// Create a Redis cache adapter
const redisCache = new RedisCacheAdapter(redisClient, {
keyPrefix: 'tmdb:', // Prefix for cache keys (default: 'tmdb:')
defaultTTL: 3600 // Default TTL in seconds (default: 1 hour)
});
// Initialize TMDB with the Redis cache
const tmdb = new TMDB('your-api-key', {
cache: redisCache
});
// Use the SDK as usual - responses will be cached in Redis
const movie = await tmdb.movie.getDetails('550');
You can disable caching for specific requests by passing an options object as the third parameter:
// This request will bypass the cache
const freshMovie = await tmdb.movie.getDetails('550', { language: 'en-US' }, {
useCache: false
});
See the examples/cache-examples.js
file for more detailed examples of using the caching system.
To use this SDK, you'll need a TMDB API key. You can obtain one by:
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
A lightweight JavaScript SDK for The Movie Database (TMDB) REST API
The npm package @elselab-io/node-tmdb-sdk receives a total of 1 weekly downloads. As such, @elselab-io/node-tmdb-sdk popularity was classified as not popular.
We found that @elselab-io/node-tmdb-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.