or just use swagger lol
- Overview
- Quick Start
- Authentication
- API Endpoints
- Data Models
- Admin Features
- Error Handling
- Development
LocaLe is a peer-to-peer marketplace where "Your Community is Your Credential". This API powers a trust-based local service platform where users can offer and book services within their community.
- JWT Authentication - Secure user authentication
- User Profiles - Comprehensive user management
- Service Marketplace - Create, browse, and manage services
- Service Categories - Organized service classification
- Trust System - Community-based verification and ratings
- Admin Panel - Full platform management capabilities
- Backend: FastAPI (Python)
- Database: PostgreSQL with SQLAlchemy ORM
- Authentication: JWT Bearer Tokens
- Documentation: Auto-generated OpenAPI/Swagger
http://127.0.0.1:8000
Visit the auto-generated Swagger UI at:
http://127.0.0.1:8000/docs
curl http://127.0.0.1:8000/healthLocaLe uses JWT Bearer Token authentication. Most endpoints require a valid token in the Authorization header.
- Register a new user account
- Login with phone and password
- Use the token in subsequent requests
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...- 30 minutes default expiration
- Automatic token refresh recommended
POST /users/Request Body:
{
"name": "Kosi okafor",
"email": "kosi@example.com",
"phone": "+1234567890",
"password": "securepassword123"
}POST /users/loginResponse:
{
"id": "user-uuid",
"name": "Kosi Okafor",
"phone": "+1234567890",
"access_token": "jwt-token-here",
"token_type": "bearer"
}GET /users/meRequires authentication
PUT /users/meRequest Body:
{
"name": "Updated Name",
"email": "newemail@example.com",
"avatar_url": "https://example.com/avatar.jpg"
}GET /users/{user_id}PUT /users/{user_id}DELETE /users/{user_id}GET /services/?skip=0&limit=100GET /services/{service_id}POST /services/Request Body:
{
"title": "Professional Plumbing",
"description": "Expert plumbing services for homes and offices",
"base_price": 75000.00,
"hourly_rate": 50000.00,
"service_radius_km": 25,
"current_location": "Ikate, Lekki",
"category_name": "Home-Services"
}PUT /services/{service_id}DELETE /services/{service_id}POST /services/{service_id}/activateGET /services/myReturns all services created by the current user
GET /services/seller/{seller_id}All admin endpoints require admin_key query parameter
POST /admin/categories/categories?name=CategoryName&description=Description&admin_key=your_admin_keyGET /admin/categories/categories?admin_key=your_admin_keyGET /admin/categories/users?skip=0&limit=100&admin_key=your_admin_key{
"id": "uuid-string",
"name": "Kosi King",
"email": "kosi@example.com",
"phone": "+1234567890", (I did not handle this lol, maybe FE would)
"avatar_url": "https://example.com/avatar.jpg",
"trust_score": 85,
"verification_level": 2,
"is_online": true,
"last_active": "2024-01-15T10:30:00Z"
}{
...UserBaseResponse,
"nin_verified": true,
"completion_count": 15,
"total_earnings": 2500.00,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}{
...UserBaseResponse,
"access_token": "jwt-token",
"token_type": "bearer"
}{
"id": "uuid-string",
"title": "Service Title",
"description": "Service description",
"base_price": "75.00",
"hourly_rate": "50.00",
"service_radius_km": 25,
"current_location": "New York, NY",
"is_available_now": true,
"status": "active",
"trust_points": 42,
"completion_count": 8,
"created_at": "2024-01-15T10:30:00Z"
}{
...ServiceBaseResponse,
"seller": { /* UserBaseResponse */ },
"categories": [
{
"id": "category-uuid",
"name": "Home-Services",
"description": "Home related services",
"icon_url": "https://example.com/icon.png"
}
],
"total_earnings": "600.00",
"updated_at": "2024-01-15T10:30:00Z"
}OpenAPI schema
- Complete API Specification - All endpoints, methods, parameters
- Request/Response Schemas - Exact data structures
- Authentication Flow - JWT token handling
- Error Handling - Standardized error responses
- Interactive Documentation - Live testing via Swagger UI
- User Registration/Login Flow
- Service Browsing & Search
- Service Creation & Management
- User Profile Management
- Admin Dashboard
Set ADMIN_KEY environment variable to enable admin features.
- โ Create and manage service categories
- โ View all user data (including private fields)
# Create categories
curl -X POST "http://127.0.0.1:8000/admin/categories/categories?name=Plumbing&description=Plumbing%20services&admin_key=your_key"
# View all users
curl -X GET "http://127.0.0.1:8000/admin/categories/users?admin_key=your_key"{
"detail": [
{
"loc": ["body", "phone"],
"msg": "field required",
"type": "value_error.missing"
}
]
}200- Success201- Created400- Bad Request (validation errors)401- Unauthorized (invalid/missing token)403- Forbidden (admin access denied)404- Not Found422- Unprocessable Entity (input validation failed)
# Clone and setup
git clone <repository>
cd LPnP
# Install dependencies
pip install -r requirements.txt
# Environment variables
cp .env.example .env
# Edit .env with your database and admin settings
# Run development server
uvicorn app.main:app --reloadDATABASE_URL=postgresql://user:pass@localhost:5432/locale_db
SECRET_KEY=your-jwt-secret-key
ADMIN_KEY=your-admin-access-keyThe API automatically creates necessary tables on startup using SQLAlchemy models.
- API Documentation:
http://127.0.0.1:8000/docs - OpenAPI Schema:
http://127.0.0.1:8000/openapi.json - Health Check:
http://127.0.0.1:8000/health