YannisP
YannisP

Reputation: 69

YouTube API - Search for video in specific channel

I'm using the Youtube API on javascript in order to get all videos from a specific channel:

$.get(
    "https://www.googleapis.com/youtube/v3/channels?",{
    part : 'contentDetails',
    id : '..............',
    key: "..........................."},
    function(data) {
            ............................................
});

How can I search in that specific channel for videos by using a keyword?

Upvotes: 1

Views: 1123

Answers (2)

YannisP
YannisP

Reputation: 69

Found it:

function searchVideo(input) {
    $.get(
        "https://www.googleapis.com/youtube/v3/search", 
        {
            q: input,
            part : 'snippet',
            channelId : '...........',
            key: "........."
        },
        function(data) {
            $.each( data.items, function( i, item ) {
                ....................
            });
        }
    );
}   

There is one problem though. The results are wrong all the time. What could be the case here?

Upvotes: 1

johnh10
johnh10

Reputation: 4185

Use the YouTube search:list endpoint instead.

It takes both a channelID and a q parameter for searches.

Upvotes: 2

Related Questions