Get started with moviedb CDN

MIT licensed

Moviedb is a library for accessing the Movie Database API to search, discover, and retrieve movie and TV show information.

Tags:
  • themoviedb
  • api
  • tmdb

Stable version

Copied!

How to start using moviedb CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with moviedb CDN - cdnhub.io</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="https://cdn.cdnhub.io/moviedb/0.2.12/moviedb.min.js"></script>
</head>
<body>
    <button id="search-btn">Search Movie</button>
    <input type="text" id="search-input" placeholder="Enter movie title">
    <div id="movie-info"></div>

    <script>
      const apiKey = 'YOUR_API_KEY';
      const axios = require('axios');
      const Movie = require('moviedb-api');

      const movieDb = new Movie({apiKey});

      const searchBtn = document.getElementById('search-btn');
      const searchInput = document.getElementById('search-input');
      const movieInfo = document.getElementById('movie-info');

      searchBtn.addEventListener('click', async () => {
        const movieTitle = searchInput.value;
        try {
          const movie = await movieDb.search(movieTitle).then(response => response.data.results[0]);
          movieInfo.innerHTML = `
            <h2>${movie.title}</h2>
            <p>Release date: ${movie.release_date}</p>
            <p>Overview: ${movie.overview}</p>
          `;
        } catch (error) {
          console.error(error);
        }
      });
    </script>
</body>
</html>
Copied!
Copied!

All versions