Skip to main content

Official Python SDK for Stophy - YouTube context API for AI agents.

Project description

stophy

Official Python SDK for Stophy YouTube context API for AI agents. Search videos, fetch transcripts, read comments and live chat, inspect channels and playlists, and get autocomplete suggestions, all returned as structured JSON.

Install

pip install stophy

Get an API key from your Stophy dashboard. The SDK sends it as Authorization: Bearer <key> on every request.

Quick start

from stophy import Stophy

stophy = Stophy()  # reads STOPHY_API_KEY
result = stophy.transcript("https://www.youtube.com/watch?v=D7liwdjvhWc")
print(result["data"]["text"])

Methods

Method Description
stophy.video_details(url) Video metadata and related videos
stophy.transcript(url) Timestamped captions and full text
stophy.comments(url, ...) Top-level comments
stophy.replies(token) Replies for a comment thread
stophy.live_chat(url, ...) Live stream chat messages
stophy.search(...) Search with filters for type, sort, date, duration, features
stophy.channel(...) Channel metadata + content by tab
stophy.playlist(...) Playlist items, paginated
stophy.suggest(...) Search autocomplete suggestions
stophy.credits() Current credit balance
stophy.logs(...) Recent request logs
stophy.usage(...) Daily credit/request counts

Methods use snake_case options and map them to API field names. The generic video(...) method remains available for discriminant-based calls.

# Search
results = stophy.search("typescript tutorial", sort_by="popularity", duration="long")

# Comments, then replies to a comment
comments = stophy.comments(url, sort_by="top")
token = comments["data"]["items"][0].get("repliesToken")
if token:
    replies = stophy.replies(token)

# Autocomplete and account
print(stophy.suggest("react")["data"]["suggestions"])
print(stophy.credits()["data"]["credits"])

Pagination

token = None
while True:
    page = stophy.search("lofi", continuation_token=token)
    ...  # handle page["data"]["items"]
    token = page["data"].get("continuationToken")
    if not token:
        break

Async

AsyncStophy exposes the same operations with async/await:

from stophy import AsyncStophy

async with AsyncStophy() as stophy:
    result = await stophy.transcript(
        "https://www.youtube.com/watch?v=D7liwdjvhWc"
    )
    print(result["data"]["text"])

Errors

Non-2xx responses raise StophyError:

from stophy import Stophy, StophyError

try:
    stophy.credits()
except StophyError as err:
    print(err.status, err.code, err, err.request_id)
    # err.code: "UNAUTHORIZED" | "INSUFFICIENT_CREDITS" | "BAD_REQUEST" |
    #           "INVALID_INPUT" | "NOT_FOUND" | "CONCURRENCY_LIMITED" | "INTERNAL_ERROR"

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stophy-0.2.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

stophy-0.2.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file stophy-0.2.0.tar.gz.

File metadata

  • Download URL: stophy-0.2.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stophy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ab6c145de941af2031062170d19bb211be5b0594359b081e7436d46e1fb5de77
MD5 601ec0db52507a4b56d0e7e640f3c596
BLAKE2b-256 c3dc532aa507fba1e7067e2df8957b33e245bb8773a1e771647f39e8409b9239

See more details on using hashes here.

Provenance

The following attestation bundles were made for stophy-0.2.0.tar.gz:

Publisher: publish.yml on stophydotdev/sdk

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

File details

Details for the file stophy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: stophy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stophy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9614b09c7b0d7aa6323794e61595986cf5510a8687edf9ad98abaec9087eab9d
MD5 f96f8189a78ac37123d181d557c8068b
BLAKE2b-256 e442731b9aafd682b30eda9dfe3866ccef02a2eda46a870e86a237b2237cb6a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for stophy-0.2.0-py3-none-any.whl:

Publisher: publish.yml on stophydotdev/sdk

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page