Updated on Sep 14, 2023

2

min read

Retrieve a movie

GET

The Movies API allows you to access detailed information about a specific movie using its unique identifier (ID). This document provides a comprehensive guide on how to make a GET request to retrieve movie data.

Endpoint

To retrieve a movie, you need to make a GET request to the following endpoint:

GET /movies/{movie_id}

Replace {movie_id} with the unique identifier of the movie you are interested in.

Request

Here's an example of how to make a GET request to retrieve movie information using JavaScript:

const movieId = 12345; // Replace with the actual movie ID
const apiUrl = `https://api.moviesapi.com/v1/movies/${movieId}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => {
    console.log("Movie Details:", data);
  })
  .catch(error => {
    console.error("Error:", error);
  });

In this example, we use the fetch function to make an HTTP GET request to the specified API endpoint, replacing 12345 with the actual movie ID you want to retrieve.

Response

The API will respond with detailed information about the movie in JSON format. Here's an example response:

{
  "id": 12345,
  "title": "The Shawshank Redemption",
  "release_date": "1994-09-23",
  "genre": ["Drama", "Crime"],
  "director": "Frank Darabont",
  "actors": ["Tim Robbins", "Morgan Freeman"],
  "plot": "Two imprisoned men bond over a number of years (...)",
  "rating": 9.3
}

Response Explanation

  • id: The unique identifier of the movie.

  • title: The title of the movie.

  • release_date: The release date of the movie.

  • genre: An array of genres associated with the movie.

  • director: The director of the movie.

  • actors: An array of actors in the movie.

  • plot: A brief description of the movie's plot.

  • rating: The average user rating for the movie.

Now that you know how to retrieve movie information, you can explore the Movies API further by making requests for specific movies or implementing more advanced queries.