https://github.com/rojansapkota/youtubestatsapi
A Flask-based API to retrieve YouTube channel information, recent videos, video statistics, and generate video transcripts.
https://github.com/rojansapkota/youtubestatsapi
youtube-api youtube-stats youtube-stats-api
Last synced: 2 months ago
JSON representation
A Flask-based API to retrieve YouTube channel information, recent videos, video statistics, and generate video transcripts.
- Host: GitHub
- URL: https://github.com/rojansapkota/youtubestatsapi
- Owner: RojanSapkota
- License: mit
- Created: 2024-09-10T12:20:39.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-10T13:24:58.000Z (9 months ago)
- Last Synced: 2024-09-11T16:00:53.922Z (9 months ago)
- Topics: youtube-api, youtube-stats, youtube-stats-api
- Language: Python
- Homepage:
- Size: 860 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# YouTube Channel & Video API (Deprecated)
The `https://yt.lemnoslife.com` service has been discontinued due to violations of the YouTube Terms of Service, as per a notice received on **October 4, 2024** from the YouTube Legal Team. The endpoints relying on this service are now deprecated and may no longer function as intended. See the relevant discussion [here](https://codeberg.org/Benjamin_Loison/Thunderbird/issues/43#issuecomment-2369800)
```markdown
# YouTube Channel & Video APIEffortlessly access YouTube channel details, recent videos, video statistics, and transcripts with this Flask-based API. Designed for simplicity and efficiency, this tool helps you retrieve comprehensive YouTube data quickly.
## Features
- **Channel Information:** Get details about a YouTube channel, including title, description, and subscriber count.
- **Recent Videos:** Fetch the latest video URL from a specified channel.
- **Video Statistics:** Retrieve video title and view count.
- **Transcripts:** Generate transcripts for YouTube videos with ease.
- **Caching:** Utilizes caching to improve response times and reduce API load.
- **Error Handling:** Provides meaningful error messages for better debugging and user experience.
- **Flexible Querying:** Supports dynamic requests for various YouTube data using channel and video IDs.
- **Multiple Video Support:** Retrieve statistics for multiple videos at once by passing a list of video IDs.## How It Works
### 1. Channel Info
**Endpoint:** `/channel`**Method:** `GET`
**Query Parameter:**
- `id`: YouTube channel ID**Example Request:**
```bash
curl "http://localhost:5000/channel?id=CHANNEL_ID"
```**Response:**
```json
{
"title": "Channel Title",
"description": "Channel Description",
"subscribers": "Subscriber Count"
}
```### 2. Recent Video
**Endpoint:** `/recentvid`**Method:** `GET`
**Query Parameter:**
- `id`: YouTube channel ID**Example Request:**
```bash
curl "http://localhost:5000/recentvid?id=CHANNEL_ID"
```**Response:**
```json
{
"videoUrl": "https://www.youtube.com/watch?v=VIDEO_ID"
}
```### 3. Video Stats
**Endpoint:** `/stats`**Method:** `GET`
**Query Parameter:**
- `id`: YouTube video ID**Example Request:**
```bash
curl "http://localhost:5000/stats?id=VIDEO_ID"
```**Response:**
```json
{
"title": "Video Title",
"viewCount": "View Count"
}
```### 4. Transcript
**Endpoint:** `/transcript`**Method:** `GET`
**Query Parameter:**
- `id`: YouTube video ID**Example Request:**
```bash
curl "http://localhost:5000/transcript?id=VIDEO_ID"
```**Response:**
```json
{
"transcript": "Transcript Text"
}
```### 5. Error Handling
The API includes robust error handling, returning meaningful error messages when:
- No ID is provided
- The specified channel or video is not found
- An unexpected error occurs## Technologies Used
- **Backend:** Flask, Flask-Caching
- **APIs:** YouTube Data API, Kome AI for transcripts## Installation
To get started with the YouTube Channel & Video API, follow these installation steps:
1. **Clone the Repository**
```bash
git clone https://github.com/RojanSapkota/YouTubeStatsAPI.git
cd YouTubeStatsAPI
```2. **Create a Virtual Environment (optional but recommended)**
```bash
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
```3. **Install Required Packages**
```bash
pip install Flask Flask-Caching requests
```4. **Run the Application**
```bash
python main.py
```The API will be available at `http://localhost:5000`.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contact
For any questions or feedback, please contact [Rojan](mailto:[email protected]).
```### Key Corrections Made:
- Clarified some sentences for better readability.
- Ensured consistent formatting throughout.
- Maintained clarity in API functionality descriptions.Feel free to use or modify it as needed!