A comprehensive URL safety scoring service built with FastAPI that analyzes URLs for potential security threats using multiple detection methods including heuristics, external reputation APIs, and network analysis.
- Multi-layered Analysis: Combines heuristics, external APIs, DNS/TLS checks
- Smart Normalization: URL expansion, IDN handling, tracking parameter removal
- Risk Scoring: 0-100 scoring with clear verdicts (ok/suspicious/malicious)
- Performance Optimized: Parallel processing, caching, configurable timeouts
- Privacy Focused: Minimal data retention, PII redaction
- Production Ready: Rate limiting, API authentication, comprehensive logging
# Install dependencies
pip install -r requirements.txt
# Set up environment
cp .env.example .env
# Edit .env with your API keys
# Run the service
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Test endpoint
curl -X POST "http://localhost:8000/score_urls" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{"urls": ["https://example.com"]}'Once running, visit:
- Interactive docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
app/
├── main.py # FastAPI application entry point
├── api/ # API routes and endpoints
├── core/ # Core business logic
├── services/ # External integrations
├── models/ # Pydantic schemas
├── utils/ # Utility functions
└── config.py # Configuration management
All configuration is handled via environment variables. See .env.example for required settings.
pytest tests/ -v