A FastAPI-based service that provides secure access to YouTube video transcript searching using Google's Gemini AI model.
- Secure authentication using public key cryptography
- YouTube transcript extraction with proxy support
- AI-powered transcript search using Google's Gemini
- Request tracking and metadata storage using PocketBase
- CORS protection for the textframe Chrome Extension
- Python 3.9+
- Docker (for containerized deployment)
- PocketBase instance
- Google Gemini API access
- HTTPS Proxy credentials (for YouTube access)
DB_URL=your_pocketbase_url
EXTENSION_ID=your_chrome_extension_id
GEMINI_API_KEY=your_gemini_api_key
GEMINI_MODEL_NAME=your_model_name
PROXY_USERNAME=your_proxy_username
PROXY_PASSWORD=your_proxy_password
PROXY_DOMAIN=your_proxy_domain
PROXY_PORT=your_proxy_port
- Install dependencies:
pip install -r requirements.txt
- Run the server:
fastapi dev main.py
see FastAPI for more info
- Build the image:
docker build -t textframe-api .
- Run the container:
docker run -d \
-p 80:80 \
--env-file .env \
textframe-api
The API implements a secure authentication flow:
- Client registers their public key
- Client requests a nonce
- Client signs the nonce with their private key
- API verifies the signature before processing requests
Register a new public key for authentication.
{
"uuid": "user_unique_id",
"public_key": "base64_encoded_public_key"
}
Get a nonce for request signing.
Header: X-UUID: user_unique_id
Search video transcripts.
Headers:
X-UUID: user_unique_id
X-Nonce-Signature: signed_nonce
Body:
{
"query": "search_query",
"video_id": "youtube_video_id"
}
- FastAPI - Web framework
- PocketBase - Database
- youtube_transcript_api - Transcript extraction
- google.generativeai - Gemini AI integration
- PyNaCl - Cryptographic operations
- Pydantic - Data validation
python-api/
├── app/
│ └── main.py # Main application file
├── Dockerfile # Container definition
├── requirements.txt # Python dependencies
└── README.md # This file
The API tracks usage metrics in PocketBase:
- Token usage
- User queries
- AI responses
- User identifiers
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License - see the LICENSE file for details.