Path: [GET] /api/v1/shipping/rates

Description: Retrieves available shipping rates based on origin, destination, and weight. Requires Bearer token authentication.

Authentication:

Request Parameters:

Parameter Type Required Location Description
origin String Required Query The origin address or postal code.
destination String Required Query The destination address or postal code.
weight Number Required Query The weight of the package in kilograms.

Example Request:

curl --location 'localhost/api/v1/shipping/rates?origin=Jakarta&destination=Bandung&weight=2.5' \\
--header 'Authorization: Bearer your_token_here'

Response Parameters:

Name Type Demo Value Description
status String success Response status indicating success.
rates Array List of available shipping rates.
— service String Standard Shipping Name of the shipping service.
— price Number 10.50 Cost of the shipping service.
— estimated_delivery String 3-5 business days Estimated delivery time.
— calculated_rate Number 30000 calculated shipping cost

Success Response Example:

{
    "status": "success",
    "rates": [
        {
            "origin": "Jakarta",
						"destination": "Bandung",
						"service": "express",
						"rate": 20000,
						"calculatedRate": 30000,
						"estimated_delivery": "1-2 business days"
        },
        {
            "origin": "Jakarta",
						"destination": "Bandung",
						"service": "standard",
						"rate": 10000,
						"calculatedRate": 15000,
						"estimated_delivery": "3-5 business days"
        }
    ]
}


Error Response Examples:

  1. Missing Parameters:

    {
        "status": "error",
        "message": "Missing required parameters: origin, destination, weight."
    }
    
  2. Invalid Authentication:

    {
        "status": "error",
        "message": "Invalid or expired token."
    }