Youtube API search query

<script> function getRes(response) { apiresults = response.items; apiresults.forEach(function(video){ console.log(; console.log(video.snippet.title); console.log("---------------------------"); }); } // Gets ID of videos // Called automatically when JavaScript client library is loaded. function init() { gapi.client.load('youtube', 'v3', onYouTubeApiLoad); } // Called automatically when YouTube API interface is loaded (see line 9). function onYouTubeApiLoad() { // This API key is intended for use only in this lesson. // See to get a key for your own applications. gapi.client.setApiKey('yourkey'); search(); } function search() { // Use the JavaScript client library to create a search.list() API call. var request ={ part: 'snippet', q: "the beatles" // Just an example }); // Send the request to the API server, // and invoke onSearchRepsonse() with the response. request.execute(onSearchResponse); } // Called automatically with the response of the YouTube API request. function onSearchResponse(response) { getRes(response); } </script> <!-- The above functions must be load into memory before the following API is called --> <script src=""></script>
How to properly use the Youtube API (you must first get your Google Developers API Key) to search youtube videos, read the documentation to learn about other functions and parameters you can use.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.