This document describes the API system and homeserver for license verification in UVDM (Ultimate Video Download Manager).
The UVDM API system consists of two main components:
- API Server (Homeserver) - A Flask-based server that handles license verification, activation, and management
- License Client - A Python module integrated into the UVDM application for communicating with the API server
- License Generation: Generate unique license keys with configurable expiration dates
- License Activation: Bind licenses to specific machines
- License Verification: Verify license validity and check expiration
- Offline Mode: Cache license validation for offline use (up to 7 days)
- Machine Binding: Prevent license sharing by binding to machine ID
- Feature Flags: Control which features are available for each license
# Basic usage
python api_server.py
# With custom configuration
export UVDM_API_PORT=8080
export UVDM_API_HOST=0.0.0.0
export UVDM_ADMIN_KEY=your_secure_key
python api_server.py
# Using the config file
source api_config.env
python api_server.py- URL:
/ - Method: GET
- Description: Get API information and available endpoints
- Response: JSON with API details
- URL:
/api/license/verify - Method: POST
- Body:
{ "license_key": "UVDM-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX", "machine_id": "optional_machine_id" } - Response:
{ "valid": true, "license_type": "standard", "expiry_date": "2025-10-19T00:00:00", "features": ["download", "upload", "playlist", "batch"] }
- URL:
/api/license/activate - Method: POST
- Body:
{ "license_key": "UVDM-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX", "machine_id": "machine_identifier" } - Response:
{ "success": true, "message": "License activated successfully", "license_type": "standard", "expiry_date": "2025-10-19T00:00:00" }
- URL:
/api/license/deactivate - Method: POST
- Body:
{ "license_key": "UVDM-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX", "machine_id": "optional_machine_id" } - Response:
{ "success": true, "message": "License deactivated successfully" }
- URL:
/api/license/status - Method: GET
- Description: Get statistics about all licenses
- Response:
{ "total_licenses": 10, "active_licenses": 7, "expired_licenses": 2 }
- URL:
/api/license/generate - Method: POST
- Body:
{ "admin_key": "your_admin_key", "license_type": "standard", "duration_days": 365, "features": ["download", "upload", "playlist", "batch"] } - Response:
{ "success": true, "license_key": "UVDM-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX", "license_type": "standard", "expiry_date": "2025-10-19T00:00:00", "features": ["download", "upload", "playlist", "batch"] }
from app.license_client import LicenseClient
# Initialize the client
client = LicenseClient(server_url='http://localhost:5000')
# Verify a license
result = client.verify_license('UVDM-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX')
if result['valid']:
print("License is valid!")
print(f"License type: {result['license_type']}")
print(f"Expires: {result['expiry_date']}")
else:
print(f"License verification failed: {result['error']}")
# Activate a license
result = client.activate_license('UVDM-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX')
if result['success']:
print("License activated successfully!")
# Check server status
if client.check_server_status():
print("Server is online")The license client automatically caches successful verifications for offline use. Cached licenses are valid for 7 days.
# Force offline mode
result = client.verify_license('UVDM-XXX...', offline_mode=True)
if result['valid'] and result.get('offline'):
print(f"Using cached license (age: {result['cache_age_days']} days)")The API server stores data in JSON files:
data/licenses.json- License informationdata/api_keys.json- API keys (future use)data/license_cache.json- Client-side license cache
- Change the default admin key in production (
UVDM_ADMIN_KEY) - Use HTTPS for production deployments
- Implement rate limiting to prevent abuse
- Regular backups of license data
- Machine ID hashing prevents exposure of system information
You can test the API using curl:
# Generate a license (requires admin key)
curl -X POST http://localhost:5000/api/license/generate \
-H "Content-Type: application/json" \
-d '{"admin_key": "admin123", "license_type": "standard", "duration_days": 365}'
# Verify a license
curl -X POST http://localhost:5000/api/license/verify \
-H "Content-Type: application/json" \
-d '{"license_key": "UVDM-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX", "machine_id": "test-machine"}'
# Activate a license
curl -X POST http://localhost:5000/api/license/activate \
-H "Content-Type: application/json" \
-d '{"license_key": "UVDM-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX", "machine_id": "test-machine"}'- User authentication and authorization
- License usage analytics
- Multi-tier licensing (free, premium, enterprise)
- Automated license renewal
- Web-based admin dashboard
- Payment integration
- Email notifications for expiring licenses
- Check if port 5000 is already in use
- Verify Python and Flask are installed correctly
- Check file permissions on data directory
- Ensure the API server is running
- Check network connectivity
- Verify the license key format
- Check server logs for errors
- Ensure license was verified online at least once
- Check cache file exists in
data/license_cache.json - Cache is valid for only 7 days
This API system is part of UVDM and follows the same MIT License.