We have a node.js app that connects to the Youtube API but when we pull videos, it is not pulling the latest video from the creators channel

Edit
This is a common issue with the YouTube API. Here are the most likely causes and solutions:

Check Your API Query Parameters
Sort by Upload Date:

javascript
const response = await youtube.search.list({
  part: 'snippet',
  channelId: 'CHANNEL_ID_HERE',
  order: 'date', // This is crucial - sorts by upload date
  maxResults: 10,
  type: 'video'
});
Use the correct endpoint: Instead of search.list, try using activities.list which is more reliable for recent uploads:

javascript
const response = await youtube.activities.list({
  part: 'snippet,contentDetails',
  channelId: 'CHANNEL_ID_HERE',
  maxResults: 10
});
Common Issues to Check
API Caching/Delays: YouTube's API can have delays of 15-60 minutes for new uploads. The search endpoint is particularly prone to this.

Video Privacy: Make sure the latest video is actually public. Private, unlisted, or scheduled videos won't appear in API results.

Published vs Upload Time: Use publishedAfter parameter if you need videos after a specific time:

javascript
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);

const response = await youtube.search.list({
  part: 'snippet',
  channelId: 'CHANNEL_ID_HERE',
  order: 'date',
  publishedAfter: yesterday.toISOString(),
  type: 'video'
});
Quota Limits: If you're hitting quota limits, the API might return cached/stale results.

Alternative Approach
Try using the channel's uploads playlist:

javascript
// First, get the channel's uploads playlist ID
const channelResponse = await youtube.channels.list({
  part: 'contentDetails',
  id: 'CHANNEL_ID_HERE'
});

const uploadsPlaylistId = channelResponse.data.items[0].contentDetails.relatedPlaylists.uploads;

// Then get the latest videos from that playlist
const videosResponse = await youtube.playlistItems.list({
  part: 'snippet',
  playlistId: uploadsPlaylistId,
  maxResults: 10
});