Skip to content

A Flask-based API to retrieve YouTube channel information, recent videos, video statistics, and generate video transcripts.

License

Notifications You must be signed in to change notification settings

KyleBrian/YouTubeStatsAPI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

# 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:

{
  "title": "Channel Title",
  "description": "Channel Description",
  "subscribers": "Subscriber Count"
}

2. Recent Video

Endpoint: /recentvid

Method: GET

Query Parameter:

  • id: YouTube channel ID

Example Request:

curl "http://localhost:5000/recentvid?id=CHANNEL_ID"

Response:

{
  "videoUrl": "https://www.youtube.com/watch?v=VIDEO_ID"
}

3. Video Stats

Endpoint: /stats

Method: GET

Query Parameter:

  • id: YouTube video ID

Example Request:

curl "http://localhost:5000/stats?id=VIDEO_ID"

Response:

{
  "title": "Video Title",
  "viewCount": "View Count"
}

4. Transcript

Endpoint: /transcript

Method: GET

Query Parameter:

  • id: YouTube video ID

Example Request:

curl "http://localhost:5000/transcript?id=VIDEO_ID"

Response:

{
  "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

    git clone https://github.com/RojanSapkota/YouTubeStatsAPI.git
    cd YouTubeStatsAPI
  2. Create a Virtual Environment (optional but recommended)

    python -m venv venv
    source venv/bin/activate   # On Windows use `venv\Scripts\activate`
  3. Install Required Packages

    pip install Flask Flask-Caching requests
  4. Run the Application

    python main.py

The API will be available at http://localhost:5000.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For any questions or feedback, please contact Rojan.

About

A Flask-based API to retrieve YouTube channel information, recent videos, video statistics, and generate video transcripts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%