A powerful, self-hosted, and ready-to-deploy API server built with FastAPI to fetch transcripts from any YouTube video. This project is containerized using Docker and managed with Docker Compose, making it incredibly easy to deploy and run.
- 🚀 High Performance: Built with FastAPI for fast and reliable API responses.
- 📦 Docker Ready: Comes with pre-configured
Dockerfileanddocker-compose.ymlfor seamless deployment and local development. - 📝 Professional Logging: Detailed logging is built-in, writing to both the console and a rotating
api.logfile for easy monitoring and debugging. - 🔑 No API Keys Needed: Leverages the robust
youtube-transcript-apilibrary which does not require any YouTube API keys. - 📚 Interactive Docs: Automatic, interactive API documentation provided by FastAPI (via Swagger UI) at the
/docsendpoint.
Once the server is running, you can access the following endpoints:
For a full, interactive documentation of the API, visit:
http://<your_server_ip>:5000/docs
Fetches the transcript for a specific video. You can specify one or more languages in order of preference.
- Endpoint:
GET /transcript/{video_id} - Example Request:
curl "http://127.0.0.1:5000/transcript/x4fEnyINwdw?languages=ar&languages=en" - Success Response (200):
{ "video_id": "x4fEnyINwdw", "transcript": [ { "text": "احنا بقينا في عصر جديد ...", "start": 0.08, "duration": 4.4 }, // ... more transcript parts ] }
Lists all available transcript languages for a given video. This is useful to check before requesting a specific transcript.
- Endpoint:
GET /transcripts/list/{video_id} - Example Request:
curl http://127.0.0.1:5000/transcripts/list/x4fEnyINwdw
- Success Response (200):
{ "video_id": "x4fEnyINwdw", "available_transcripts": [ { "language": "Arabic", "language_code": "ar", "is_generated": true, "is_translatable": true } ] }
This is the easiest way to get the server running on both your local machine and a production server.
- Clone the repository:
git clone https://github.com/amrpyt/youtube-transcript-api-project.git cd youtube-transcript-api-project - Run the server:
docker-compose up -d --build
- The API will now be running on port
5000. To see logs, rundocker-compose logs -f. - To stop the server, run
docker-compose down.
This project is perfectly set up for one-click deployment with Coolify.
- Connect your GitHub account to Coolify.
- Create a new "Application" resource and point it to this repository.
- Coolify will automatically detect the
Dockerfileordocker-compose.yml. - Set the port to
5000. - Click Deploy. That's it!
This project was set up by an AI assistant.