ayushnighoskar / Netflix-Clone

Netflix-Clone using HTML+CSS+JS
3 stars 3 forks source link

How to use api? #1

Open coppaxamsukk opened 3 days ago

ayushnighoskar commented 2 days ago
  1. Get API Keys -

Obtain API keys from:

TMDB: Sign up at TMDB and get the API key from your account settings. YouTube: Go to Google Cloud Console, create a project, enable the YouTube Data API v3, and generate your API key.

Replace apikey and searchOnYoutube keys in the code with your actual API keys.

  1. Set Up API Endpoints -

The code defines endpoints to fetch:

Categories from TMDB: fetchAllCategories Movies based on category: fetchMoviesList Trending movies: fetchTrending YouTube search for trailers: searchOnYoutube

You are calling these APIs using fetch and passing the API key in the request.

  1. Fetch and Display Trending Movies -

Function: fetchTrendingMovies()

Action: Fetches trending movies from TMDB and displays one random movie as the banner, using its title, release date, and overview.

  1. Fetch and Display Categories with Movies -

Function: fetchAndBuildAllSections()

Action: Fetches categories from TMDB and lists movies within each category. For each category, the first 6 movies are displayed.

  1. Search for Movie Trailer on YouTube -

Function: searchMovieTrailer(movieName, iframId)

Action: This function uses the movie title to search for a trailer on YouTube using the YouTube API, and embeds the trailer in an iframe on hover.

  1. Initialize the Application -

Function: init()

Action: This function runs on page load, fetching trending movies and movie categories, then building the UI.

  1. HTML Structure -

Ensure your HTML has the necessary containers:

banner-section for the movie banner

movies-cont for movie categories and movie lists

  1. Run the Code -

When the page loads, the init() function is triggered, fetching trending movies, categories, and YouTube trailers, and updating the UI.

This setup will pull movies from TMDB, and trailers from YouTube, and display them dynamically in your project.

coppaxamsukk commented 2 days ago
  1. Get API Keys -

Obtain API keys from:

TMDB: Sign up at TMDB and get the API key from your account settings. YouTube: Go to Google Cloud Console, create a project, enable the YouTube Data API v3, and generate your API key.

Replace apikey and searchOnYoutube keys in the code with your actual API keys.

  1. Set Up API Endpoints -

The code defines endpoints to fetch:

Categories from TMDB: fetchAllCategories Movies based on category: fetchMoviesList Trending movies: fetchTrending YouTube search for trailers: searchOnYoutube

You are calling these APIs using fetch and passing the API key in the request.

  1. Fetch and Display Trending Movies -

Function: fetchTrendingMovies()

Action: Fetches trending movies from TMDB and displays one random movie as the banner, using its title, release date, and overview.

  1. Fetch and Display Categories with Movies -

Function: fetchAndBuildAllSections()

Action: Fetches categories from TMDB and lists movies within each category. For each category, the first 6 movies are displayed.

  1. Search for Movie Trailer on YouTube -

Function: searchMovieTrailer(movieName, iframId)

Action: This function uses the movie title to search for a trailer on YouTube using the YouTube API, and embeds the trailer in an iframe on hover.

  1. Initialize the Application -

Function: init()

Action: This function runs on page load, fetching trending movies and movie categories, then building the UI.

  1. HTML Structure -

Ensure your HTML has the necessary containers:

banner-section for the movie banner #movies-cont for movie categories and movie lists

  1. Run the Code -

When the page loads, the init() function is triggered, fetching trending movies, categories, and YouTube trailers, and updating the UI.

This setup will pull movies from TMDB, and trailers from YouTube, and display them dynamically in your project.

Noo. I wanna use gogoanime api