What is youtube-transcript-api?
Format transcript text locally.
Format transcript text locally.
Apart from marked quotes, everything on this page comes from our own test run.
How we tested youtube-transcript-api
We ran youtube-transcript-api v1.2.4 on (UTC) in an isolated sandbox: Ubuntu under WSL2. Networking was switched off, so nothing was downloaded or sent during the test. The test ran as an unprivileged user with an empty home directory.
Sandbox checks recorded before the run, all passed: network disabled, home directory blocked, secrets blocked, writes limited to the test workspace.
Setup as recorded: WSL2 no-network sandbox; installed release and dependencies verified against official wheel SHA-256; no installation.
- The input file
example.py(344 bytes) was placed in an empty workspace. - We ran
bin/test example.py. It exited with code 0. - We kept the exact output (84 bytes) and compared it with the input byte for byte.
- The terminal session was recorded (6.72 seconds).
bin/test is defined by the test definition in our repository (config/curation/youtube-transcript-api-1.2.4-1029.json), shown below as it stood when this page was built. The script itself is not part of the hashed test record, unlike the input, output and command above.
#!/usr/bin/python3 -I
import contextlib,io,sys,time
START=time.perf_counter()
sys.path.insert(0,"/tmp/ws")
N={"__name__":"curated_example"}
OUT=[]
def check(label,test):
try: ok=bool(test())
except Exception as error:
ok=False
print(type(error).__name__,file=sys.stderr)
OUT.append((ok,label))
try:
with contextlib.redirect_stdout(io.StringIO()):
exec(compile(open(sys.argv[1],encoding="utf-8").read(),sys.argv[1],"exec"),N)
except BaseException as error:
print("Example failed: "+type(error).__name__,file=sys.stderr)
check('Text lines',lambda: N["text"]=="hi\nok")
check('Text count',lambda: len(N["raw"])==2)
check('Text first',lambda: N["raw"][0]["text"]=="hi")
check('Text JSON',lambda: __import__("json").loads(N["encoded"])==N["raw"])
for ok,label in OUT: print(("PASS " if ok else "FAIL ")+label)
print("%d/%d passed in %.2f s"%(sum(o for o,_ in OUT),len(OUT),time.perf_counter()-START))
What we saw
What we tried: Local documented API adaptation: Text lines, Text count, Text first, Text JSON.
What went in: 9 lines of text (344 bytes).
What came out: 5 lines of text (84 bytes).
Exact recorded input and output. Invisible characters are written out (for example \x1b is the escape character) so you can see them.
import youtube_transcript_api as y
from youtube_transcript_api import formatters as f
S=y.FetchedTranscriptSnippet
parts=[S("hi",0,1),S("ok",1,1)]
meta=("demo","English","en",False)
items=y.FetchedTranscript(parts,*meta)
text=f.TextFormatter().format_transcript(items)
raw=items.to_raw_data()
encoded=f.JSONFormatter().format_transcript(items)
PASS Text lines
PASS Text count
PASS Text first
PASS Text JSON
4/4 passed in 0.17 s
Measured result
- Input size
- 344 bytes
- Output size
- 84 bytes
- Sandbox run time
- 10.52 seconds: the whole isolated sandbox run, including sandbox start-up. This is not the tool's own processing time.
- Demo recording length
- 6.72 seconds
Recorded measurement: 4 of 4 README checks passed in 0.17 seconds.
Limits of this test
Only synthetic transcript snippets were formatted locally; no YouTube video, captions, or network retrieval was tested.
This record covers one input, one version (v1.2.4) and one platform (Ubuntu under WSL2). It is not a speed benchmark: the sandbox time includes start-up. We did not run it on Windows or macOS here, so results there may differ.
Is youtube-transcript-api a fit for you?
- Check further if your input goes beyond our sample: the limit quoted above comes from the project itself.
- Check further if you need it on Windows: this record covers Ubuntu under WSL2 only.
Questions this test answers
Did we test youtube-transcript-api on Windows?
No. This record ran on Ubuntu under WSL2. It does not show how youtube-transcript-api behaves in a Windows console.
Which version did we test, and when?
youtube-transcript-api v1.2.4, on (UTC).
Did the test need internet access?
No. The sandbox had networking switched off for the whole run.
What does youtube-transcript-api not handle?
Our single input does not probe this. The project names its own limit, quoted under Limits of this test; inputs like that need their own test.
Watch the test
Pressing play loads the YouTube player from youtube-nocookie.com; YouTube (Google) then applies its own privacy policy. Nothing is loaded from YouTube before you press play. Privacy
Transcript
Format transcript text locally.
It converts transcript objects into plain text and JSON. It has 8,524 stars on GitHub and an MIT license.
Here is what it gives you: one, plain text; two, raw data; three, JSON text.
We ran the README example in a sandbox with no network: 4 checks in all.
Result: 4 of 4 checks passed in 0.17 seconds.
Our verdict: it works. One honest limit: only synthetic transcript snippets were formatted locally; no YouTube video, captions, or network retrieval was tested.
Full test results are in the Tools link on our profile.
Test records
Each test keeps the code shown in its video. Code TXTFMT leads here; you can also search any code on Find a code.
| Code | Tested | Version | Platform | Result |
|---|---|---|---|---|
| TXTFMT | v1.2.4 | Ubuntu under WSL2 | see record |
Official links
Related tools we tested
- cachetools: see record
- filelock: see record
- fsspec: see record
- httpx: see record
- more-itertools: see record
- multidict: see record
License and attribution
- MIT — youtube-transcript-api by jdepoix (MIT)
Rights holder: jdepoix. Permission: use_modify_distribute License source ↗ - LicenseRef-RepoProof-Owned — RepoProof
Rights holder: RepoProof. Permission: use_modify_distribute License source ↗
Covers 6 assets: demo input, demo output, demo recording, input frame, output frame, demo extra checks json. - LicenseRef-RepoProof-Owned — RepoProof capture of github.com/jdepoix/youtube-transcript-api
Rights holder: RepoProof. Permission: use_modify_distribute License source ↗
Covers 3 assets: demo extra github page png, demo extra github stars png, demo extra github json.
Production note
AI-assisted script and synthetic narration; demo recorded by our automated test workflow.
Page text is assembled from the recorded test data. Sentences taken from the tool's README are marked as quotes.