net – YouTube V3 API – Search for videos by title



I'm using youtube V3 API to fetch videos from a .net project. Turns out I have the exact title and I need to search for it. In the documentation it is not clear whether it is possible to search by title. API documentation

Today I have the approximate date, so I use the PublishedAfter and PublishedBefore properties, then scroll through the results list to look for the video with the title I need. I would like to optimize my query since I own the video title.


Considering that you already have the API Key and it is enabled, in summary:

var query = 'mutant giant spider dog'
gapi.client.load('youtube', 'v3', function() {

   var request ={
        part: 'snippet',
        q: query,
        maxResults: 1
    request.execute(function(response) {
       $.each(response.items, function(i, item) {
          var idVideo = item['id']['videoId'];
          var urlVideo = "" + idVideo;
          //FAZ O QUE QUISER COM OS DADOS. title, description,..

I set maxResults to 1 to bring up the most relevant video based on the name, so if I pass the full name it should be first on the list. But if you want to iterate through the list, increase the maxResult as in jsfiddler below.

Test on this Fiddler:

Note: remember to load the JQuery and Google API

================================================== ==========

Querying via C# is very similar too:

YoutubeService youtube = new YoutubeService(new BaseClientService.Initializer() {
    ApiKey = credentials.ApiKey

SearchResource.ListRequest listRequest = youtube.Search.List("snippet");
listRequest.Q = CommandLine.RequestUserInput<string>("Search term: ");
listRequest.Order = SearchResource.Order.Relevance;

SearchListResponse searchResponse = listRequest.Fetch();
foreach (SearchResult searchResult in searchResponse.Items)

Full example:

Download lib:

Scroll to Top