API Reference

v1

Extract the highest-quality cover image from YouTube videos via a simple REST API.

Base URL

# Production (Cloudflare Workers)
https://your-worker.your-domain.workers.dev

# Local development
http://localhost:8787

Authentication

No authentication required. The API is currently open.

POST /v1/resolve

Resolve the best cover image for a given URL. Returns the highest-quality candidate along with all alternatives.

Request Body

FieldTypeDefaultDescription
Top-level
urlstringrequiredYouTube video URL (youtube.com/watch?v=, youtu.be/, /shorts/, /embed/)
optionsobjectoptionalResolve options (see below)
options
options.preferenum"balanced""largest" | "balanced" | "fastest"
options.min_widthnumber0Minimum width filter (pixels)
options.min_heightnumber0Minimum height filter (pixels)
options.refreshbooleanfalseSkip cache, always re-fetch
options.debugbooleanfalseInclude detailed trace info in response

Example Request

curl -X POST https://your-api.workers.dev/v1/resolve \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  }'

Response

FieldTypeDescription
request_idstringUnique request identifier
canonicalobject{ platform, resource_type, resource_id, canonical_url }
bestImageCandidateHighest-scored candidate image
candidatesImageCandidate[]All candidates sorted by score (maxres, sd, hq, mq, default)
cacheobject{ hit: boolean, ttl_seconds: number }
traceobjectPipeline execution trace (steps, timings)
metaobject?Page metadata (title, author, etc.)
warningsarray?Non-fatal issues encountered
errorsarray?Errors encountered during resolve

ImageCandidate Object

FieldTypeDescription
urlstringDirect image URL (e.g. i.ytimg.com/vi/.../maxresdefault.jpg)
widthnumber|nullImage width in pixels (from HTTP probe)
heightnumber|nullImage height in pixels (from HTTP probe)
formatenum"jpg" | "png" | "webp" | "avif" | "gif" | "unknown"
quality_tierenum"max" | "high" | "medium" | "low" | "unknown"
scorenumber|nullComposite score (tier bonus + pixel bonus)
source_methodenum"rule" | "api" | "og" | "oembed" | ...
availabilityobject{ status: "ok"|"missing"|"blocked"|"error", http_status? }

Example Response

{
  "request_id": "mme7othw-i1eau49ph",
  "canonical": {
    "platform": "youtube",
    "resource_type": "video",
    "resource_id": { "videoId": "dQw4w9WgXcQ" },
    "canonical_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  },
  "best": {
    "url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg",
    "width": 1280,
    "height": 720,
    "format": "jpg",
    "quality_tier": "max",
    "score": 129.8,
    "source_method": "rule",
    "availability": { "status": "ok", "http_status": 200 }
  },
  "candidates": [ "...5 candidates from maxres to default..." ],
  "cache": { "hit": false, "ttl_seconds": 86400 },
  "trace": { "timings": { "total_ms": 789 } }
}

Error Codes

HTTPCodeDescription
400INVALID_JSONRequest body is not valid JSON
400VALIDATION_ERRORRequest doesn't match schema (missing url, invalid options)
500RESOLVE_ERRORPipeline execution failed

GET /health

Simple health check endpoint. Returns 200 when the service is running.

{ "ok": true }

YouTube Quality Tiers

For YouTube videos, the API probes 5 thumbnail quality tiers and returns the best available:

TierURL PatternTypical Size
maxi.ytimg.com/vi/ID/maxresdefault.jpg1280x720
highi.ytimg.com/vi/ID/sddefault.jpg640x480
mediumi.ytimg.com/vi/ID/hqdefault.jpg480x360
lowi.ytimg.com/vi/ID/mqdefault.jpg320x180
lowi.ytimg.com/vi/ID/default.jpg120x90

Playground

Try the API directly from your browser. Edit the request body and click send.

Request Body

POST

Response

Click "Send Request" to try the API