Skip to main content

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

  • native returns existing captions and never starts speech transcription.
  • auto uses existing captions first and generates a transcript only when needed.
  • generate creates 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

capslane-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

capslane-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

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

Hashes for capslane-0.1.0.tar.gz
Algorithm Hash digest
SHA256 11276acc4e573b613099241b5633d007001a4203be15de4d88d51c348e95c280
MD5 21891df90373ee073f68138cd161e6de
BLAKE2b-256 9a6851d939fae7aa2bdc0e38ec2551a3884eff0c584ac5abeb2151915e78bc4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for capslane-0.1.0.tar.gz:

Publisher: publish.yml on Webba-Creative-Technologies/capslane-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for capslane-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27a757f29e80d407c2d21116ba479e44469110fe0361a37379fa8f0b150244e9
MD5 ea06fbeed3268bbea0a079d2f86afec7
BLAKE2b-256 18a9edcfb6b820222ff2feab2af983c259342b2e0c2372c94bd7bc86fb2a6a90

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.0

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page