Rate shopping with carriers
What is rate shopping?
Rates are the cost and service levels associated with a shipment. When you want to find the best cost and service level for a shipment, you can request rates from a number of different carriers in a single call. You can then compare the results to find the option that works best for your shipment. This practice is known as rate shopping. When you create a Shipment object, rates are automatically generated for all carriers connected with your account. This can lead to a large number of rates returned for a shipment.
Follow this guide to learn how to rate shop for a specific subset of your available carriers.
Rate shopping for specific carriers
Capture carrier object ID
Capture the necessary carrier account object IDs. In this example, 6aa34d5f6865448fbb1ee93636e98999
and 7bb1235sdsd9sds6989845497874879
.
curl https://api.goshippo.com/carrier_accounts \
-H "Authorization: ShippoToken shippo_test_3a47d23c032ca626fce863c48d0f93d63a394396"
The expected response will look like this.
{
"next": "baseurl?page=3&results=10",
"previous": "baseurl?page=1&results=10",
"results": [
{
"account_id": "****",
"active": true,
"carrier": "UPS",
"parameters": {
"account_number": "94567e",
….
},
"is_shippo_account": false,
"metadata": "string",
"object_id": "6aa34d5f6865448fbb1ee93636e98999",
"object_owner": "bob+22@gmail.com",
"test": false
},
{
"account_id": "****",
"active": true,
"carrier": "USPS",
"parameters": {
"account_number": "9090a",
….
},
"is_shippo_account": false,
"metadata": "string",
"object_id": "7bb1235sdsd9sds6989845497874879",
"object_owner": "bob+22@gmail.com",
"test": false
}
]
}
Get rates
To get rates for specific carriers, create a Shipment and specify the carriers to be used using carrier_accounts
field in the /shipments
POST request to get rates as you usually would.
curl https://api.goshippo.com/shipments/ \
-H "Authorization: ShippoToken shippo_test_3a47d23c032ca626fce863c48d0f93d63a394396" \
-H "Content-Type: application/json" \
-d '{
"address_to": {
"name": "Mr Hippo",
"street1": "965 Mission St #572",
"city": "San Francisco",
"state": "CA",
"zip": "94103",
"country": "US",
"phone": "4151234567",
"email": "mrhippo@shippo.com"
},
"address_from": {
"name": "Mrs Hippo",
"street1": "1092 Indian Summer Ct",
"city": "San Jose",
"state": "CA",
"zip": "95122",
"country": "US",
"phone": "4159876543",
"email": "mrshippo@shippo.com"
},
"parcels": [{
"length": "10",
"width": "15",
"height": "10",
"distance_unit": "in",
"weight": "1",
"mass_unit": "lb"
}],
"async": false,
"carrier_accounts": [
"6aa34d5f6865448fbb1ee93636e98999",
"7bb1235sdsd9sds6989845497874879",
...
]
}'
The expected response will include a list of Rates generated from only the carriers specified in carrier_accounts
array.