n8n YouTube API: Video Metadata Upload Automation
I automate YouTube operations with n8n because the platform’s API is powerful but tedious to manage manually. When I upload videos, update metadata, or pull analytics across multiple channels, doing it through the YouTube Studio dashboard eats hours. n8n turns those repetitive tasks into set-and-forget workflows.
The YouTube Data API v3 handles uploads, metadata management, channel analytics, and comment moderation. I connect it to n8n using OAuth 2.0 credentials from the Google Cloud Console. Once authenticated, every YouTube operation becomes a node on my canvas.
Uploading Videos and Managing Metadata
The YouTube upload workflow starts with a file trigger — a new video lands in a folder, and n8n picks it up. I use the n8n YouTube node for the API calls, though the HTTP Request node works for advanced scenarios.
Here’s my standard upload workflow:
`javascript
// YouTube node configuration for upload
Operation: Upload
Video File: {{local_video_path}}
Title: {{video_title}}
Description: {{video_description}}
Category Id: 28 (Technology)
Privacy Status: private
Tags: [n8n, automation, tutorial]
`
The file trigger uses n8n’s File Watch node or a Google Drive trigger that watches a designated upload folder. When a new file appears, the workflow extracts the title and description from a naming convention or a companion CSV file.
For batch uploads, I process a spreadsheet where each row represents a video:
`javascript
// Code node: parse video metadata from CSV row
const row = item.json;
const metadata = {
title: row.title || Untitled - ${row.filename},
description: row.description || ”,
tags: (row.tags || ”).split(‘,’).map(t => t.trim()),
category: row.category || ’28’,
license: row.license || ‘youtube’
};
return [{ json: metadata, pairedItem: { item: 0 } }];
`
Metadata updates happen through the Videos: update endpoint. I use this to add chapters, update thumbnails, or change privacy settings after the initial upload:
`javascript
// YouTube node: update video metadata
Operation: Update
Video Id: {{video_id}}
Snippet Title: {{updated_title}}
Snippet Description: {{updated_description}}
Status Privacy Status: {{privacy_status}}
`
Thumbnail uploads require a separate API call. I generate custom thumbnails in a design tool, store them in Google Drive, then fetch and upload them through n8n:
`javascript
// HTTP Request to upload thumbnail
Method: POST
URL: https://content-upload.googleapis.com/upload/youtube/v3/thumbnails?videoId={{video_id}}
Headers: { Authorization: Bearer {{oauth_token}} }
Body: {{thumbnail_image_binary}}
`
Channel Analytics and Performance Tracking
YouTube Analytics API gives me data that the dashboard doesn’t surface easily. I pull view counts, watch time, subscriber growth, and revenue metrics on a daily schedule using n8n’s Cron node.
`javascript
// Cron node: daily at 6 AM
Schedule: 0 6 *
// YouTube Analytics node configuration
Operation: Query
Metrics: views,estimatedMinutesWatched,subscribersGained,subscribersLost,likeCount,commentCount
StartDate: {{yesterday_date}}
EndDate: {{today_date}}
Ids: channel=MINE
`
The results flow into a Google Sheets node that maintains a running log. From there, an If node checks for anomalies — a sudden drop in views triggers a Slack notification through the n8n Slack & PagerDuty nodes guide setup.
For weekly performance reports, I aggregate the daily data and format it into an email:
`javascript
// Code node: calculate weekly metrics
const dailyViews = item.json.views || 0;
const weeklyTotal += dailyViews;
const avgWatchTime = item.json.estimatedMinutesWatched / weeklyDays;
return [{
json: {
weekly_views: weeklyTotal,
avg_watch_time_minutes: avgWatchTime.toFixed(1),
net_subscribers: item.json.subscribersGained – item.json.subscribersLost
}
}];
`
I also track keyword performance. By querying search terms from the analytics response, I identify which tags and titles drive discovery traffic. This feeds back into my metadata optimization workflow for future uploads.
Automating Comment Moderation
YouTube’s comment API lets me moderate comments programmatically. I set up a workflow that checks new comments against keywords and filters rules:
`javascript
// YouTube node: list comments
Operation: List
Video Id: {{video_id}}
Order: time
Max Results: 50
// Code node: filter comments by keywords
const blockedTerms = [‘spam’, ‘scam’, ‘buy followers’];
const filtered = item.json.filter(c =>
!blockedTerms.some(term => c.textDisplay.toLowerCase().includes(term))
);
return filtered.map(c => ({ json: c }));
`
Comments that pass the filter route to a Hold for Review queue in Google Sheets. Blocked comments go straight to deletion. Approved comments trigger a reply through the YouTube Comments API using a template stored in n8n’s parameter mapping.
Connecting to Your Existing Setup
The n8n Docker Deployment guide covers hosting your n8n instance. YouTube API credentials live in n8n’s credential manager — set them up once and reuse across workflows.
For scheduling the daily analytics cron, the n8n Docker Environment Variables reference explains how to configure timezone settings so your reports arrive at the right local time.
Action Card: Daily YouTube Upload
Quick test workflow for uploading a video:
`javascript
// 1. Manual trigger node
// Set: video_file = path/to/your/video.mp4
// Set: title = Test Upload from n8n
// Set: description = Automated via YouTube API
// 2. YouTube node: Upload
// Operation: Upload
// Video File: {{$json.video_file}}
// Title: {{$json.title}}
// Description: {{$json.description}}
// Privacy Status: private
// 3. Response node: capture videoId from response
// 4. YouTube node: Update
// Operation: Update
// Video Id: {{$responseBody.id}}
// Privacy Status: public
`
Check your YouTube Studio dashboard to confirm the video uploaded and went public. The whole process takes under 2 minutes versus 10+ minutes manually.
