High-performance social media video downloader API - Built with Rust + yt-dlp.
- 🚀 Fast - Rust-powered with Axum framework
- 📦 All-in-One - Includes yt-dlp for media extraction
- 🔒 Secure - Built-in rate limiting and CORS protection
- 🐳 Docker Ready - Single container deployment
- 📊 Cached - Smart caching with TTL support
| Platform | Video | Image |
|---|---|---|
| TikTok | ✅ | ✅ |
| X (Twitter) | ✅ | ✅ |
| ✅ |
# Build image
docker build -t snatch-backend snatch-rs/
# Run container
docker run -d \
--name snatch-backend \
-p 38701:3001 \
-e ALLOWED_ORIGINS=https://your-frontend.com \
--restart always \
snatch-backend
# Check health
curl http://localhost:38701/healthCreate docker-compose.yml:
services:
api:
build:
context: .
dockerfile: snatch-rs/Dockerfile
container_name: snatch-backend
ports:
- "38701:3001"
environment:
- ALLOWED_ORIGINS=${ALLOWED_ORIGINS:-}
- RUST_LOG=${RUST_LOG:-info}
- RATE_LIMIT_MAX=${RATE_LIMIT_MAX:-10}
restart: unless-stopped
volumes:
- ./data:/app/data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/health"]
interval: 30s
timeout: 10s
retries: 3Then run:
# Create .env from example
cp .env.example .env
# Edit .env and configure ALLOWED_ORIGINS
# Start service
docker compose up -d --build# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install yt-dlp
pip install yt-dlp
# or
brew install yt-dlp
# Run
cd snatch-rs
cargo run --releaseGET /health
Response: "OK"POST /api/extract
Content-Type: application/json
{
"url": "https://www.tiktok.com/@user/video/123"
}
Response:
{
"success": true,
"platform": "tiktok",
"title": "Video Title",
"thumbnail": "https://...",
"formats": [
{
"format_id": "0",
"ext": "mp4",
"quality": "720p",
"url": "https://...",
"size": 12345678
}
]
}See docs/API.md for full API documentation.
| Variable | Description | Default | Production |
|---|---|---|---|
ALLOWED_ORIGINS |
CORS allowed origins | All origins | Set to your frontend domain |
RUST_LOG |
Log level | info |
info or warn |
PORT |
Server port | 3001 |
3001 |
RATE_LIMIT_MAX |
Requests per minute | 10 |
10 |
RATE_LIMIT_WINDOW |
Rate window (ms) | 60000 |
60000 |
server {
listen 443 ssl http2;
server_name api.your-domain.com;
ssl_certificate /etc/letsencrypt/live/api.your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.your-domain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:38701;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}- Language: Rust
- Framework: Axum (Tokio)
- Downloader: yt-dlp
- Deployment: Docker
snatch/
├── snatch-rs/
│ ├── src/
│ │ ├── main.rs # Entry point
│ │ ├── handlers.rs # API endpoints
│ │ ├── models.rs # Data models
│ │ ├── cache.rs # Caching logic
│ │ ├── extractor.rs # yt-dlp integration
│ │ ├── validation.rs # URL validation
│ │ └── retry.rs # Retry logic
│ ├── Cargo.toml
│ └── Dockerfile
└── docs/
└── API.md # API documentation
- CORS: Configure
ALLOWED_ORIGINSin production - Rate Limiting: Default 10 requests/minute per IP
- Input Validation: URL sanitization and pattern matching
- No Data Storage: No logs or user data persisted
# View logs
docker logs -f snatch-backend
# Check health
curl http://localhost:38701/healthThis API is designed to work with the Snatch Frontend.
MIT