// Replace 'YOUR_API_KEY' and 'YOUR_PLAYLIST_ID' with your actual API key and playlist ID.
const apiKey = AIzaSyBV0y2GfIbLEI-ruG1644NEg2wXO-SsFTw;
const playlistId = PL4GcRGPV7hzwpfGROdhraLV9EqS6QP87M;
// Fetch the playlist items sorted by date.
fetch(`https://www.googleapis.com/youtube/v3/playlistItems?key=${apiKey}&playlistId=${playlistId}&part=snippet&maxResults=3&order=date`)
.then(response => response.json())
.then(data => {
const videos = data.items;
// Loop through the videos and generate the HTML for each one.
videos.forEach(video => {
const videoId = video.snippet.resourceId.videoId;
const videoTitle = video.snippet.title;
// Generate the HTML for the embedded video player.
const embedCode = ``;
// Insert the embedded video into your webpage.
document.getElementById('playlist-videos').innerHTML += `