Skip to main content

TubePull Python SDK

PyPI CI Python

tubepull is the official Python SDK for the TubePull video download API. Give it a public YouTube, TikTok, Instagram, Reddit, X (Twitter), Twitch, Facebook or Vimeo URL and it returns a finished MP4 or MP3 file on a signed download link. TubePull does the fetching, merging and transcoding. Your code takes three calls: download(), wait(), save().

from tubepull import TubePull

with TubePull() as tp:  # reads TUBEPULL_API_KEY
    job = tp.download("https://www.tiktok.com/@scout2015/video/6718335390845095173")
    job = tp.wait(job)
    print(tp.save(job, "downloads/"))  # downloads/<request_token>.mp4
  • Sync TubePull and async AsyncTubePull clients with the same methods
  • Typed dataclasses for every response, plus a typed exception for every API error
  • Polling with backoff, Retry-After handling on 429s, and file saving that streams to disk and checks the size
  • One dependency: httpx. Python 3.10+

Install

pip install tubepull

Get an API key from the TubePull Developer portal and export it:

export TUBEPULL_API_KEY="tp_live_your_api_key_here"

The key is a Bearer token, so keep it in an environment variable or a secrets manager, not in source code. You can also pass it directly: TubePull(api_key="tp_live_...").

Quickstart

Download a video as MP4

from tubepull import TubePull

tp = TubePull()

job = tp.download("https://www.youtube.com/watch?v=dQw4w9WgXcQ", quality="1080")
print(job.request_token, job.status)  # 9f8c...  queued

job = tp.wait(job, timeout=900)  # polls GET /video/status with backoff
print(job.download_url, job.expires_in, job.file_size_bytes, job.file_mime)

path = tp.save(job, "downloads/")  # streams the signed file to disk

format is "video" (MP4) or "audio" (MP3). quality is a maximum height ("2160", "1440", "1080", "720", "480", "360") or "best", which is the default.

Extract audio as MP3

job = tp.wait(tp.download("https://soundcloud.com/artist/track", format="audio"))
tp.save(job, "podcast.mp3")
meta = tp.metadata("https://www.instagram.com/reel/REEL_ID/")
print(meta.platform, meta.title, meta.duration, meta.content_kind)
for option in meta.quality_selector.options:
    print(option.value, option.label)

metadata() uses your metadata allowance, not a download credit, and no file is fetched.

Check your credits and rate limit

credits = tp.credits()  # free to call
print(credits.plan, credits.downloads.remaining, credits.metadata.remaining)

print(tp.rate_limit)  # from the last response's headers
# RateLimit(limit=..., remaining=..., reset=..., credits_remaining=...)

The SDK doesn't hardcode plan limits. tp.rate_limit reflects the X-RateLimit-* and X-Credits-Remaining headers on the most recent response.

Async

import asyncio
from tubepull import AsyncTubePull


async def main() -> None:
    async with AsyncTubePull() as tp:
        jobs = [await tp.download(u) for u in URLS]
        done = await asyncio.gather(*(tp.wait(j) for j in jobs))
        for job in done:
            await tp.save(job, "downloads/")


asyncio.run(main())

API

Method Endpoint Returns
download(url, format="video", quality="best") POST /video/download Job (status="queued")
status(job_or_token) GET /video/status Job
wait(job_or_token, timeout=900, *, poll_interval=5, max_interval=60, backoff=2) polls GET /video/status Job (status="done")
metadata(url) GET /video/metadata Metadata
credits() GET /credits Credits
create_key(label=None) POST /auth/key ApiKey
save(job, path=".", *, chunk_size=1 MiB) signed download_url pathlib.Path

Downloads run asynchronously. A job moves through queued, claimed and running to done or failed. When it is done, download_url is a signed link valid for expires_in seconds (one hour). If the link expires, call status() again with the same token for a fresh one.

save() takes a file path or a directory. In a directory, or with a path ending in /, the file is named <request_token>.<ext> from file_mime. It writes to a .part file and renames it only when the size matches file_size_bytes. The signed link is fetched without your API key.

Client options: TubePull(api_key=None, *, base_url=None, timeout=30, max_retries=2, max_retry_wait=60, http_client=None). base_url defaults to $TUBEPULL_API_BASE or https://tubepull.com/api/v1.

Every model keeps the full response dict in .raw, so a field added on the server is never lost.

Supported platforms

Each platform page covers the URL formats it accepts and its quirks:

Vimeo, Dailymotion, SoundCloud, Bandcamp, Mixcloud, Pinterest and Streamable are supported too. The API reference has the current list.

Error handling

Every API error raises a subclass of tubepull.TubePullError. Errors from the API itself (APIError and its subclasses) carry status_code, code, message, details and headers.

Exception HTTP code What to do
InvalidRequestError 400 invalid_request Fix the request (missing URL or bad token)
UnsupportedPlatformError 400 unsupported_platform Skip the link. No credit was spent
AuthError 401 unauthorized Check the API key. Also raised by the constructor when no key is set
QuotaExceededError 402 download_quota_exceeded, metadata_quota_exceeded, hard_cap_reached Stop the batch. Upgrade or raise your overage cap
NotFoundError 404 not_found Unknown token, or a token from another account
RateLimitError 429 rate_limited Wait err.retry_after seconds
ContentBlockedError 451 content_blocked_dmca Don't retry. See reference_id and counter_notice_url
ServerError 5xx enqueue_failed, metadata_unavailable, delivery_failed, key_create_failed Retry later. For delivery_failed, queue a new download
JobFailedError n/a err.error bucket Raised by wait() when a job ends failed. Final for that URL
WaitTimeoutError n/a n/a wait() ran out of time. Also a TimeoutError
DownloadError n/a n/a save() failed, the link expired or the size didn't match
APIConnectionError n/a n/a Network problem. No HTTP response
from tubepull import QuotaExceededError, RateLimitError, TubePull, TubePullError

tp = TubePull()
for url in urls:
    try:
        tp.save(tp.wait(tp.download(url)), "downloads/")
    except QuotaExceededError:
        break  # out of credits or at the overage cap
    except RateLimitError as err:
        print(f"rate limited, retry in {err.retry_after}s")
        break
    except TubePullError as err:
        print(f"skipped {url}: {err}")

Retries: the client retries 429 rate_limited on its own, up to max_retries times, when Retry-After is no longer than max_retry_wait seconds. Longer waits raise RateLimitError straight away so you can decide what to do. Other errors aren't retried, because a failed download request may already have spent a credit. During wait(), a 429 sleeps for Retry-After when that still fits inside timeout.

Acceptable use

Only download content you own, have permission or a licence to use, or that is in the public domain, and follow each platform's terms. Use of the API is governed by Section 8 (Developer API) of the TubePull Terms. URLs blocked under a copyright takedown return 451 (ContentBlockedError).

License

MIT © Moondust Studios

Metadata

Release files for tubepull 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tubepull 0.1.0
File Size Uploaded Provenance Actions
tubepull-0.1.0.tar.gz 19.5 kB With provenance Details for tubepull-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tubepull 0.1.0
File Interpreter ABI Platform Actions
tubepull-0.1.0-py3-none-any.whl Python 3 none any Details for tubepull-0.1.0-py3-none-any.whl

Total release size: 37.6 kB

Release files / tubepull-0.1.0.tar.gz

Download URL tubepull-0.1.0.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
47f0b4aae00acafdba16e2d896a97aa59070f57851cf3165e82b99e362e4e1d2
BLAKE2b-256 checksum
How to use checksums
1b711dbbdb496bb09013f1a512d1a8611f925ec00a4ffa4563af89e9f7eda917
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / tubepull-0.1.0-py3-none-any.whl

Download URL tubepull-0.1.0-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf3d3f9daf0f26dcd17949ed00b8ba8b949fdfc990548bdcb96ec794cac488d1
BLAKE2b-256 checksum
How to use checksums
44c3f61141d62673dcdade7705b220c32bcbdc234aac0d854c4d1ec05db2f854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for tubepull 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tubepull-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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