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
Release history Release notifications | RSS feed
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab6c145de941af2031062170d19bb211be5b0594359b081e7436d46e1fb5de77
|
|
| MD5 |
601ec0db52507a4b56d0e7e640f3c596
|
|
| BLAKE2b-256 |
c3dc532aa507fba1e7067e2df8957b33e245bb8773a1e771647f39e8409b9239
|
Provenance
The following attestation bundles were made for stophy-0.2.0.tar.gz:
Publisher:
publish.yml on stophydotdev/sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stophy-0.2.0.tar.gz -
Subject digest:
ab6c145de941af2031062170d19bb211be5b0594359b081e7436d46e1fb5de77 - Sigstore transparency entry: 2026424406
- Sigstore integration time:
-
Permalink:
stophydotdev/sdk@2e0127ef18934c84685d34ec22d667779ce4349e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/stophydotdev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e0127ef18934c84685d34ec22d667779ce4349e -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9614b09c7b0d7aa6323794e61595986cf5510a8687edf9ad98abaec9087eab9d
|
|
| MD5 |
f96f8189a78ac37123d181d557c8068b
|
|
| BLAKE2b-256 |
e442731b9aafd682b30eda9dfe3866ccef02a2eda46a870e86a237b2237cb6a1
|
Provenance
The following attestation bundles were made for stophy-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on stophydotdev/sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stophy-0.2.0-py3-none-any.whl -
Subject digest:
9614b09c7b0d7aa6323794e61595986cf5510a8687edf9ad98abaec9087eab9d - Sigstore transparency entry: 2026424545
- Sigstore integration time:
-
Permalink:
stophydotdev/sdk@2e0127ef18934c84685d34ec22d667779ce4349e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/stophydotdev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e0127ef18934c84685d34ec22d667779ce4349e -
Trigger Event:
push
-
Statement type: