Updated on Sep 14, 2023

2

min read

Retrieve an actor

GET

You can retrieve detailed information about a specific actor from the Movies API by using the actor's unique identifier (ID). This document provides instructions on how to make a GET request to retrieve actor data.

Endpoint

To retrieve an actor, make a GET request to the following endpoint:

GET /actors/{actor_id}

Replace {actor_id} with the unique identifier of the actor you want to retrieve.

Request

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

const actorId = 123; // Replace with the actual actor ID
const apiUrl = `https://api.moviesapi.com/v1/actors/${actorId}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => {
    console.log("Actor 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. Replace 123 with the actual actor ID you want to retrieve.

Response

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

{
  "id": 123,
  "name": "Morgan Freeman",
  "birthdate": "1937-06-01",
  "nationality": "American",
  "biography": "Morgan Freeman is a renowned American actor...",
  "movies": [
    {
      "id": 54321,
      "title": "The Shawshank Redemption",
      "release_date": "1994-09-23",
      "character": "Ellis Boyd 'Red' Redding"
    },
    {
      "id": 98765,
      "title": "Seven",
      "release_date": "1995-09-22",
      "character": "Detective Somerset"
    }
  ]
}

Response Explanation

  • id: The unique identifier of the actor.

  • name: The full name of the actor.

  • birthdate: The birthdate of the actor (if available).

  • nationality: The nationality of the actor (if available).

  • biography: A brief biography or description of the actor (if available).

  • movies: An array of movies associated with the actor. Each movie object includes details about the movie and the character played by the actor.

You can now retrieve detailed information about specific actors using the Movies API. Next, we'll cover other actions related to actors.