π£οΈ API Routes Reference - Main System Integration β
π Overview β
Complete reference of all Partner Services API routes that the main system needs to use. This guide provides a quick-scan format for developers to understand what APIs are available and their current implementation status.
Base URL: http://localhost:3000/api/v1
Authentication: HMAC SHA-256 (see Authentication Guide)
Current Status: 100% Implemented | All Critical APIs Operational
π₯ System Health & Information β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /health | Enhanced system health check with components | β Active | π΄ Critical |
GET | /health/ready | Kubernetes readiness probe | β Active | π΄ Critical |
GET | /health/live | Kubernetes liveness probe | β Active | π΄ Critical |
GET | /api/v1 | API version information | β Active | π‘ Medium |
π Geographical Data APIs β
Public Access (No Authentication) β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /api/v1/pincodes/states | Get states with pincode counts & search | β Active | π‘ Medium |
Service-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /api/v1/cities | Cities with comprehensive filtering | β Active | π΄ Critical |
GET | /api/v1/areas | Areas with city/state filtering | β Active | π΄ Critical |
GET | /api/v1/pincodes/search | Advanced pincode search with filters | β Active | π΄ Critical |
GET | /api/v1/pincodes/:pincode | Specific pincode details with hierarchy | β Active | π΄ Critical |
GET | /api/v1/pincodes/:pincode/hierarchy | Complete geographical hierarchy for pincode | β Active | π‘ Medium |
Cache Fixes Applied:
- β Cache key generation for array parameters
- β Proper filtering now returns correct results
- β Response times: 6-17ms for geographical queries
- β Cache invalidation properly handles state/city filters
πΊοΈ Zone Management APIs β
Service-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /api/v1/zones | Get all zones (main system access) | β Active | π΄ Critical |
POST | /api/v1/zones | Create new zone | β Active | π΄ Critical |
π§ Service Type Management β
Service-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /api/v1/service-types | Get all service types | β Active | π΄ Critical |
POST | /api/v1/service-types | Create new service type | β Active | π΄ Critical |
π¦ Package Management APIs β
Service-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /api/v1/packages/charges | Get package charges with filtering | β Active | π΄ Critical |
POST | /api/v1/packages/charges | Create new package charge | β Active | π΄ Critical |
POST | /api/v1/packages/charges/bulk | Create multiple package charges | β Active | π‘ Medium |
π° Customer Charge Management APIs β
Service-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /api/v1/customer-charges | Get customer charge configurations | β Active | π΄ Critical |
POST | /api/v1/customer-charges | Create new customer charge | β Active | π΄ Critical |
POST | /api/v1/customer-charges/bulk | Create multiple customer charges | β Active | π‘ Medium |
Enhancements:
- β Added partner-specific charge filtering
- β Enhanced charge type categorization (FSC, COD, Insurance)
- β Improved response with summary statistics
π― Discount Management APIs β
Service-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /api/v1/discounts | Get discount configurations with filtering | β Active | π΄ Critical |
POST | /api/v1/discounts | Create new discount configuration | β Active | π΄ Critical |
PUT | /api/v1/discounts/:id | Update existing discount | β Active | π‘ Medium |
DELETE | /api/v1/discounts/:id | Delete discount | β Active | π‘ Medium |
POST | /api/v1/discounts/bulk | Create multiple discounts | β Active | π‘ Medium |
Fixes Applied:
- β Partner-specific discount filtering
- β Added weight range validation to prevent overlaps
- β Enhanced validity period checking
- β Added comprehensive discount analytics
π₯ Partner Data Retrieval APIs β
Service-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /api/v1/partners/comprehensive-data | Get complete partner data | β Active | π΄ Critical |
GET | /api/v1/partner-packages/:partnerId | Get packages for partner | β Active | π΄ Critical |
Partner-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
GET | /api/v1/partner-charges/:partnerId | Get charges for specific partner | β Active | π΄ Critical |
GET | /api/v1/partner-discounts/:partnerId | Get discounts for specific partner | β Active | π΄ Critical |
GET | /api/v1/partner-services/:partnerId | Get services for specific partner | β Active | π΄ Critical |
GET | /api/v1/partner-zones/:partnerId | Get partner zones | β Active | π΄ Critical |
π° Charge Calculation APIs β
Partner-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
POST | /api/v1/surcharge-calculation/:partnerId/calculate | Comprehensive charge calculation | β Active | π΄ Critical |
Service-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
POST | /api/v1/shipments/calculate-charges | Shipment charge calculation | β Active | π΄ Critical |
π Partner Availability & Assignment APIs β
Service-Level Authentication Required β
Method | Route | Description | Status | Priority |
---|---|---|---|---|
POST | /api/v1/partners/availability/check | Check partner availability | β Active | π΄ Critical |
POST | /api/v1/shipment-assignment/assign | Assign shipment to partner | β Active | π΄ Critical |
π Quick Testing Examples β
Health Check β
bash
curl -X GET "http://localhost:3000/health"
States Data (Public) β
bash
curl -X GET "http://localhost:3000/api/v1/pincodes/states?search=Maharashtra&limit=10"
Cities Search (Service Auth) β
bash
curl -X GET "http://localhost:3000/api/v1/cities?stateIds=1,2&includeState=true&limit=20" \
-H "x-service-id: TESTING_1" \
-H "x-timestamp: $(date +%s)" \
-H "x-signature: your_service_signature"
Partner Data (Service Auth) β
bash
curl -X GET "http://localhost:3000/api/v1/partners/comprehensive-data?partnerId=partner_001" \
-H "x-service-id: TESTING_1" \
-H "x-timestamp: $(date +%s)" \
-H "x-signature: your_service_signature"
Charge Calculation (Service Auth) β
bash
curl -X POST "http://localhost:3000/api/v1/shipments/calculate-charges" \
-H "Content-Type: application/json" \
-H "x-service-id: TESTING_1" \
-H "x-timestamp: $(date +%s)" \
-H "x-signature: your_service_signature" \
-d '{
"partnerId": "partner_001",
"pickupPincode": "110001",
"deliveryPincode": "400001",
"weight": 2500,
"shipmentType": "B2C",
"paymentType": "COD",
"declaredValue": 3500
}'
Partner Availability Check (Service Auth) β
bash
curl -X POST "http://localhost:3000/api/v1/partners/availability/check" \
-H "Content-Type: application/json" \
-H "x-service-id: TESTING_1" \
-H "x-timestamp: $(date +%s)" \
-H "x-signature: your_service_signature" \
-d '{
"pickupPincode": "110001",
"deliveryPincode": "400001",
"weight": 2500,
"shipmentType": "B2C",
"paymentType": "COD",
"serviceRequirements": ["PICKUP", "DELIVERY", "COD"]
}'
Shipment Assignment (Service Auth) β
bash
curl -X POST "http://localhost:3000/api/v1/shipment-assignment/assign" \
-H "Content-Type: application/json" \
-H "x-service-id: TESTING_1" \
-H "x-timestamp: $(date +%s)" \
-H "x-signature: your_service_signature" \
-d '{
"shipmentDetails": {
"shipmentId": "SH_1721123456789",
"fromPincode": "110001",
"toPincode": "400001",
"weight": 2500,
"shipmentType": "B2C",
"paymentType": "COD",
"serviceTypes": ["PICKUP", "DELIVERY", "EXPRESS", "COD"]
},
"assignmentPreferences": {
"assignmentStrategy": "BEST_MATCH"
}
}'
β‘ Key Integration Points β
For Main System Integration: β
- Geographical APIs - Use
/cities
,/areas
,/pincodes/search
for location services - Partner Data - Use
/partners/comprehensive-data
for complete partner information - Availability Check - Use
/partners/availability/check
before assignment - Charge Calculation - Use service-level
/shipments/calculate-charges
for estimates - Assignment - Use
/shipment-assignment/assign
for final partner assignment
For Partner Integration: β
- Zone Data - Use
/partner-zones/:partnerId
for coverage information - Charges - Use
/partner-charges/:partnerId
for all charge configurations - Services - Use
/partner-services/:partnerId
for available services - Calculation - Use
/surcharge-calculation/:partnerId/calculate
for precise pricing
π Authentication Summary β
Service-Level (x-service-id) β
- All main system APIs
- Zone management
- Service types
- Partner comprehensive data β Active
- Availability checks
- Shipment assignments
- Charge calculations β Active
Partner-Level (x-partner-id) β
- Partner-specific data retrieval
- Partner charge calculations
- Partner zone access
Public (No Auth) β
- Basic health checks
- State listings
π·οΈ Recent Fixes & Enhancements (July 24, 2025) β
Critical Fixes Applied: β
π§ Cache System
- Cities and Areas APIs now return correct filtered results
- Cache key generation for array parameters
- Improved performance: 6-17ms response times
π Authentication
- Service-level auth now works for partner comprehensive data
- Partner packages endpoint accepts service authentication
- Better error messages for missing authentication
βοΈ Business Logic
- Partner availability check supports "find all available partners"
- Shipment assignment accepts hyphens/underscores in IDs
- PICKUP and DELIVERY services are now mandatory
π Middleware
- Charge calculation middleware order corrected
- Authentication now works properly for all endpoints
Performance Improvements: β
- Response Times: 6-17ms for geographical APIs, 145-567ms for complex calculations
- Cache Efficiency: Proper key generation prevents cache collisions
- Error Handling: Enhanced with specific error codes and suggestions
Breaking Changes: β
None - All changes are backward compatible
π Related Documentation β
- Complete API Reference - Full endpoint specifications with examples
- Quick Start Guide - 15-minute setup
- Authentication Guide - HMAC implementation
- Main System Flow - Complete workflows
π― Integration Checklist β
Before Integration: β
- [ ] Review authentication setup (HMAC SHA-256)
- [ ] Test health endpoints for connectivity
- [ ] Verify service credentials and signatures
Core Integration Steps: β
- [ ] Implement geographical data fetching (cities/areas with cache support)
- [ ] Setup partner data retrieval (comprehensive-data API)
- [ ] Integrate availability checking (with "find all available" support)
- [ ] Implement charge calculation (with proper authentication)
- [ ] Setup shipment assignment
Post-Integration Testing: β
- [ ] Test cache performance on geographical APIs
- [ ] Verify all authentication flows work correctly
- [ ] Test error handling for edge cases
- [ ] Validate assignment flow with different service requirements
Quick reference for Partner Services API routes. For detailed specifications, see Complete API Reference. All critical fixes applied - July 24, 2025