body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
line-height: 1.6;
color: #333;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.calculator-container {
background-color: #f9f9f9;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 30px;
margin-bottom: 40px;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.calc-header {
text-align: center;
margin-bottom: 25px;
}
.calc-header h2 {
color: #4d148c; /* FedEx Purple-ish */
margin: 0;
}
.calc-header p {
color: #666;
font-size: 0.9em;
}
.input-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
@media (max-width: 768px) {
.input-grid {
grid-template-columns: 1fr;
}
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: 600;
font-size: 0.9rem;
}
.form-group input, .form-group select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
box-sizing: border-box;
}
.dims-group {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 10px;
}
.btn-calc {
background-color: #ff6200; /* FedEx Orange-ish */
color: white;
border: none;
padding: 15px 30px;
font-size: 18px;
font-weight: bold;
border-radius: 4px;
cursor: pointer;
width: 100%;
margin-top: 10px;
transition: background-color 0.3s;
}
.btn-calc:hover {
background-color: #e05600;
}
.results-area {
margin-top: 30px;
padding: 20px;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
display: none;
}
.result-row {
display: flex;
justify-content: space-between;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.result-row:last-child {
border-bottom: none;
font-weight: bold;
font-size: 1.2em;
color: #4d148c;
}
.dim-note {
font-size: 0.85em;
color: #666;
margin-top: 5px;
font-style: italic;
}
.article-content {
background: #fff;
padding: 20px;
}
.article-content h2 {
color: #333;
margin-top: 30px;
}
.article-content h3 {
color: #4d148c;
}
.api-code-block {
background: #2d2d2d;
color: #ccc;
padding: 15px;
border-radius: 5px;
font-family: monospace;
overflow-x: auto;
margin: 20px 0;
}
function calculateShippingRate() {
// 1. Get Inputs
var weightInput = document.getElementById('actualWeight').value;
var length = document.getElementById('pkgLength').value;
var width = document.getElementById('pkgWidth').value;
var height = document.getElementById('pkgHeight').value;
var zone = document.getElementById('destinationZone').value;
var service = document.getElementById('serviceType').value;
// 2. Validate
if (!weightInput || !length || !width || !height) {
alert("Please enter valid weight and dimensions.");
return;
}
var actualWeight = parseFloat(weightInput);
var l = parseFloat(length);
var w = parseFloat(width);
var h = parseFloat(height);
var z = parseInt(zone);
if (isNaN(actualWeight) || isNaN(l) || isNaN(w) || isNaN(h)) {
alert("Inputs must be numbers.");
return;
}
// 3. Logic: Calculate Dimensional Weight
// FedEx standard divisor is usually 139 for commercial/retail
var dimWeightCalc = (l * w * h) / 139;
var dimWeight = Math.ceil(dimWeightCalc); // Round up to next lb
var roundedActual = Math.ceil(actualWeight); // Carriers usually bill by rounded lb
// 4. Determine Billable Weight
var billableWeight = Math.max(roundedActual, dimWeight);
// 5. Simulate Pricing Logic (This is a simplified simulation, not real-time API data)
// Base cost per lb increases by zone
// Formula: Base + (Weight * CostPerLb * ZoneMultiplier)
var baseStartPrice = 10.00; // Base handling fee
var zoneRatePerLb = 0;
// Approximate zone curves
switch(z) {
case 2: zoneRatePerLb = 0.95; break;
case 3: zoneRatePerLb = 1.15; break;
case 4: zoneRatePerLb = 1.45; break;
case 5: zoneRatePerLb = 1.85; break;
case 6: zoneRatePerLb = 2.45; break;
case 7: zoneRatePerLb = 3.10; break;
case 8: zoneRatePerLb = 3.95; break;
default: zoneRatePerLb = 1.00;
}
var estimatedBase = baseStartPrice + (billableWeight * zoneRatePerLb);
// 6. Apply Service Multipliers
var serviceMultiplier = 1.0;
var serviceName = "";
switch(service) {
case 'ground':
serviceMultiplier = 1.0;
serviceName = "Ground (1.0x)";
break;
case 'express_saver':
serviceMultiplier = 1.8;
serviceName = "Express Saver (1.8x)";
break;
case '2day':
serviceMultiplier = 2.4;
serviceName = "2Day (2.4x)";
break;
case 'standard_overnight':
serviceMultiplier = 3.2;
serviceName = "Std Overnight (3.2x)";
break;
case 'priority_overnight':
serviceMultiplier = 3.8;
serviceName = "Pri Overnight (3.8x)";
break;
}
var subTotal = estimatedBase * serviceMultiplier;
// 7. Fuel Surcharge
var fuelRate = 0.15; // 15% simulation
var fuelSurcharge = subTotal * fuelRate;
var finalTotal = subTotal + fuelSurcharge;
// 8. Output Results
document.getElementById('resDimWeight').innerText = dimWeight + " lbs";
document.getElementById('resBillableWeight').innerText = billableWeight + " lbs";
document.getElementById('resBaseRate').innerText = "$" + subTotal.toFixed(2);
document.getElementById('resServiceType').innerText = serviceName;
document.getElementById('resFuel').innerText = "$" + fuelSurcharge.toFixed(2);
document.getElementById('resTotal').innerText = "$" + finalTotal.toFixed(2);
document.getElementById('resultDisplay').style.display = "block";
}
Understanding the FedEx Shipping Rate Calculator API
Integrating shipping capabilities into e-commerce platforms requires a robust understanding of how carriers calculate costs. The FedEx Shipping Rate Calculator API is the bridge between your online store and FedEx's complex pricing engine. This guide explains how the API determines rates using Billable Weight logic, ensuring you don't undercharge your customers for shipping.
How the Calculation Logic Works
Unlike simple flat-rate systems, the FedEx API utilizes a dynamic pricing model based on three primary factors. The simulator above replicates this logic to help developers and logistics managers predict costs.
1. Dimensional (Volumetric) Weight
Space is as valuable as weight in logistics. FedEx calculates the "Dimensional Weight" of a package to account for lightweight but bulky items (like pillows or large plastic parts). The standard formula used in the API is:
Dim Weight = (Length x Width x Height) / 139
If the Dimensional Weight is higher than the actual scale weight, the API will use the Dimensional Weight as the Billable Weight. This is why inputting accurate dimensions into your API requests is critical.
2. Zone-Based Pricing
Distance is measured in "Zones" ranging from Zone 2 (local/regional) to Zone 8 (cross-country). The API calculates the distance between the Origin Zip Code and the Destination Zip Code to assign a zone. As the Zone number increases, the base rate per pound increases significantly.
3. Service Type and Surcharges
The raw API response includes a base rate which is then adjusted by:
- Service Level: Ground is the baseline. Express Saver, 2Day, and Overnight services apply multipliers to the base cost.
- Fuel Surcharges: A fluctuating percentage added to the base rate, updated weekly by FedEx.
- Residential Delivery Fees: Delivering to a home often incurs a higher fee than delivering to a commercial address.
Integrating the FedEx Rate API
When building a custom checkout experience, you will typically interact with the FedEx "Rate Services" endpoint. Here is a conceptual overview of the JSON payload structure required to get an accurate rate:
{
"accountNumber": {
"value": "YOUR_ACCOUNT_NUMBER"
},
"requestedShipment": {
"shipper": { "address": { "postalCode": "90210", "countryCode": "US" } },
"recipient": { "address": { "postalCode": "10001", "countryCode": "US" } },
"pickupType": "USE_SCHEDULED_PICKUP",
"serviceType": "FEDEX_GROUND",
"packagingType": "YOUR_PACKAGING",
"requestedPackageLineItems": [
{
"weight": { "units": "LB", "value": 10.0 },
"dimensions": { "length": 12, "width": 12, "height": 12, "units": "IN" }
}
]
}
}
Common API Integration Pitfalls
Ignoring Dimensions: Many developers only pass weight to the API. If the package is large, the API will return a rate based on weight, but the final invoice from FedEx will be much higher due to dimensional weight adjustments. Always pass requestedPackageLineItems.dimensions.
Address Validation: Rates differ for commercial vs. residential addresses. Use the FedEx Address Validation API before calling the Rate API to ensure the residential flag is set correctly.
Frequently Asked Questions
What is the divisor for FedEx Dimensional Weight?
Currently, the standard divisor for domestic and international shipments is 139. This means you multiply L x W x H in inches and divide by 139. The result is rounded up to the nearest pound.
Why does the API return a different rate than my invoice?
The API provides an estimated rate. Final invoices may include additional surcharges such as Additional Handling (for heavy/long packages), Oversize charges, or address correction fees that were not detected at the time of the API call.
Does the FedEx API support negotiated rates?
Yes. If you authenticate with your specific Account Number and Meter Number, the API response will return your specific contract rates (negotiated rates) alongside the standard list rates.