Skip to content

SiddheshKanawade/ugc-service

Repository files navigation

UGC Service API

A FastAPI service for handling YouTube videos and channels data with MongoDB.

Features

  • YouTube video and channel data management
  • MongoDB integration with Motor (async driver)
  • RESTful API with proper validation and error handling
  • Pagination and filtering support
  • OpenAPI documentation

Prerequisites

  • Python 3.8+
  • MongoDB

Installation

  1. Clone this repository
git clone https://github.com/yourusername/ugc-service.git
cd ugc-service
  1. Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Configure environment variables (or modify .env file)
MONGODB_URL=mongodb://localhost:27017
DATABASE_NAME=ugc_db
API_PREFIX=/api/v1
DEBUG=true

Running the Service

Start the API server:

python -m uvicorn app.main:app --reload

The API will be available at http://localhost:8000, and the documentation at http://localhost:8000/api/v1/docs.

API Endpoints

YouTube Video Endpoints

  • GET /api/v1/youtube/videos/ - Get all videos (paginated)
  • GET /api/v1/youtube/videos/{video_id} - Get a specific video (MongoDB ID or YouTube ID)
  • POST /api/v1/youtube/videos/ - Create a new video
  • PUT /api/v1/youtube/videos/{video_id} - Update a video
  • DELETE /api/v1/youtube/videos/{video_id} - Delete a video
  • GET /api/v1/youtube/videos/search/ - Search videos with filters

YouTube Channel Endpoints

  • GET /api/v1/youtube/channels/ - Get all channels (paginated)
  • GET /api/v1/youtube/channels/{channel_id} - Get a specific channel (MongoDB ID or YouTube ID)
  • POST /api/v1/youtube/channels/ - Create a new channel
  • PUT /api/v1/youtube/channels/{channel_id} - Update a channel
  • DELETE /api/v1/youtube/channels/{channel_id} - Delete a channel
  • GET /api/v1/youtube/channels/{channel_id}/videos - Get videos for a specific channel

Project Structure

ugc-service/
│
├── app/                    # Application package
│   ├── api/                # API endpoints
│   │   └── routes/         # API routes
│   ├── core/               # Core application code
│   ├── db/                 # Database related code
│   ├── models/             # Data models
│   ├── schemas/            # Pydantic schemas
│   ├── services/           # Business logic
│   └── main.py             # FastAPI application entry point
│
├── tests/                  # Test directory
├── .env                    # Environment variables
├── requirements.txt        # Python dependencies
└── README.md               # Project documentation

Testing

Run tests with pytest:

pytest

Data Models

The service supports the following data models:

YouTube Video

YouTube video data with fields like:

  • video_id, title, description
  • channel information
  • view/like/comment counts
  • thumbnails
  • tags
  • comments

YouTube Channel

YouTube channel data with fields like:

  • channel_id, title, description
  • subscriber/view counts
  • thumbnails
  • country
  • topic categories

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •