YepAPI
YouTube API

YouTube Screenshot

Capture a frame from a YouTube video at a specific timestamp, as a URL or inline base64.

POST/v1/youtube/screenshot
$0.01/call

Usage

const res = await fetch('https://api.yepapi.com/v1/youtube/screenshot', {
  method: 'POST',
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    id: 'dQw4w9WgXcQ',
    timestamp: '00:00:50',
    format: 'base64',   // inline JPEG — no second fetch needed
    resolution: '720p', // optional; defaults to the highest available
  }),
});
const { data } = await res.json();
const frame = Buffer.from(data.image, 'base64'); // data.mimeType === 'image/jpeg'
curl -X POST https://api.yepapi.com/v1/youtube/screenshot \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id": "dQw4w9WgXcQ", "timestamp": "00:00:50", "format": "base64"}'

Request Body

ParameterTypeRequiredDescriptionDefault
idstringYes11-character YouTube video ID (not a URL)—
timestampstringNoPosition in the video. HH:MM:SS, MM:SS, or a number of seconds ("372")00:00:50
formatstringNourl returns frame links only. base64 also downloads the selected frame server-side and returns it inlineurl
resolutionstringNoPreferred frame height, e.g. 720p. If the video doesn't offer that size the closest lower one is used and reported in resolutionhighest available

Response

{
  "ok": true,
  "data": {
    "url": "https://api.yepapi.com/frames/dQw4w9WgXcQ.000050.720p.3f9c….jpg",
    "resolution": "720p",
    "resolutions": ["1080p", "720p", "480p", "360p"],
    "link": {
      "1080p": "https://api.yepapi.com/frames/dQw4w9WgXcQ.000050.1080p.3f9c….jpg",
      "720p": "https://api.yepapi.com/frames/dQw4w9WgXcQ.000050.720p.3f9c….jpg",
      "480p": "https://api.yepapi.com/frames/dQw4w9WgXcQ.000050.480p.3f9c….jpg",
      "360p": "https://api.yepapi.com/frames/dQw4w9WgXcQ.000050.360p.3f9c….jpg"
    },
    "image": "/9j/4AAQSkZJRgABAQ...(base64 JPEG, only with format=base64)",
    "mimeType": "image/jpeg",
    "bytes": 138579,
    "status": "OK"
  }
}

Response Fields

FieldTypeDescription
okbooleanWhether the request succeeded
data.urlstringHTTPS link to the selected frame, served from api.yepapi.com. Safe to embed in an <img> on any HTTPS page; no API key needed to fetch it
data.resolutionstringResolution actually selected, e.g. 720p
data.resolutionsstring[]Every resolution rendered for this video, highest first
data.linkobjectMap of resolution → frame URL. Only the resolutions the source video can supply are present, so an old upload may return just 480p and 360p
data.imagestringBase64-encoded JPEG of the selected frame. Present only when format is base64
data.mimeTypestringMedia type of image (always image/jpeg today). Present only with format=base64
data.bytesnumberDecoded size of image in bytes. Present only with format=base64
data.statusstringOK when the frame is ready
Info

data.link is an object keyed by resolution, not an array. Read data.url for the best frame, or pick a key from data.link yourself.

Warning

Frame links are signed URLs on api.yepapi.com and keep working as long as the video is available: if the rendered frame has expired upstream, fetching the link re-renders it transparently. Fetches of a frame link are not billed. Use format: "base64" when you want the bytes in the same round-trip.

Info

For computer-vision or LLM pipelines, send format: "base64" with a pinned resolution such as 720p. The response is self-contained and payloads stay predictable — a 720p frame is typically 100–150 KB decoded.

Errors

StatusCodeWhen
400VALIDATION_ERRORid is not an 11-character video ID, timestamp is malformed or out of range, format or resolution is unrecognised
502UPSTREAM_ERRORThe frame could not be rendered. This also happens intermittently for valid videos: the renderer occasionally answers "not found" and then succeeds seconds later. Retry the request two or three times with a short delay before treating it as a failure. Failed calls are not billed

On this page