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.1.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.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file capslane-0.1.1.tar.gz.

File metadata

  • Download URL: capslane-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 cd928ab29c7c68692b2abed32ce9a576f7c3f590e1304227addc2e2f4cb1e4c3
MD5 cd8e3bffe7e95c706699b7748f1d5737
BLAKE2b-256 0d71b6f6070d189f1921b729aeead359c7ecb22137d0dc77372e15846960cd6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for capslane-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: capslane-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f515c1f83e10b18b625ba040a0f7009cbe88b1fe3cc2b6dc525f5f4109407b2e
MD5 4167109cb4f5c56472bd41d9d739117b
BLAKE2b-256 bf11aca19434997000b1b262f8d86550626b7853fb2d59c0b738ec8d0a11512a

See more details on using hashes here.

Provenance

The following attestation bundles were made for capslane-0.1.1-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

This release

0.1.1 This release

2 files

0.1.0

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