Skip to main content
Platforms

YouTube

Upload videos and Shorts to YouTube via the PostPeer API.

Overview

Upload videos and Shorts to YouTube with full metadata control — titles, descriptions, tags, privacy settings, and categories. PostPeer handles YouTube's chunked upload process and OAuth.

Quick Start

1. Connect a YouTube Account

curl https://api.postpeer.dev/v1/connect/youtube \
  -H "x-access-key: YOUR_API_KEY"

Returns a Google OAuth URL. The user authorizes video upload permissions. See Connect Accounts for the full OAuth flow.

2. Get the Account ID

curl https://api.postpeer.dev/v1/connect/integrations \
  -H "x-access-key: YOUR_API_KEY"

Find the integration with "platform": "youtube" and note the id.

3. Upload a Video

curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "How to build a social media scheduler",
    "platforms": [
      {
        "platform": "youtube",
        "accountId": "yt_789",
        "platformSpecificData": {
          "title": "How to Build a Social Media Scheduler",
          "visibility": "public",
          "tags": ["tutorial", "api", "social media"]
        }
      }
    ],
    "mediaItems": [
      { "type": "video", "url": "https://cdn.example.com/video.mp4" }
    ],
    "publishNow": true
  }'
import PostPeer from '@postpeer/node';

const client = new PostPeer();
const { data } = await client.posts.create({
	body: {
		content: 'How to build a social media scheduler',
		platforms: [
			{
				platform: 'youtube',
				accountId: 'yt_789',
				platformSpecificData: {
					title: 'How to Build a Social Media Scheduler',
					visibility: 'public',
					tags: ['tutorial', 'api', 'social media'],
				},
			},
		],
		mediaItems: [{ type: 'video', url: 'https://cdn.example.com/video.mp4' }],
		publishNow: true,
	},
});
from postpeer import PostPeer

with PostPeer() as client:
    post = client.posts.create(
        content="How to build a social media scheduler",
        platforms=[
            {
                "platform": "youtube",
                "accountId": "yt_789",
                "platformSpecificData": {
                    "title": "How to Build a Social Media Scheduler",
                    "visibility": "public",
                    "tags": ["tutorial", "api", "social media"],
                },
            },
        ],
        media_items=[
            {"type": "video", "url": "https://cdn.example.com/video.mp4"},
        ],
        publish_now=True,
    )

Response:

{
	"success": true,
	"status": "published",
	"postId": "post_ghi789",
	"platforms": [
		{
			"platform": "youtube",
			"success": true,
			"platformPostUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
		}
	]
}

Platform-Specific Data

Pass this object in platformSpecificData when posting to YouTube.

FieldTypeRequiredValues and constraintsDescription
titlestringNoLength: 0–100Video title (max 100 chars, no < or >). Defaults to first 100 chars of content, or "Untitled Video".
tagsstring[]NoVideo tags. Total characters across all tags must be ≤500.
visibilitystringNopublic, private, unlistedWho can see the video. Defaults to "public". Scheduled posts upload as private and flip to this value at publish time.
madeForKidsbooleanNoCOPPA compliance flag. Setting to true permanently disables comments, notification bell, personalized ads, end screens, and cards on the video. Defaults to false.
containsSyntheticMediabooleanNoAI-generated content disclosure. YouTube is increasingly enforcing this requirement. Defaults to false.
categoryIdstringNoYouTube category ID. Defaults to "22" (People & Blogs). Common values: "1" Film & Animation, "10" Music, "20" Gaming, "22" People & Blogs, "27" Education, "28" Science & Technology.
firstCommentstringNoLength: 0–10000Auto-posted comment after the video goes live. Max 10,000 characters. For publishNow posts: posted immediately after upload. For scheduled posts: posted when the video becomes public.

Shorts

Upload square or vertical videos up to 3 minutes long, and YouTube will categorize them as Shorts:

curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Quick API tip! #shorts",
    "platforms": [
      {
        "platform": "youtube",
        "accountId": "yt_789",
        "platformSpecificData": {
          "title": "Quick API Tip",
          "visibility": "public"
        }
      }
    ],
    "mediaItems": [
      { "type": "video", "url": "https://cdn.example.com/short.mp4" }
    ],
    "publishNow": true
  }'

Supported Formats

TypeFormatsMaximum sizeMaximum duration
VideoMP4 recommended; MOV, MPEG, AVI, WMV, FLV, WebM, 3GPP, ProRes, and HEVC supported256 GB15 minutes by default; 12 hours for verified accounts
ShortsSame formats as standard video256 GB3 minutes
ThumbnailJPG or PNG2 MB

Pass a thumbnail URL in mediaItems with "thumbnail" field to set a custom thumbnail.

SpecificationYouTube recommendation
ContainerMP4 with no edit lists and the moov atom at the front
VideoH.264 High Profile, progressive scan, 4:2:0 chroma subsampling
AudioAAC-LC, 48 kHz
Frame rateKeep the source frame rate; 24, 25, 30, 48, 50, and 60 FPS are common
Aspect ratio16:9 for standard video; square or vertical for Shorts

See YouTube's official supported formats, recommended encoding settings, upload limits, and Shorts requirements.

On this page