← Back to Home

How to Upload Videos to YouTube API

Updated March 5, 2026
youtubevideo uploadapiresumable uploadstreamingrange header

Uploading Videos to YouTube API

There are two valid upload patterns depending on your runtime and file size constraints.

Approach A: Google API Client (googleapis) Upload

Good for standard Node services with local file access.

const response = await youtube.videos.insert({
  part: ['snippet', 'status', 'localizations'],
  requestBody,
  media: { body: createReadStream(videoPath) },
});

Useful features:

Approach B: Resumable Streaming Upload

Good for Worker/edge pipelines, large files, or R2 stream sources.

Session Init

const response = await fetch(
  'https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status,contentDetails',
  { method: 'POST', headers, body: JSON.stringify(metadata) }
);
const uploadUrl = response.headers.get('Location');

Chunk Upload

if (response.status === 308) {
  const range = response.headers.get('Range');
  const match = range?.match(/bytes=0-(\d+)/);
  bytesUploaded = match ? Number(match[1]) + 1 : bytesUploaded + chunk.length;
}

Metadata Defaults (Common News Pipeline)

Thumbnail Upload (Recommended)

After main upload:

Which Approach to Choose