An open API service indexing awesome lists of open source software.

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.

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 API

Effortlessly 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!