Welcome to Short-URL API
Short-URL is a comprehensive URL shortener and management API built with FastAPI. It goes beyond simple URL shortening by providing advanced features like password protection, JWT authentication, hit tracking, and complete URL lifecycle management.What is Short-URL?
Short-URL is a production-ready API service that allows you to:- Create short URLs with custom aliases
- Protect URLs with optional password authentication
- Manage URLs through a complete set of authenticated endpoints
- Track usage with built-in hit counters and analytics
- Control access by pausing and resuming URLs on demand
Key Features
JWT Authentication
Secure token-based authentication using Bearer tokens for all management operations
Password Protection
Optional password protection for URLs with secure password hashing using PBKDF2-SHA256
URL Management
Complete control over your URLs - change destinations, pause/resume, delete, and reset hit counters
Hit Tracking
Built-in analytics to track how many times your short URLs are accessed
MongoDB Backend
Asynchronous MongoDB integration with Motor for high-performance data operations
CORS Support
Configurable CORS middleware for cross-origin requests
Architecture Overview
Short-URL is built on a modern Python stack:Core Technologies
- FastAPI - High-performance web framework with automatic API documentation
- Motor - Asynchronous MongoDB driver for Python
- Pydantic - Data validation and settings management using Python type annotations
- Python-JOSE - JWT token creation and verification
- Passlib - Secure password hashing with PBKDF2-SHA256
Database Structure
The API uses MongoDB with two main collections:- URLMap - Stores URL mappings with unique codes and passwords
- URLStats - Tracks hit counts, creation dates, and active states
Security Features
All management endpoints require JWT authentication. Passwords are hashed using PBKDF2-SHA256, never stored in plain text.
- Bearer token authentication for protected endpoints
- Password validation (3-20 characters)
- URL blacklist support to prevent malicious links
- Reserved keyword protection for url_code values
API Endpoints Overview
The API provides two categories of endpoints:Public Endpoints
POST /create- Create new short URLsPOST /login- Authenticate and receive access tokensGET /{url_code}- Redirect to destination URLGET /health- Database health check
Protected Endpoints (Require Authentication)
DELETE /delete- Delete a URLPATCH /pause- Temporarily disable a URLPATCH /resume- Re-enable a paused URLPATCH /change_url- Update the destination URLPATCH /reset_hits- Reset the hit counterPOST /change_password- Update URL passwordGET /details- Retrieve URL statisticsGET /validate_token- Verify token validityGET /refresh_token- Get a new access token
What Problems Does It Solve?
URL Management at Scale
URL Management at Scale
Unlike simple URL shorteners, Short-URL provides complete lifecycle management. You can update destinations, pause URLs temporarily, track usage, and delete URLs when no longer needed - all without losing your short codes.
Secure URL Sharing
Secure URL Sharing
Password protection ensures that only authorized users can access your shortened URLs. Combined with JWT authentication for management, your URLs are protected at both the access and administrative levels.
Usage Analytics
Usage Analytics
Built-in hit tracking lets you monitor how often your URLs are accessed. Perfect for marketing campaigns, content distribution, or understanding user engagement.
Flexible Deployment
Flexible Deployment
Built with FastAPI and async MongoDB, the API can handle high-traffic scenarios with horizontal scaling. CORS support enables integration with any frontend application.
Getting Started
Quickstart Guide
Get up and running in 5 minutes with our step-by-step guide
Installation
Detailed installation instructions and environment setup
API Reference
Complete API endpoint documentation with examples
Authentication
Learn how to authenticate and manage access tokens
Interactive Documentation
Once you have the server running, FastAPI provides automatic interactive documentation:- Swagger UI - Available at
/docs - ReDoc - Available at
/redoc