Skip to content

πŸ›£οΈ 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 ​

MethodRouteDescriptionStatusPriority
GET/healthEnhanced system health check with componentsβœ… ActiveπŸ”΄ Critical
GET/health/readyKubernetes readiness probeβœ… ActiveπŸ”΄ Critical
GET/health/liveKubernetes liveness probeβœ… ActiveπŸ”΄ Critical
GET/api/v1API version informationβœ… Active🟑 Medium

🌍 Geographical Data APIs ​

Public Access (No Authentication) ​

MethodRouteDescriptionStatusPriority
GET/api/v1/pincodes/statesGet states with pincode counts & searchβœ… Active🟑 Medium

Service-Level Authentication Required ​

MethodRouteDescriptionStatusPriority
GET/api/v1/citiesCities with comprehensive filteringβœ… ActiveπŸ”΄ Critical
GET/api/v1/areasAreas with city/state filteringβœ… ActiveπŸ”΄ Critical
GET/api/v1/pincodes/searchAdvanced pincode search with filtersβœ… ActiveπŸ”΄ Critical
GET/api/v1/pincodes/:pincodeSpecific pincode details with hierarchyβœ… ActiveπŸ”΄ Critical
GET/api/v1/pincodes/:pincode/hierarchyComplete 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 ​

MethodRouteDescriptionStatusPriority
GET/api/v1/zonesGet all zones (main system access)βœ… ActiveπŸ”΄ Critical
POST/api/v1/zonesCreate new zoneβœ… ActiveπŸ”΄ Critical

πŸ”§ Service Type Management ​

Service-Level Authentication Required ​

MethodRouteDescriptionStatusPriority
GET/api/v1/service-typesGet all service typesβœ… ActiveπŸ”΄ Critical
POST/api/v1/service-typesCreate new service typeβœ… ActiveπŸ”΄ Critical

πŸ“¦ Package Management APIs ​

Service-Level Authentication Required ​

MethodRouteDescriptionStatusPriority
GET/api/v1/packages/chargesGet package charges with filteringβœ… ActiveπŸ”΄ Critical
POST/api/v1/packages/chargesCreate new package chargeβœ… ActiveπŸ”΄ Critical
POST/api/v1/packages/charges/bulkCreate multiple package chargesβœ… Active🟑 Medium

πŸ’° Customer Charge Management APIs ​

Service-Level Authentication Required ​

MethodRouteDescriptionStatusPriority
GET/api/v1/customer-chargesGet customer charge configurationsβœ… ActiveπŸ”΄ Critical
POST/api/v1/customer-chargesCreate new customer chargeβœ… ActiveπŸ”΄ Critical
POST/api/v1/customer-charges/bulkCreate 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 ​

MethodRouteDescriptionStatusPriority
GET/api/v1/discountsGet discount configurations with filteringβœ… ActiveπŸ”΄ Critical
POST/api/v1/discountsCreate new discount configurationβœ… ActiveπŸ”΄ Critical
PUT/api/v1/discounts/:idUpdate existing discountβœ… Active🟑 Medium
DELETE/api/v1/discounts/:idDelete discountβœ… Active🟑 Medium
POST/api/v1/discounts/bulkCreate 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 ​

MethodRouteDescriptionStatusPriority
GET/api/v1/partners/comprehensive-dataGet complete partner dataβœ… ActiveπŸ”΄ Critical
GET/api/v1/partner-packages/:partnerIdGet packages for partnerβœ… ActiveπŸ”΄ Critical

Partner-Level Authentication Required ​

MethodRouteDescriptionStatusPriority
GET/api/v1/partner-charges/:partnerIdGet charges for specific partnerβœ… ActiveπŸ”΄ Critical
GET/api/v1/partner-discounts/:partnerIdGet discounts for specific partnerβœ… ActiveπŸ”΄ Critical
GET/api/v1/partner-services/:partnerIdGet services for specific partnerβœ… ActiveπŸ”΄ Critical
GET/api/v1/partner-zones/:partnerIdGet partner zonesβœ… ActiveπŸ”΄ Critical

πŸ’° Charge Calculation APIs ​

Partner-Level Authentication Required ​

MethodRouteDescriptionStatusPriority
POST/api/v1/surcharge-calculation/:partnerId/calculateComprehensive charge calculationβœ… ActiveπŸ”΄ Critical

Service-Level Authentication Required ​

MethodRouteDescriptionStatusPriority
POST/api/v1/shipments/calculate-chargesShipment charge calculationβœ… ActiveπŸ”΄ Critical

πŸš€ Partner Availability & Assignment APIs ​

Service-Level Authentication Required ​

MethodRouteDescriptionStatusPriority
POST/api/v1/partners/availability/checkCheck partner availabilityβœ… ActiveπŸ”΄ Critical
POST/api/v1/shipment-assignment/assignAssign 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: ​

  1. Geographical APIs - Use /cities, /areas, /pincodes/search for location services
  2. Partner Data - Use /partners/comprehensive-data for complete partner information
  3. Availability Check - Use /partners/availability/check before assignment
  4. Charge Calculation - Use service-level /shipments/calculate-charges for estimates
  5. Assignment - Use /shipment-assignment/assign for final partner assignment

For Partner Integration: ​

  1. Zone Data - Use /partner-zones/:partnerId for coverage information
  2. Charges - Use /partner-charges/:partnerId for all charge configurations
  3. Services - Use /partner-services/:partnerId for available services
  4. 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: ​

  1. πŸ”§ Cache System

    • Cities and Areas APIs now return correct filtered results
    • Cache key generation for array parameters
    • Improved performance: 6-17ms response times
  2. πŸ” Authentication

    • Service-level auth now works for partner comprehensive data
    • Partner packages endpoint accepts service authentication
    • Better error messages for missing authentication
  3. βš™οΈ Business Logic

    • Partner availability check supports "find all available partners"
    • Shipment assignment accepts hyphens/underscores in IDs
    • PICKUP and DELIVERY services are now mandatory
  4. πŸš€ 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



🎯 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

Released under the MIT License.