YouTube API
YouTube Screenshot
Capture a frame from a YouTube video at a specific timestamp, as a URL or inline base64.
POST
$0.01/call/v1/youtube/screenshotUsage
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
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
id | string | Yes | 11-character YouTube video ID (not a URL) | — |
timestamp | string | No | Position in the video. HH:MM:SS, MM:SS, or a number of seconds ("372") | 00:00:50 |
format | string | No | url returns frame links only. base64 also downloads the selected frame server-side and returns it inline | url |
resolution | string | No | Preferred frame height, e.g. 720p. If the video doesn't offer that size the closest lower one is used and reported in resolution | highest 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
| Field | Type | Description |
|---|---|---|
ok | boolean | Whether the request succeeded |
data.url | string | HTTPS 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.resolution | string | Resolution actually selected, e.g. 720p |
data.resolutions | string[] | Every resolution rendered for this video, highest first |
data.link | object | Map 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.image | string | Base64-encoded JPEG of the selected frame. Present only when format is base64 |
data.mimeType | string | Media type of image (always image/jpeg today). Present only with format=base64 |
data.bytes | number | Decoded size of image in bytes. Present only with format=base64 |
data.status | string | OK 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
| Status | Code | When |
|---|---|---|
400 | VALIDATION_ERROR | id is not an 11-character video ID, timestamp is malformed or out of range, format or resolution is unrecognised |
502 | UPSTREAM_ERROR | The 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 |