{"openapi":"3.1.0","info":{"title":"VidCrawl API","version":"1.0.0","description":"Progressive video context for AI agents. Scrape metadata, full descriptions, transcripts, and storyboards first, then inspect high-res frames or run the grounded video agent."},"servers":[{"url":"https://vidcrawl.com","description":"API Server"}],"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API key","description":"Use Authorization: Bearer <API_KEY>."},"apiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Use x-api-key: <API_KEY>."}},"schemas":{"HealthResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"service":{"type":"string"},"version":{"type":"string"}},"required":["ok","service","version"]},"AccountResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"user_id":{"type":"string"},"credits":{"type":"number"},"costs":{"type":"object","properties":{"scrape":{"type":"number"},"frames":{"type":"number"},"search":{"type":"number"},"agent":{"type":"object","properties":{"low":{"type":"number"},"medium":{"type":"number"},"high":{"type":"number"}},"required":["low","medium","high"]}},"required":["scrape","frames","search","agent"]}},"required":["ok","user_id","credits","costs"]},"ErrorResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[false]},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"issues":{"type":"array","items":{}},"request_id":{"type":"string"}},"required":["code","message"]}},"required":["ok","error"]},"ScrapeResponse":{"type":"object","properties":{"ok":{"type":"boolean"},"scrape_id":{"type":"string"},"platform":{"type":"string","enum":["youtube","tiktok","instagram","x","unknown"]},"video_id":{"type":"string"},"canonical_url":{"type":"string"},"metadata":{"type":"object","properties":{"title":{"type":"string"},"author":{"type":"string"},"channel_id":{"type":"string"},"duration_sec":{"type":"number"},"views":{"type":"number"},"likes":{"type":"number"},"published_at":{"type":"string"},"description":{"type":"string"},"description_links":{"type":"array","items":{"type":"string"}},"thumbnail_url":{"type":"string"},"chapters":{"type":"array","items":{"type":"object","properties":{"title":{"type":"string"},"start_sec":{"type":"number"},"timestamp":{"type":"string"}},"required":["title","start_sec","timestamp"]},"default":[]}},"required":["title","author","duration_sec"]},"transcript":{"type":"object","properties":{"source":{"type":"string","enum":["native_manual","native_auto","ai_asr","caption_text","none"]},"language":{"type":"string"},"full_text":{"type":"string"},"segments":{"type":"array","items":{"type":"object","properties":{"start_sec":{"type":"number"},"end_sec":{"type":"number"},"duration_sec":{"type":"number"},"timestamp":{"type":"string"},"text":{"type":"string"}},"required":["start_sec","end_sec","duration_sec","timestamp","text"]}},"truncated":{"type":"boolean"},"covered_sec":{"type":"number"}},"required":["source","language","full_text","segments"]},"storyboard":{"type":"object","properties":{"strategy":{"type":"string","enum":["youtube_storyboard","ffmpeg_contact_sheet","thumbnail","none"]},"interval_sec":{"type":"number"},"total_tiles":{"type":"number"},"sheets":{"type":"array","items":{"type":"object","properties":{"sheet_index":{"type":"number"},"url":{"type":"string"},"local_path":{"type":"string"},"width":{"type":"number"},"height":{"type":"number"},"cols":{"type":"number"},"rows":{"type":"number"},"tile_width":{"type":"number"},"tile_height":{"type":"number"},"tiles":{"type":"array","items":{"type":"object","properties":{"index":{"type":"number"},"timestamp_sec":{"type":"number"},"timestamp":{"type":"string"},"row":{"type":"number"},"col":{"type":"number"}},"required":["index","timestamp_sec","timestamp","row","col"]}}},"required":["sheet_index","url","width","height","cols","rows","tile_width","tile_height","tiles"]}}},"required":["strategy","interval_sec","total_tiles","sheets"]},"markdown":{"type":"string"},"metrics":{"type":"object","properties":{"latency_ms":{"type":"number"},"network_bytes":{"type":"number"},"proxy_bytes":{"type":"number"},"credits_used":{"type":"number"},"estimated_cost_usd":{"type":"number"}},"required":["latency_ms","network_bytes","credits_used","estimated_cost_usd"]}},"required":["ok","platform","video_id","canonical_url","metadata","transcript","storyboard","markdown","metrics"]},"ScrapeRequest":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"formats":{"type":"array","items":{"type":"string","enum":["markdown","segments","storyboard"]},"minItems":1,"maxItems":3,"default":["markdown","segments","storyboard"]},"lang":{"type":"string","maxLength":16,"pattern":"^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$","default":"en"},"max_age_sec":{"type":"integer","minimum":0,"maximum":31536000}},"required":["url"]},"FramesResponse":{"type":"object","properties":{"ok":{"type":"boolean"},"platform":{"type":"string","enum":["youtube","tiktok","instagram","x","unknown"]},"video_id":{"type":"string"},"frames":{"type":"array","items":{"type":"object","properties":{"timestamp_sec":{"type":"number"},"timestamp":{"type":"string"},"source":{"type":"string","enum":["storyboard_crop","ffmpeg_seek"]},"mime_type":{"type":"string","enum":["image/jpeg"]},"width":{"type":"number"},"height":{"type":"number"},"data_url":{"type":"string"},"byte_length":{"type":"number"}},"required":["timestamp_sec","timestamp","source","mime_type","width","height","data_url","byte_length"]}},"metrics":{"type":"object","properties":{"latency_ms":{"type":"number"},"credits_used":{"type":"number"}},"required":["latency_ms","credits_used"]}},"required":["ok","platform","video_id","frames","metrics"]},"FramesRequest":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"timestamps_sec":{"type":"array","items":{"type":"number","minimum":0},"minItems":1,"maxItems":20},"max_width":{"type":"integer","minimum":320,"maximum":1920,"default":1280}},"required":["url","timestamps_sec"]},"SearchResponse":{"type":"object","properties":{"ok":{"type":"boolean"},"query":{"type":"string"},"platform":{"type":"string","enum":["youtube","tiktok"]},"results":{"type":"array","items":{"type":"object","properties":{"video_id":{"type":"string"},"url":{"type":"string"},"title":{"type":"string"},"author":{"type":"string"},"channel_id":{"type":"string"},"duration_sec":{"type":"number"},"duration":{"type":"string"},"views":{"type":"number"},"published_at":{"type":"string"},"thumbnail_url":{"type":"string"},"snippet":{"type":"string"},"scraped":{"type":"object","properties":{"ok":{"type":"boolean"},"scrape_id":{"type":"string"},"platform":{"type":"string","enum":["youtube","tiktok","instagram","x","unknown"]},"video_id":{"type":"string"},"canonical_url":{"type":"string"},"metadata":{"type":"object","properties":{"title":{"type":"string"},"author":{"type":"string"},"channel_id":{"type":"string"},"duration_sec":{"type":"number"},"views":{"type":"number"},"likes":{"type":"number"},"published_at":{"type":"string"},"description":{"type":"string"},"description_links":{"type":"array","items":{"type":"string"}},"thumbnail_url":{"type":"string"},"chapters":{"type":"array","items":{"type":"object","properties":{"title":{"type":"string"},"start_sec":{"type":"number"},"timestamp":{"type":"string"}},"required":["title","start_sec","timestamp"]},"default":[]}},"required":["title","author","duration_sec"]},"transcript":{"type":"object","properties":{"source":{"type":"string","enum":["native_manual","native_auto","ai_asr","caption_text","none"]},"language":{"type":"string"},"full_text":{"type":"string"},"segments":{"type":"array","items":{"type":"object","properties":{"start_sec":{"type":"number"},"end_sec":{"type":"number"},"duration_sec":{"type":"number"},"timestamp":{"type":"string"},"text":{"type":"string"}},"required":["start_sec","end_sec","duration_sec","timestamp","text"]}},"truncated":{"type":"boolean"},"covered_sec":{"type":"number"}},"required":["source","language","full_text","segments"]},"storyboard":{"type":"object","properties":{"strategy":{"type":"string","enum":["youtube_storyboard","ffmpeg_contact_sheet","thumbnail","none"]},"interval_sec":{"type":"number"},"total_tiles":{"type":"number"},"sheets":{"type":"array","items":{"type":"object","properties":{"sheet_index":{"type":"number"},"url":{"type":"string"},"local_path":{"type":"string"},"width":{"type":"number"},"height":{"type":"number"},"cols":{"type":"number"},"rows":{"type":"number"},"tile_width":{"type":"number"},"tile_height":{"type":"number"},"tiles":{"type":"array","items":{"type":"object","properties":{"index":{"type":"number"},"timestamp_sec":{"type":"number"},"timestamp":{"type":"string"},"row":{"type":"number"},"col":{"type":"number"}},"required":["index","timestamp_sec","timestamp","row","col"]}}},"required":["sheet_index","url","width","height","cols","rows","tile_width","tile_height","tiles"]}}},"required":["strategy","interval_sec","total_tiles","sheets"]},"markdown":{"type":"string"},"metrics":{"type":"object","properties":{"latency_ms":{"type":"number"},"network_bytes":{"type":"number"},"proxy_bytes":{"type":"number"},"credits_used":{"type":"number"},"estimated_cost_usd":{"type":"number"}},"required":["latency_ms","network_bytes","credits_used","estimated_cost_usd"]}},"required":["ok","platform","video_id","canonical_url","metadata","transcript","storyboard","markdown","metrics"]}},"required":["video_id","url","title","author","duration_sec","duration"]}},"metrics":{"type":"object","properties":{"latency_ms":{"type":"number"},"network_bytes":{"type":"number"},"credits_used":{"type":"number"}},"required":["latency_ms","network_bytes","credits_used"]}},"required":["ok","query","platform","results","metrics"]},"SearchRequest":{"type":"object","properties":{"query":{"type":"string","minLength":1,"maxLength":200},"platform":{"type":"string","enum":["youtube","tiktok"],"default":"youtube"},"limit":{"type":"integer","minimum":1,"maximum":20,"default":5},"scrape":{"type":"boolean","default":false},"lang":{"type":"string","maxLength":16,"pattern":"^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$","default":"en"},"source":{"type":"string","enum":["live","index"],"default":"live"},"domain":{"type":"string","minLength":1,"maxLength":200}},"required":["query"]},"AgentResponse":{"type":"object","properties":{"ok":{"type":"boolean"},"summary":{"type":"string"},"visual_hook":{"type":"string"},"on_screen_ocr":{"type":"array","items":{"type":"object","properties":{"timestamp":{"type":"string"},"timestamp_sec":{"type":"number"},"kind":{"type":"string","enum":["slide","code","caption_overlay","ui","chart","product","other"]},"text":{"type":"string"},"context":{"type":"string"}},"required":["timestamp","timestamp_sec","kind","text","context"]}},"scenes":{"type":"array","items":{"type":"object","properties":{"start_timestamp":{"type":"string"},"end_timestamp":{"type":"string"},"visual_summary":{"type":"string"},"on_screen_text":{"type":"string"},"spoken_summary":{"type":"string"}},"required":["start_timestamp","end_timestamp","visual_summary","on_screen_text","spoken_summary"]}},"data":{"type":"object","additionalProperties":{}},"citations":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"video_id":{"type":"string"},"timestamp":{"type":"string"},"timestamp_sec":{"type":"number"},"claim":{"type":"string"},"evidence_type":{"type":"string","enum":["spoken","visual_ocr","both"]}},"required":["url","video_id","timestamp","timestamp_sec","claim","evidence_type"]}},"usage":{"type":"object","properties":{"effort":{"type":"string","enum":["low","medium","high"]},"credits_used":{"type":"number"},"latency_ms":{"type":"number"},"scrape_latency_ms":{"type":"number"},"llm_latency_ms":{"type":"number"},"network_bytes":{"type":"number"},"model":{"type":"string"},"model_tokens":{"type":"object","properties":{"input":{"type":"number"},"output":{"type":"number"}},"required":["input","output"]},"estimated_cost_usd":{"type":"number"}},"required":["effort","credits_used","latency_ms","scrape_latency_ms","llm_latency_ms","network_bytes","model","model_tokens","estimated_cost_usd"]}},"required":["ok","summary","visual_hook","on_screen_ocr","scenes","citations","usage"]},"AgentRequest":{"type":"object","properties":{"prompt":{"type":"string","minLength":1,"maxLength":4000},"urls":{"type":"array","items":{"type":"string","format":"uri"},"minItems":1,"maxItems":10},"effort":{"type":"string","enum":["low","medium","high"],"default":"low"},"schema":{"type":"object","additionalProperties":{}}},"required":["prompt","urls"]}},"parameters":{}},"paths":{"/healthz":{"get":{"security":[],"tags":["System"],"operationId":"getHealth","summary":"Check service health","responses":{"200":{"description":"Service is healthy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/v1/account":{"get":{"tags":["Account"],"operationId":"getAccount","summary":"Check credit balance and per-endpoint costs","description":"Returns the authenticated account ID, remaining credit balance, and current per-endpoint credit costs. Costs 0 credits.","responses":{"200":{"description":"Account credit balance and endpoint costs","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountResponse"}}}},"401":{"description":"A valid API key is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/scrape":{"post":{"tags":["Video Context"],"operationId":"scrapeVideo","summary":"Extract deterministic video context (Layer 1)","description":"Returns metadata, full description, outgoing links, chapters, timestamped transcript, storyboard contact sheets, and LLM-ready Markdown without invoking an LLM. Same-user 24h replays cost 0 credits; cross-user durable cache hits and live scrapes cost 1 credit. Supports max_age_sec (default 2592000s, 0 forces fresh scrape).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScrapeRequest"}}}},"responses":{"200":{"description":"Video context extracted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScrapeResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"A valid API key is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Insufficient credits before upstream execution","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Video is unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Upstream extraction error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream provider failed or challenged the request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/frames":{"post":{"tags":["Visual Inspection"],"operationId":"extractFrames","summary":"Slice high-resolution frames at specific timestamps (Layer 2A)","description":"Extracts up to 20 high-resolution JPEG frames at requested timestamps_sec using ISO-BMFF sidx byte-range slicing or storyboard cropping. Costs 1 credit.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FramesRequest"}}}},"responses":{"200":{"description":"Frames extracted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FramesResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"A valid API key is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Insufficient credits before upstream execution","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Video is unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Frame extraction failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream provider failed or challenged the request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/search":{"post":{"tags":["Discovery"],"operationId":"searchVideos","summary":"Search videos with optional scrape enrichment (Layer 2B)","description":"Searches live YouTube videos (source=\"live\", 1 credit + 1 per scraped video) or searches the cached video index (source=\"index\", 0 credits up to 1,000/day with optional domain filter and [MM:SS] transcript snippets, +1 per scraped result when scrape=true).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchRequest"}}}},"responses":{"200":{"description":"Search results returned","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"A valid API key is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Insufficient credits before upstream execution","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Video is unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Daily free index search limit reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Search failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream provider failed or challenged the request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/agent":{"post":{"tags":["Agent"],"operationId":"analyzeVideos","summary":"Run progressive-disclosure video understanding agent (Layer 3)","description":"Scrapes deterministic context first, inspects visual storyboard grids and frames, and returns grounded JSON with [MM:SS] citations. Low/medium/high effort costs 3/5/10 credits.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentRequest"}}}},"responses":{"200":{"description":"Agent analysis complete","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"A valid API key is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Insufficient credits before upstream execution","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Video is unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Agent execution failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream provider failed or challenged the request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"webhooks":{}}