Find every moment a phrase is said in a video, then jump straight to it.
yt-grep works like grep, but on video transcripts. Give it a YouTube, TikTok, X or Instagram URL and a phrase (or a
regex), and it prints each match with its timestamp. On YouTube, each match also gets a link that opens the video at that second.
It's a small, readable example of the Supadata JS SDK (@supadata/js):
about 100 lines across two files.
$ yt-grep "https://www.youtube.com/watch?v=dQw4w9WgXcQ" "/give you up|let you down/" 16 match(es) for "/give you up|let you down/" in "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)" [en] 0:43 ♪ Never gonna give you up ♪ https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=43s 0:45 ♪ Never gonna let you down ♪ https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=45s ...
- Get a free API key at supadata.ai.
- Install and run:
git clone https://github.com/Troules/yt-grep.git && cd yt-grep npm install && npm run build export SUPADATA_API_KEY=your-key-here node dist/cli.js "https://youtu.be/dQw4w9WgXcQ" "never gonna"
You can also run npm link once so yt-grep is on your PATH.
yt-grep <video-url> <query> [options]
<query> is a case-insensitive phrase, or a regex written as /pattern/.
Options:
-l, --lang <code> Preferred transcript language (e.g. en, fr)
-m, --mode <mode> native | auto | generate (default: auto)
--json Print matches as JSON
-h, --help Show this help
The exit codes follow grep: 0 means there were matches, 1 means none, 2 means an error. Status messages go to stderr,
so stdout stays clean for pipes:
yt-grep "$URL" "pricing" --json | jq -r '.matches[].link'
Supadata turns video and social media URLs into transcripts, metadata and structured data through one API. All the API code is in src/cli.ts:
| SDK call | What it's for |
|---|---|
supadata.transcript({ url, lang, mode, text: false }) |
Fetches timestamped transcript chunks from any supported platform. mode: "auto" falls back to AI transcription when the video has no captions. |
supadata.transcript.getJobStatus(jobId) |
For long media and AI-generated transcripts, transcript() returns a { jobId } instead of the transcript. The CLI polls until the job is completed. |
supadata.metadata({ url }) |
Gets the video title for the header line. |
SupadataError |
A typed error with a machine-readable error code (transcript-unavailable, limit-exceeded, …) and details. |
The core pattern, in short:
import { Supadata } from "@supadata/js"; const supadata = new Supadata({ apiKey: process.env.SUPADATA_API_KEY! }); let transcript = await supadata.transcript({ url, text: false }); if ("jobId" in transcript) { // poll supadata.transcript.getJobStatus(transcript.jobId) until status === "completed" } // transcript.content: [{ text, offset /* ms */, duration, lang }, ...]
Matching and link building live in src/search.ts. They're pure functions, unit-tested without
network access (npm test).
Free-plan tip: the free plan has a per-second rate limit, so
yt-grepmakes its API calls one after the other instead of in parallel.
npm test # unit tests (node:test, no API key needed) npm run dev -- "<url>" "<query>" # run from source with Node's type stripping npm run build # compile to dist/
Requires Node.js 22.6 or later.