Capslane Python SDK
The Capslane Python SDK retrieves YouTube transcripts from Python applications. It returns existing captions when available and can generate a transcript when a video has no usable caption track. The package uses the Python standard library and has no runtime dependency.
Requirements
- Python 3.10 or later
- A Capslane API key from the dashboard
Installation
pip install capslane
Retrieve a transcript
import os
from capslane import CapslaneClient
capslane = CapslaneClient(os.environ["CAPSLANE_API_KEY"])
result = capslane.transcript(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
mode="auto",
)
transcript = (
capslane.wait_for_transcript(result)
if "jobId" in result
else result
)
print(transcript["content"])
Check a transcript job
job = capslane.transcript_job(
"job_00000000-0000-0000-0000-000000000000"
)
wait_for_transcript polls an accepted job until it completes, fails or reaches the timeout.
transcript = capslane.wait_for_transcript(
job,
interval=2.0,
timeout=20 * 60,
)
Request options
| Option | Type | Description |
|---|---|---|
url |
str |
Public YouTube URL or 11-character video ID. |
lang |
str |
Optional preferred language code. |
mode |
native, auto or generate |
Selects how Capslane obtains the transcript. |
text |
bool |
Returns one text string instead of timestamped segments. |
chunk_size |
int |
Groups transcript segments into larger chunks. |
Modes
nativereturns existing captions and never starts speech transcription.autouses existing captions first and generates a transcript only when needed.generatecreates a transcript from the video audio.
Errors
Failed requests raise CapslaneError. The error includes the HTTP status, Capslane error code and request ID when available.
from capslane import CapslaneError
try:
capslane.transcript("invalid")
except CapslaneError as error:
print(error.status, error.code, error.request_id)
Security
Use Capslane from a trusted server. Do not expose API keys in browser code, public repositories or client-side environment variables.
Links
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file capslane-0.1.0.tar.gz.
File metadata
- Download URL: capslane-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11276acc4e573b613099241b5633d007001a4203be15de4d88d51c348e95c280
|
|
| MD5 |
21891df90373ee073f68138cd161e6de
|
|
| BLAKE2b-256 |
9a6851d939fae7aa2bdc0e38ec2551a3884eff0c584ac5abeb2151915e78bc4d
|
Provenance
The following attestation bundles were made for capslane-0.1.0.tar.gz:
Publisher:
publish.yml on Webba-Creative-Technologies/capslane-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
capslane-0.1.0.tar.gz -
Subject digest:
11276acc4e573b613099241b5633d007001a4203be15de4d88d51c348e95c280 - Sigstore transparency entry: 2697632968
- Sigstore integration time:
-
Permalink:
Webba-Creative-Technologies/capslane-python@76cd0559cc40cc497bbdf782cd6bc4481b9cd575 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Webba-Creative-Technologies
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@76cd0559cc40cc497bbdf782cd6bc4481b9cd575 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file capslane-0.1.0-py3-none-any.whl.
File metadata
- Download URL: capslane-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27a757f29e80d407c2d21116ba479e44469110fe0361a37379fa8f0b150244e9
|
|
| MD5 |
ea06fbeed3268bbea0a079d2f86afec7
|
|
| BLAKE2b-256 |
18a9edcfb6b820222ff2feab2af983c259342b2e0c2372c94bd7bc86fb2a6a90
|
Provenance
The following attestation bundles were made for capslane-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Webba-Creative-Technologies/capslane-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
capslane-0.1.0-py3-none-any.whl -
Subject digest:
27a757f29e80d407c2d21116ba479e44469110fe0361a37379fa8f0b150244e9 - Sigstore transparency entry: 2697633064
- Sigstore integration time:
-
Permalink:
Webba-Creative-Technologies/capslane-python@76cd0559cc40cc497bbdf782cd6bc4481b9cd575 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Webba-Creative-Technologies
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@76cd0559cc40cc497bbdf782cd6bc4481b9cd575 -
Trigger Event:
workflow_dispatch
-
Statement type: