A simple and easy-to-use unofficial YouTube API Wrapper
Project description
Simple YouTube API
An unofficial lightweight Python wrapper for extracting video metadata and transcripts from YouTube videos.
Features
- 🎥 Extract video metadata (title, thumbnail, short description)
- 📝 Get video transcripts in various languages
- ⚡ Simple and easy to use interface
- 🔒 No API key required
Installation
pip install simple-yt-api
Quick Start
from simple_yt_api import YouTubeAPI
# Initialize with a YouTube URL
url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
yt = YouTubeAPI(url)
# Get video metadata
metadata = yt.data()
print(metadata["title"])
# Get video transcript
transcript = yt.get_transcript(language_code="tr", as_dict=True) # Get Turkish transcript. Defaults to "en".
print(transcript)
# Get both metadata and transcript at once
data, transcript = yt.get_video_data_and_transcript(
language_code="es",
as_dict=False # Return transcript as plain text
)
API Reference
YouTubeAPI Class
YouTubeAPI(url: str)
Initialize the API with a YouTube video URL.
data() -> dict
Returns video metadata dictionary containing:
video_id: YouTube video IDtitle: Video titleimg_url: Thumbnail URLshort_description: Video description
get_transcript(language_code: str = "en", as_dict: bool = True) -> list[dict] | str
Get video transcript in specified languages.
language_code (str, optional): The language code for the desired transcript. Defaults to "en".as_dict (bool, optional): IfTrue, returns the transcript as a list of dictionaries; otherwise, returns the transcript as a string. Defaults toTrue.
get_video_data_and_transcript(language_code: str = "en", as_dict: bool = True) -> tuple
Returns both video metadata and transcript for a YouTube video in one call without worrying about errors.
Error Handling
The library includes custom exceptions:
InvalidURL: For invalid YouTube URL format.NoVideoFound: When a video is not accessible or doesn't exist.NoMetadataFound: When no metadata is found for the video.TranscriptsDisabled: When transcripts are not available for the video.NoTranscriptFound: When no transcript is available for the video.
Requirements
- requests==2.32.3
- beautifulsoup4==4.13.4
- youtube-transcript-api==1.0.3
Warning
Sending too many requests in a short period might lead to your IP address being temporarily blocked by YouTube. Use responsibly.
License
This project is licensed under the MIT License.
Links
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 simple_yt_api-2.0.0.tar.gz.
File metadata
- Download URL: simple_yt_api-2.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bf38ac03977cf140b112f0702922969813090f5b1d0ca65dc190a82930f9196
|
|
| MD5 |
7718a6f2793a0c336f4e3237124c2b52
|
|
| BLAKE2b-256 |
80a759fcde9b4fc68aa87034752bbfe79644ac1efd963d95e9b5c4edd830846f
|
File details
Details for the file simple_yt_api-2.0.0-py3-none-any.whl.
File metadata
- Download URL: simple_yt_api-2.0.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6506805e1d1ff75e3bd124cc15eba988ae9766fe62fdc019f983adafb88c4412
|
|
| MD5 |
d145649e9a59b3a5559be98696acba09
|
|
| BLAKE2b-256 |
541fd2cfcca9fce223cd84f704b9af1e238a8c5a4cf03ff652d7cd4ec2055902
|