Adi
Adi

Reputation: 762

Getting actor IMDB ID's from a Film IMDB ID in a single query

So, with this query, I can get the actors in the film:

[{
  "type": "/film/film",
  "imdb_id": "tt0090605",
  "starring": [{
    "actor": null
  }],
  "limit": 1
}]

And with this query, I can get the IMDB_ID for an actor:

[{
  "type": "/people/person",
  "name": "Lance Henriksen",
  "date_of_birth": "1940-05-05",
  "key": [{
    "namespace": "/authority/imdb/name",
    "value": null
  }],
  "limit": 1
}]

I am wondering if it is possible to combine the two. So given an IMDB ID for a film, it will return the respective actors and their IMDB IDs?

I am guessing it isn't possible within MQL and am happy with that as an answer, just curious as to whether that sort of query is possible.

Thanks!

Upvotes: 2

Views: 1487

Answers (1)

Tom Morris
Tom Morris

Reputation: 10540

Sure it's possible. Queries can be nested to arbitrary depths. If you want the IMDB IDs, birth dates, and names of the stars, just use a query like this:

[{
  "type": "/film/film",
  "imdb_id": "tt0090605",
  "name": null,
  "starring": [{
    "actor": [{
      "name": null,
      "mid": null,
      "/people/person/date_of_birth": null,
      "key": [{
        "namespace": "/authority/imdb/name",
        "value": null
      }]
    }],
    "limit": 1
  }]
}]

for your example, you'll get a result that looks like this:

{
  "result": [{
    "name": "Aliens",
    "imdb_id": "tt0090605",
    "type": "/film/film",
    "starring": [{
      "actor": [{
        "name": "Sigourney Weaver",
        "/people/person/date_of_birth": "1949-10-08",
        "key": [{
          "value": "nm0000244",
          "namespace": "/authority/imdb/name"
        }],
        "mid": "/m/0h96g"
      }]
    }]
  }]
}

Upvotes: 1

Related Questions