Spaces:
Running
Running
Service Catalogue API - Quick Reference (SPA-MS)
Overview
Customer-facing API for listing and viewing service catalogue in SPA microservice.
Data Source: scm_service_catalogue (MongoDB)
Base Path: /customer/services
Authentication: Optional (depends on deployment)
Endpoints
1. List Services (with Projection Support)
POST /customer/services/list
Request Body:
{
"category": "Hair Services",
"status": "active",
"limit": 20,
"offset": 0,
"projection_list": ["service_id", "name", "price", "duration_mins"]
}
Response (with projection):
[
{
"service_id": "uuid",
"name": "Hair Cut",
"price": 500.00,
"duration_mins": 30
}
]
Response (without projection):
{
"services": [
{
"service_id": "uuid",
"merchant_id": "merchant_123",
"name": "Hair Cut",
"code": "SVC001",
"category": {
"id": "cat_hair",
"name": "Hair Services"
},
"description": "Professional hair cutting service",
"duration_mins": 30,
"price": 500.00,
"currency": "INR",
"gst_rate": 18.0,
"status": "active"
}
],
"pagination": {
"limit": 20,
"offset": 0,
"total": 15
}
}
Projection Fields:
service_id- Service UUIDmerchant_id- Merchant UUIDname- Service namecode- Service codecategory- Category objectdescription- Service descriptionduration_mins- Duration in minutesprice- Service pricecurrency- Currency codegst_rate- GST rate percentagestatus- Service status
2. Get Service by ID
GET /customer/services/{service_id}
Response: CustomerServiceResponse
3. Legacy GET List (Deprecated)
GET /customer/services?category=Hair%20Services&status=active&limit=20&offset=0
Note: Use POST /list instead for projection support.
Request Schema
ServiceListRequest
{
"category": "string (optional)",
"status": "active|inactive|archived (optional)",
"limit": 20,
"offset": 0,
"projection_list": ["field1", "field2"]
}
Response Schema
CustomerServiceResponse
{
"service_id": "uuid",
"merchant_id": "uuid",
"name": "Hair Cut",
"code": "SVC001",
"category": {
"id": "cat_123",
"name": "Hair Services"
},
"description": "Professional hair cutting service",
"duration_mins": 30,
"price": 500.00,
"currency": "INR",
"gst_rate": 18.0,
"status": "active"
}
Example Usage
List All Active Services
curl -X POST "http://localhost:8000/customer/services/list" \
-H "Content-Type: application/json" \
-d '{
"status": "active",
"limit": 20,
"offset": 0
}'
List Services by Category
curl -X POST "http://localhost:8000/customer/services/list" \
-H "Content-Type: application/json" \
-d '{
"category": "Hair Services",
"status": "active",
"limit": 20,
"offset": 0
}'
List Services with Projection (Performance Optimized)
curl -X POST "http://localhost:8000/customer/services/list" \
-H "Content-Type: application/json" \
-d '{
"category": "Hair Services",
"status": "active",
"limit": 20,
"offset": 0,
"projection_list": ["service_id", "name", "price", "duration_mins"]
}'
Get Service Details
curl -X GET "http://localhost:8000/customer/services/{service_id}"
Filters
category
Filter services by category name (case-insensitive).
Example:
{
"category": "Hair Services"
}
status
Filter services by status.
Valid Values: active, inactive, archived
Example:
{
"status": "active"
}
Pagination
Use limit and offset for pagination:
{
"limit": 20,
"offset": 0
}
Rules:
limit: 1-100 (default: 20)offset: >= 0 (default: 0)
Projection List Benefits
Using projection_list reduces payload size significantly:
Without Projection (Full Response):
{
"service_id": "uuid",
"merchant_id": "merchant_123",
"name": "Hair Cut",
"code": "SVC001",
"category": {"id": "cat_hair", "name": "Hair Services"},
"description": "Professional hair cutting service",
"duration_mins": 30,
"price": 500.00,
"currency": "INR",
"gst_rate": 18.0,
"status": "active"
}
With Projection (Minimal Response):
{
"service_id": "uuid",
"name": "Hair Cut",
"price": 500.00,
"duration_mins": 30
}
Payload Reduction: ~70% smaller
Error Responses
404 Not Found
{
"detail": "Service with ID 'xyz' not found"
}
422 Validation Error
{
"detail": [
{
"loc": ["body", "status"],
"msg": "Status must be one of: active, inactive, archived",
"type": "value_error"
}
]
}
500 Internal Server Error
{
"detail": "Failed to list services"
}
Integration with Client Apps
Mobile App Example (React Native)
// List services with projection
const response = await fetch('http://api.example.com/customer/services/list', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
category: 'Hair Services',
status: 'active',
limit: 20,
offset: 0,
projection_list: ['service_id', 'name', 'price', 'duration_mins']
})
});
const services = await response.json();
Web App Example (JavaScript)
// Get service details
const response = await fetch(`http://api.example.com/customer/services/${serviceId}`);
const service = await response.json();
Performance Tips
- Use Projection: Always use
projection_listto request only needed fields - Pagination: Use appropriate
limitvalues (20-50 recommended) - Caching: Cache service lists on client side with TTL
- Filters: Apply filters server-side rather than client-side filtering
Data Flow
Client App
β
SPA-MS (/customer/services/list)
β
MongoDB (scm_service_catalogue collection)
β
Transform to customer-safe format
β
Apply projection (if requested)
β
Return to client
Notes
- All services are read from
scm_service_catalogueMongoDB collection - No authentication required (configure as needed)
- Customer-safe data only (no internal audit fields exposed)
- Projection support for performance optimization
- Follows API List Endpoint Standard
- Compatible with mobile and web client apps