🔎 YouTube Microservice (no API key)

Same /search contract as youtube-service/, backed by the youtube-search-api npm package instead of the official Data API.

Status

● no API key required, no quota

Example request

GET /search?q=eraser&maxResults=5

q required, min 3 characters. maxResults optional, default 12, capped at 50. No year/country filters here - that's specific to the official-API version.

Excluded channels

Set via the EXCLUDE_AUTHOR env var (comma-separated) - matching channels are dropped from every search result entirely.

Max duration

Set via the MAX_DURATION_MINUTES env var - currently 240 minutes. Videos longer than this are dropped from every search result entirely; an unparseable duration (missing, live, etc) is kept rather than assumed too long.

Query suggestions

GET /suggest?q=my+way&limit=5

q required, min 3 characters. limit optional, default 10, capped at 20. Proxies Google's unofficial, undocumented suggestqueries.google.com/complete/search autocomplete endpoint (ds=yt) - not a supported API, shape can change without notice. Locale is fixed server-side via SUGGEST_HL (currently en) and SUGGEST_GL (unset), not a per-request option. No auth, no cache - same tier as /search.

Audio streaming endpoint

GET /audio/:videoId
Header: X-Audio-Token: <token>

Downloads audio (audio/mp4) via yt-dlp into a transient, per-request temp file (a 0700 dir, fixed filename), streams that file to the client, then deletes it when the transfer ends. A crashed/killed request can leave a dir behind - a sweep removes any abandoned one older than 30 minutes, run at startup and every 10 minutes after. Capped at 60 minutes of video and 200MB of output. Requires the X-Audio-Token header to match the server's configured token - currently enabled. Missing/wrong token -> 401, disabled -> 503, bad videoId -> 400, 2 concurrent streams max -> 429. Not exposed cross-origin (no CORS on this route) - intended for a trusted, same-network client such as the standalone iOS player, never the browser-facing search UI. Configurable via AUDIO_TMP_DIR and AUDIO_DOWNLOAD_TIMEOUT_MS; do not run this service as root.

Trade-offs vs youtube-service/