0

Although I can easily do this on the YouTube.com advanced search page, I can't seem to get it to work with their API.

E.g.: From the explorer page

Does anyone know the trick to getting this to work?

Mohit Bhansali
  • 1,725
  • 4
  • 20
  • 43
user230347
  • 71
  • 1
  • 1
  • 3

1 Answers1

1

You can search by video quality, duration, upload date, and keywords using the Search of the YouTube Data API v3

https://developers.google.com/youtube/v3/docs/search

you can use the following filters:

publishedAfter / datetime

publishedBefore / datetime

q / string (keywords)

videoDefinition / string (any /high /standard )

videoDuration / string (any /long /medium /short )

and also you must be careful and set the type parameter as video to specify this filters.

This is a sample call:

Request:

GET https://www.googleapis.com/youtube/v3/search?part=snippet&publishedAfter=2011-01-01T00%3A00%3A00Z&q=coke&type=video&videoDefinition=high&videoDuration=short&key={YOUR_API_KEY}

Response:

200 OK

- Show headers -

{
 "kind": "youtube#searchListResponse",
 "etag": "\"rFqCJSkEICLP3Hq6a4AADI7kf48/aTddnYr9r7d0D4Q5PzPGfWpsecI\"",
 "pageInfo": {
  "totalResults": 1000000,
  "resultsPerPage": 5
 },
 "nextPageToken": "CAUQAA",
 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": "\"rFqCJSkEICLP3Hq6a4AADI7kf48/Ej9FPd2YyubbQoYtuBZ_tT1Zjck\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "5T68TvdoSbI"
   },
   "snippet": {
    "publishedAt": "2013-06-20T15:00:35.000Z",
    "channelId": "UC1zZE_kJ8rQHgLTVfobLi_g",
    "title": "Self Freezing Coca-Cola (The trick that works on any soda!)",
    "description": "Take any bottle of soda, and get it to freeze on command! This \"super cool\" trick works with cans of soda as well. To date, I haven't seen any tutorials on e...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/5T68TvdoSbI/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/5T68TvdoSbI/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/5T68TvdoSbI/hqdefault.jpg"
     }
    },
    "channelTitle": "01032010814"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"rFqCJSkEICLP3Hq6a4AADI7kf48/TAH9npB-WK5-tntpUczojivt_nk\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "FaMWxLCGY0U"
   },
   "snippet": {
    "publishedAt": "2011-04-23T00:57:00.000Z",
    "channelId": "UCIgKGGJkt1MrNmhq3vRibYA",
    "title": "Gallium Induced Structural Failure of a Coke Can",
    "description": "We show how a normally strong and robust coke can is turned into the equivalent of wet tissue paper with gallium. If you want some gallium yourself, you can ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/FaMWxLCGY0U/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/FaMWxLCGY0U/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/FaMWxLCGY0U/hqdefault.jpg"
     }
    },
    "channelTitle": "NurdRage"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"rFqCJSkEICLP3Hq6a4AADI7kf48/ZbkW-ovCwrd7bU0s44Yc6ZNF8uQ\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "KEBJmZL8G1E"
   },
   "snippet": {
    "publishedAt": "2012-06-06T20:16:20.000Z",
    "channelId": "UCosXctaTYxN4YPIvI5Fpcrw",
    "title": "The Most Outrageous Way to Share a Coke",
    "description": "What is the most outrageous way to share a Coke? Watch this video to see what iJustine, Josh TheComputerNerd01 and a few new friends came up with -- an ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/KEBJmZL8G1E/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/KEBJmZL8G1E/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/KEBJmZL8G1E/hqdefault.jpg"
     }
    },
    "channelTitle": "cocacola"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"rFqCJSkEICLP3Hq6a4AADI7kf48/I04dl1Hbm3FTzhGu8xIbRfHQ5XM\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "b6u9WJ01Oxs"
   },
   "snippet": {
    "publishedAt": "2011-09-28T01:01:55.000Z",
    "channelId": "UCUK0HBIBWgM2c4vsPhkYY4w",
    "title": "EPIC Mentos and Coke - The Slow Mo Guys",
    "description": "Volume UP, Watch in HD! Gav and Dan bring you the most epic mentos and coke video ever. Well, I say epic... It's more accurately the MOST OVERLY DRAMATIC men...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/b6u9WJ01Oxs/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/b6u9WJ01Oxs/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/b6u9WJ01Oxs/hqdefault.jpg"
     }
    },
    "channelTitle": "theslowmoguys"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": "\"rFqCJSkEICLP3Hq6a4AADI7kf48/JlSU5F38dpMSZwynbS2ztIpSNr8\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "gy5hTC1ox9A"
   },
   "snippet": {
    "publishedAt": "2013-05-29T06:22:07.000Z",
    "channelId": "UCDZESjYAwh-ws7ZSZZ8DKeg",
    "title": "2 Liter Diet Coke Challenge (No Burping)",
    "description": "L.A. BEAST responds to a challenge created by fellow competitive eater Matt \"The Megatoad\" Stonie, in which one must drink an entire 2 liter bottle of Diet C...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/gy5hTC1ox9A/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/gy5hTC1ox9A/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/gy5hTC1ox9A/hqdefault.jpg"
     }
    },
    "channelTitle": "skippy62able"
   }
  }
 ]
}
Matias Molinas
  • 2,246
  • 15
  • 11