Updated on September 14, 2023

Create a movie

POST

You can use the Monolito Movies API to add a new movie to the database. This document provides instructions on how to make a POST request to create a movie entry.

Endpoint

To create a movie, make a POST request to the following endpoint:

Request

Here's an example of how to make a POST request to create a new movie using JavaScript:

const newMovie = {
  title: "Your Movie Title",
  release_date: "YYYY-MM-DD",
  genre: ["Genre1", "Genre2"],
  director: "Director Name",
  actors: ["Actor 1", "Actor 2"],
  plot: "Movie Plot Description",
  rating: 0.0 // Initial rating (optional)
};

const apiUrl = "https://api.monolitomovies.com/v1/movies";

fetch(apiUrl, {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(newMovie)
})
  .then(response => response.json())
  .then(data => {
    console.log("New Movie Created:", data);
  })
  .catch(error => {
    console.error("Error:", error);
  });

In this example, we create a JavaScript object representing the movie's details and use the fetch function to make an HTTP POST request to the /movies endpoint. The API will create a new movie entry based on the provided data.

Response

Upon successful creation, the API will respond with the newly created movie's details in JSON format, including its unique identifier (id) and any additional information provided during the creation process.

Response Example

{
  "id": 54321,
  "title": "Your Movie Title",
  "release_date": "YYYY-MM-DD",
  "genre": ["Genre1", "Genre2"],
  "director": "Director Name",
  "actors": ["Actor 1", "Actor 2"],
  "plot": "Movie Plot Description",
  "rating": 0.0
}

Now you can create new movie entries in the Monolito Movies database via the API. Next, we'll move on to updating movie information using a PATCH request.