sf9251
sf9251

Reputation: 288

Search Videos by keyword using YouTube Data API V3

My goal is to search for YouTube videos that matches the input keyword using YouTube Data API v3. Now, YouTube Data API v3 allows you to only search for videos uploaded via the developer's application or website using the 'q' parameter but it does not allow you to make a generic search for videos matching the input search keyword as we do in the YouTube Application.

Please correct me if I missed something in the guide or if there is some workaround to achieve this.

Upvotes: 5

Views: 24735

Answers (1)

SCPhantom
SCPhantom

Reputation: 430

I made a YouTube App once myself and the following link is working for me:

https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=20&q=YOURKEYWORD&type=video&key=YOURAPIKEY

Make sure you have a registered API-Key which you can get from Google for free. The answer of the server will be in JSON-Format, which you should already be familiar with.

This is now returning a list which contains 20 entries, each representing one YouTube video, just as if you would enter a keyword in the searchbox on youtube.com.

Example for "zoo" as keyword and with my API-Key:

{
 "kind": "youtube#searchListResponse",
 "etag": "\"q5k97EMVGxODeKcDgp8gnMu79wM/EkP6ScMYfT4xPyx9BIwzJc1IcsM\"",
 "nextPageToken": "CBQQAA",
 "regionCode": "DE",
 "pageInfo": {
  "totalResults": 1000000,
  "resultsPerPage": 20
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": "\"q5k97EMVGxODeKcDgp8gnMu79wM/gWwm8abtbKoWg-uMt7NUmwSLzbA\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "iVIjckwltkk"
   },
   "snippet": {
    "publishedAt": "2014-02-25T18:22:56.000Z",
    "channelId": "UChl6CG-V7LgqhfwkvbHH67Q",
    "title": "Kids At The Zoo: Compilation",
    "description": "In this funny animal video, tune in to see an awesome compilation of kids interacting with their favorite animals at the zoo. SUBSCRIBE TO PETSAMI: ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/iVIjckwltkk/default.jpg",
      "width": 120,
      "height": 90
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/iVIjckwltkk/mqdefault.jpg",
      "width": 320,
      "height": 180
     },
     "high": {
      "url": "https://i.ytimg.com/vi/iVIjckwltkk/hqdefault.jpg",
      "width": 480,
      "height": 360
     }
    },
    "channelTitle": "Kyoot Animals",
    "liveBroadcastContent": "none"
   }
  }, ... and so on
 ]
}

Upvotes: 16

Related Questions