Amogh Talpallikar
Amogh Talpallikar

Reputation: 12184

Is there a YouTube API that can give me structured metadata about a video?

Using the YouTube API, how can I fetch structured data about a video? For instance, given a video that is a movie trailer, how can I find the movie title or topic in a structured format, and other interesting metadata such as the celebrities featured or the director?

Upvotes: 4

Views: 8977

Answers (2)

Nick
Nick

Reputation: 3394

I found that I got the metadata details I wanted via this request url:

https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails&id={YouTubeVideoID}&key={YourAPIkey}

Here is documentation with description of all the returned data fields.

Here's info on how to get an API key.

Upvotes: 2

Ikai Lan
Ikai Lan

Reputation: 2240

Yes. The v3 API allows you do do this via videos/list. Here's an example API call using a trailer for The Dark Knight Rises:

GET https://www.googleapis.com/youtube/v3/videos?part=topicDetails&id=g8evyE9TuYk&fields=items%2FtopicDetails%2FtopicIds&key={YOUR_API_KEY}

(To get a developer key, follow the instructions in our video tutorial).

That sets:

topic: topicDetails id: g8evyE9TuYk fields: items/topicDetails/topicIds

In the response body, you get:

{
 "items": [
  {
   "topicDetails": {
    "topicIds": [
     "/m/0bpm4yw",
     "/m/01d5g",
     "/m/0btpm6",
     "/m/0184dt",
     "/m/02vxn"
    ]
   }
  }
 ]
}

These correspond to Freebase mids, which you can lookup using the Freebase API. For instance, the first response corresponds to the Freebase entity The Dark Knight Rises (movie). Once you look up the entity, you can look up related entities such as the director, actors, or genre.

Play around with the API explorer a bit. When you're ready to translate this into code, watch out video about turning the API reference into code.

Upvotes: 6

Related Questions