API Reference

v1

Extract the best cover image from any URL. Supports YouTube, Bilibili, Twitter, Medium, Reddit and any page with Open Graph or oEmbed metadata.

Base URL

https://youtube.coverimage.dev

Authentication

No authentication required. The API is open and free to use.

GET /api/resolve

Resolve the best cover image for a given URL using query parameters. Ideal for quick tests and simple integrations.

Query Parameters

ParamTypeDefaultDescription
urlstringrequiredThe page URL to extract cover image from

curl Examples

YouTube video

curl "https://youtube.coverimage.dev/api/resolve?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ"

Any webpage (Open Graph)

curl "https://youtube.coverimage.dev/api/resolve?url=https://github.com/vercel/next.js"

With jq for pretty print

curl -s "https://youtube.coverimage.dev/api/resolve?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ" | jq .

POST /api/resolve

Resolve the best cover image using a JSON request body. Recommended for programmatic use.

Request Body

FieldTypeDefaultDescription
urlstringrequiredThe page URL to extract cover image from

curl Examples

Basic request

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

Extract only the image URL

curl -s -X POST https://youtube.coverimage.dev/api/resolve \
  -H "Content-Type: application/json" \
  -d '{"url": "https://medium.com/@example/my-article"}' \
  | jq -r '.best.url'

Response Format

Both GET and POST return the same JSON response structure.

Response Fields

FieldTypeDescription
request_idstringUnique request identifier
canonicalobject{ platform, resource_type, resource_id, canonical_url }
bestImageCandidateHighest-scored candidate image
candidatesImageCandidate[]All candidates sorted by score
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
widthnumber|nullImage width in pixels
heightnumber|nullImage height in pixels
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
400MISSING_URLThe url parameter is missing or empty
400INVALID_JSONPOST request body is not valid JSON
502RESOLVE_ERRORFailed to fetch or parse the target page

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. Choose GET or POST, enter a URL, and click Send. The corresponding curl command is shown below.

curl "https://youtube.coverimage.dev/api/resolve?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdQw4w9WgXcQ"