Docs    YouTube    Getting Started

Guide to Creating a Custom Search

You can create a completely custom search query using the custom search input field and the parameters show below.

How to Format a Custom Search
For each parameter you add, start with an ampersand “&” then the parameter key (ex: “order”) then an equals sign “=” then an accepted value (ex: “date”). Do not add any URL encoding as the plugin will properly encode the final search query.

Examples
&q=Funny Cat Videos&order=viewCount
&channelId=UClwg08ECyHnm_RzY1wnZC1A&publishedAfter=2019-06-30T00:00:00Z&publishedBefore=2020-01-30T00:00:00Z
&q=Gooseberry Falls&videoDuration=short

Parameter Key Accepted Values
relatedToVideoId string
The relatedToVideoId parameter retrieves a list of videos that are related to the video that the parameter value identifies. The parameter value must be set to a YouTube video ID.Note: If the relatedToVideoId parameter is set, the only other supported parameters are regionCode, relevanceLanguage, safeSearch, and fields.
channelId string
The channelId parameter indicates that the API response should only contain resources created by the channel.
eventType string
The eventType parameter restricts a search to broadcast events.
Acceptable values are:

  • completed – Only include completed broadcasts.
  • live – Only include active broadcasts.
  • upcoming – Only include upcoming broadcasts.
location string
The location parameter, in conjunction with the locationRadius parameter, defines a circular geographic area and also restricts a search to videos that specify, in their metadata, a geographic location that falls within that area. The parameter value is a string that specifies latitude/longitude coordinates e.g. (37.42307,-122.08427).

  • The location parameter value identifies the point at the center of the area.
  • The locationRadius parameter specifies the maximum distance that the location associated with a video can be from that point for the video to still be included in the search results.

The API returns an error if your request specifies a value for the location parameter but does not also specify a value for the locationRadius parameter.

locationRadius string
The locationRadius parameter, in conjunction with the location parameter, defines a circular geographic area.The parameter value must be a floating point number followed by a measurement unit. Valid measurement units are m, km, ft, and mi. For example, valid parameter values include 1500m, 5km, 10000ft, and 0.75mi. The API does not support locationRadius parameter values larger than 1000 kilometers.Note: See the definition of the location parameter for more information.
order string
The order parameter specifies the method that will be used to order resources in the API response. The default value is relevance.Acceptable values are:

  • date – Resources are sorted in reverse chronological order based on the date they were created.
  • rating – Resources are sorted from highest to lowest rating.
  • relevance – Resources are sorted based on their relevance to the search query. This is the default value for this parameter.
  • title – Resources are sorted alphabetically by title.
  • viewCount – Resources are sorted from highest to lowest number of views. For live broadcasts, videos are sorted by number of concurrent viewers while the broadcasts are ongoing.
publishedAfter datetime
The publishedAfter parameter indicates that the API response should only contain resources created at or after the specified time. The value is an RFC 3339 formatted date-time value (1970-01-01T00:00:00Z).
publishedBefore datetime
The publishedBefore parameter indicates that the API response should only contain resources created before or at the specified time. The value is an RFC 3339 formatted date-time value (1970-01-01T00:00:00Z).
q string
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.
regionCode string
The regionCode parameter instructs the API to return search results for videos that can be viewed in the specified country. The parameter value is an ISO 3166-1 alpha-2 country code.
relevanceLanguage string
The relevanceLanguage parameter instructs the API to return search results that are most relevant to the specified language. The parameter value is typically an ISO 639-1 two-letter language code. However, you should use the values zh-Hans for simplified Chinese and zh-Hant for traditional Chinese. Please note that results in other languages will still be returned if they are highly relevant to the search query term.
safeSearch string
The safeSearch parameter indicates whether the search results should include restricted content as well as standard content.Acceptable values are:

  • moderate – YouTube will filter some content from search results and, at the least, will filter content that is restricted in your locale. Based on their content, search results could be removed from search results or demoted in search results. This is the default parameter value.
  • none – YouTube will not filter the search result set.
  • strict – YouTube will try to exclude all restricted content from the search result set. Based on their content, search results could be removed from search results or demoted in search results.
topicId string
The topicId parameter indicates that the API response should only contain resources associated with the specified topic. The value identifies a Freebase topic ID.Important: Due to the deprecation of Freebase and the Freebase API, the topicId parameter started working differently as of February 27, 2017. At that time, YouTube started supporting a small set of curated topic IDs, and you can only use that smaller set of IDs as values for this parameter.

Topics
Music topics
/m/04rlf Music (parent topic)
/m/02mscn Christian music
/m/0ggq0m Classical music
/m/01lyv Country
/m/02lkt Electronic music
/m/0glt670 Hip hop music
/m/05rwpb Independent music
/m/03_d0 Jazz
/m/028sqc Music of Asia
/m/0g293 Music of Latin America
/m/064t9 Pop music
/m/06cqb Reggae
/m/06j6l Rhythm and blues
/m/06by7 Rock music
/m/0gywn Soul music
Gaming topics
/m/0bzvm2 Gaming (parent topic)
/m/025zzc Action game
/m/02ntfj Action-adventure game
/m/0b1vjn Casual game
/m/02hygl Music video game
/m/04q1x3q Puzzle video game
/m/01sjng Racing video game
/m/0403l3g Role-playing video game
/m/021bp2 Simulation video game
/m/022dc6 Sports game
/m/03hf_rm Strategy video game
Sports topics
/m/06ntj Sports (parent topic)
/m/0jm_ American football
/m/018jz Baseball
/m/018w8 Basketball
/m/01cgz Boxing
/m/09xp_ Cricket
/m/02vx4 Football
/m/037hz Golf
/m/03tmr Ice hockey
/m/01h7lh Mixed martial arts
/m/0410tth Motorsport
/m/07bs0 Tennis
/m/07_53 Volleyball
Entertainment topics
/m/02jjt Entertainment (parent topic)
/m/09kqc Humor
/m/02vxn Movies
/m/05qjc Performing arts
/m/066wd Professional wrestling
/m/0f2f9 TV shows
Lifestyle topics
/m/019_rr Lifestyle (parent topic)
/m/032tl Fashion
/m/027x7n Fitness
/m/02wbm Food
/m/03glg Hobby
/m/068hy Pets
/m/041xxh Physical attractiveness [Beauty]
/m/07c1v Technology
/m/07bxq Tourism
/m/07yv9 Vehicles
Society topics
/m/098wr Society (parent topic)
/m/09s1f Business
/m/0kt51 Health
/m/01h6rj Military
/m/05qt0 Politics
/m/06bvp Religion
Other topics
/m/01k8wb Knowledge

 

videoCaption string
The videoCaption parameter indicates whether the API should filter video search results based on whether they have captions.Acceptable values are:

  • any – Do not filter results based on caption availability.
  • closedCaption – Only include videos that have captions.
  • none – Only include videos that do not have captions.
videoCategoryId string
The videoCategoryId parameter filters video search results based on their category.
videoDefinition string
The videoDefinition parameter lets you restrict a search to only include either high definition (HD) or standard definition (SD) videos. HD videos are available for playback in at least 720p, though higher resolutions, like 1080p, might also be available.Acceptable values are:

  • any – Return all videos, regardless of their resolution.
  • high – Only retrieve HD videos.
  • standard – Only retrieve videos in standard definition.
videoDimension string
The videoDimension parameter lets you restrict a search to only retrieve 2D or 3D videos.Acceptable values are:

  • 2d – Restrict search results to exclude 3D videos.
  • 3d – Restrict search results to only include 3D videos.
  • any – Include both 3D and non-3D videos in returned results. This is the default value.
videoDuration string
The videoDuration parameter filters video search results based on their duration.Acceptable values are:

  • any – Do not filter video search results based on their duration. This is the default value.
  • long – Only include videos longer than 20 minutes.
  • medium – Only include videos that are between four and 20 minutes long (inclusive).
  • short – Only include videos that are less than four minutes long.
videoEmbeddable string
The videoEmbeddable parameter lets you to restrict a search to only videos that can be embedded into a webpage.Acceptable values are:

  • any – Return all videos, embeddable or not.
  • true – Only retrieve embeddable videos.
videoLicense string
The videoLicense parameter filters search results to only include videos with a particular license. YouTube lets video uploaders choose to attach either the Creative Commons license or the standard YouTube license to each of their videos.Acceptable values are:

  • any – Return all videos, regardless of which license they have, that match the query parameters.
  • creativeCommon – Only return videos that have a Creative Commons license. Users can reuse videos with this license in other videos that they create. Learn more.
  • youtube – Only return videos that have the standard YouTube license.
videoSyndicated string
The videoSyndicated parameter lets you to restrict a search to only videos that can be played outside youtube.com.Acceptable values are:

  • any – Return all videos, syndicated or not.
  • true – Only retrieve syndicated videos.
videoType string
The videoType parameter lets you restrict a search to a particular type of videos.Acceptable values are:

  • any – Return all videos.
  • episode – Only retrieve episodes of shows.
  • movie – Only retrieve movies.
support

Couldn’t find your answer in the docs?

Contact Support

Was this article helpful?