{"openapi":"3.1.0","info":{"title":"StableTube","description":"Pay-per-request YouTube video downloads. POST a YouTube URL, get a direct CDN download URL. URLs expire ~6 hours after issue — consume promptly. x402 only; no SIWX history.","version":"0.1.0","x-guidance":"# StableTube API\n\nBase URL: `https://stabletube.dev`\n\nYouTube downloads as an x402 API. POST a YouTube URL, get back a direct\n`*.googlevideo.com` CDN download URL. The URL is short-lived (~6 hours).\nThere is no history, no SIWX, no free re-resolve — if the URL expires, repay.\n\n## Workflow\n\n```\n1. Optional: GET /api/info?url=...   # free metadata + available qualities\n2. POST     /api/download             # paid; returns direct downloadUrl\n3. Consume  downloadUrl within ~6h    # plain HTTP GET / curl\n```\n\n## Endpoints\n\n- `GET  /api/info?url=...` — free. Title, duration, channel, thumbnails, `availableQualities`.\n- `POST /api/download` — paid. Body: `url`, `quality` (`360p` | `720p` | `1080p`, default `720p`), `format` (`mp4`). Returns `downloadUrl`, `mimeType`, `contentLengthBytes`, `expiresAt`.\n\n## Quality fallback\n\nIf the requested `quality` isn't available for that video, the closest lower quality is returned and reflected in the response `quality` field. If no mp4 stream exists at all, the call aborts with 404 inside the `.paid()` pricing function — you are not charged.\n\n## Pricing\n\nFloor $0.02. flat per-quality: 360p $0.02 / 720p $0.04 / 1080p $0.08.\n\nSee `/openapi.json` for full request/response schemas.\n","guidance":"# StableTube API\n\nBase URL: `https://stabletube.dev`\n\nYouTube downloads as an x402 API. POST a YouTube URL, get back a direct\n`*.googlevideo.com` CDN download URL. The URL is short-lived (~6 hours).\nThere is no history, no SIWX, no free re-resolve — if the URL expires, repay.\n\n## Workflow\n\n```\n1. Optional: GET /api/info?url=...   # free metadata + available qualities\n2. POST     /api/download             # paid; returns direct downloadUrl\n3. Consume  downloadUrl within ~6h    # plain HTTP GET / curl\n```\n\n## Endpoints\n\n- `GET  /api/info?url=...` — free. Title, duration, channel, thumbnails, `availableQualities`.\n- `POST /api/download` — paid. Body: `url`, `quality` (`360p` | `720p` | `1080p`, default `720p`), `format` (`mp4`). Returns `downloadUrl`, `mimeType`, `contentLengthBytes`, `expiresAt`.\n\n## Quality fallback\n\nIf the requested `quality` isn't available for that video, the closest lower quality is returned and reflected in the response `quality` field. If no mp4 stream exists at all, the call aborts with 404 inside the `.paid()` pricing function — you are not charged.\n\n## Pricing\n\nFloor $0.02. flat per-quality: 360p $0.02 / 720p $0.04 / 1080p $0.08.\n\nSee `/openapi.json` for full request/response schemas.\n","contact":{"name":"Merit Systems","url":"https://stabletube.dev"}},"servers":[{"url":"https://stabletube.dev"}],"tags":[{"name":"Download"},{"name":"Info"}],"paths":{"/api/info":{"get":{"operationId":"info","summary":"Free metadata lookup for a YouTube video: title, duration, channel, thumbnails, and available qualities. Use to confirm the URL is valid before paying.","tags":["Info"],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"videoId":{"type":"string"},"title":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSec":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"channel":{"anyOf":[{"type":"string"},{"type":"null"}]},"thumbnails":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"width":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"height":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["url"],"additionalProperties":false}},"availableQualities":{"type":"array","items":{"type":"string","enum":["360p","720p","1080p"]}}},"required":["videoId","title","durationSec","channel","thumbnails","availableQualities"],"additionalProperties":false}}}}}}},"/api/download":{"post":{"operationId":"download","summary":"Resolve a YouTube URL to a direct CDN download URL at the requested quality. URL is short-lived (~6h); consume promptly.","tags":["Download"],"x-payment-info":{"price":{"mode":"dynamic","currency":"USD","min":"0.02","max":"0.50"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"default":"stabletube.download","type":"string","const":"stabletube.download"},"url":{"type":"string","format":"uri","description":"Full YouTube URL of the video to download."},"quality":{"default":"720p","description":"Target video quality. Falls back to closest available.","type":"string","enum":["360p","720p","1080p"]},"format":{"default":"mp4","description":"Output container format. mp4 only for now.","type":"string","enum":["mp4"]}},"required":["url"]}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"videoId":{"type":"string"},"title":{"anyOf":[{"type":"string"},{"type":"null"}]},"durationSec":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"quality":{"type":"string","enum":["360p","720p","1080p"]},"format":{"type":"string","enum":["mp4"]},"mimeType":{"anyOf":[{"type":"string"},{"type":"null"}]},"contentLengthBytes":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"downloadUrl":{"type":"string","format":"uri","description":"Direct *.googlevideo.com CDN URL. Fetch within ~6 hours; after that you must repay."},"expiresAt":{"anyOf":[{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"},{"type":"null"}],"description":"Best-effort expiry of downloadUrl, if known."},"price":{"type":"string"}},"required":["videoId","title","durationSec","quality","format","mimeType","contentLengthBytes","downloadUrl","expiresAt","price"],"additionalProperties":false}}}},"402":{"description":"Payment Required"}}}}}}