Rate Calculator
The Rate Calculator API allows you to compute shipping charges based on origin/destination pincodes, weight, dimensions, journey type, and payment mode.
This guide explains how to initialize the EShopBox SDK and use the
rate_calculator interface.
Example: Setup Rate Calculator Using EShopBox SDK
The following code demonstrates how to authenticate with EShopBox and calculate rates:
"""
Example: Setup Rate Calculator using EShopBox SDK
"""
import os
from eshopbox.client import EShopBoxSDK
from dotenv import load_dotenv
load_dotenv()
def rate_calculator(sdk):
payload = {
"journeyType": "forward",
"pickupPincode": "160071",
"dropPincode": "247342",
"orderWeight": "500",
"length": "12",
"width": "12",
"height": "33",
"paymentMethod": "Prepaid",
"doorstepQc": False
}
response = sdk.rate_calculator.calculate(payload)
print("Response: ", response)
def main():
sdk = EShopBoxSDK(
workspace=os.getenv('ESHOPBOX_WORKSPACE', ''),
client_id=os.getenv('ESHOPBOX_CLIENT_ID', ''),
client_secret=os.getenv('ESHOPBOX_SECRET_ID', ''),
refresh_token=os.getenv('ESHOPBOX_REFRESH_TOKEN', '')
)
rate_calculator(sdk)
if __name__ == "__main__":
main()
Parameters
The rate_calculator.calculate(payload) method accepts the following fields:
Response Format
A successful API response typically returns shipping charges and service details.
Example response:
{
"data": {
"total_charges": 120.5,
"carrier": "Delhivery",
"service_type": "Surface",
"estimated_delivery_days": 4
}
}
Notes
Ensure your environment variables include:
ESHOPBOX_WORKSPACEESHOPBOX_CLIENT_IDESHOPBOX_SECRET_IDESHOPBOX_REFRESH_TOKEN
The rate returned depends on carrier availability, weight slabs, and payment method.
Pincodes must be valid and serviceable for the journey type.