Search code examples
youtubeyoutube-apiyoutube-data-api

YouTube Data API can't search the video


I'm using YouTube Data API v3.

I want to find a video published at "2020-01-01T11:19:05.000Z"

so I used code like this.

type='video',
part='snippet',
maxResults=50,
pageToken=options.nextPageToken,
publishedAfter="2020-01-01T11:18:05.000Z",
publishedBefore="2020-01-01T11:20:05.000Z",
regionCode="KR",

But api couldn't find the video I wanted. so I added the q parameter.

q="보겸"

Now api found the video I wanted. Why the api needs q parameter to find video?


Solution

  • The q parameter specifies the query term to search for.

    Your request can also use the Boolean NOT (-) and OR (|) operators to exclude videos or to find videos that are associated with one of several search terms.

    For example, to search for videos matching either "boating" or "sailing", set the q parameter value to boating|sailing. Similarly, to search for videos matching either "boating" or "sailing" but not "fishing", set the q parameter value to boating|sailing -fishing.

    Note that the pipe character must be URL-escaped when it is sent in your API request. The URL-escaped value for the pipe character is %7C. (source: ./youtube/v3/docs/search/list)