
E-Commerce Shipping Integration: USPS, FedEx and UPS
Shipping cost is the leading cause of cart abandonment in US e-commerce. Industry research consistently shows that unexpected or high shipping costs at checkout are responsible for 40-60% of cart abandonments in mid-ticket categories. The solution is not just offering free shipping — it is building a shipping layer that provides accurate rates upfront, labels automatically, and communicates tracking clearly.
Efficient e-commerce logistics has three pillars: accurate rate quoting at the right moment, automated label generation without manual work, and transparent tracking for the customer. Each pillar has a specific technical layer that needs to work in an integrated way.
EasyPost: Multi-Carrier with a Single API
Integrating each carrier directly is a decision that will cost heavily in maintenance. USPS, FedEx, UPS, and DHL each have their own API quirks, undocumented breaking changes, and different rate limits. For most e-commerce stores, the correct approach is using a shipping aggregator that abstracts these differences.
EasyPost is one of the most popular aggregators in the US market. It connects USPS, FedEx, UPS, DHL, and over 100 regional carriers through a single clean API.
import EasyPost from '@easypost/api';
const easypost = new EasyPost(process.env.EASYPOST_API_KEY!);
interface ShipmentParams {
fromPostalCode: string;
toPostalCode: string;
weightOz: number;
lengthIn: number;
widthIn: number;
heightIn: number;
}
async function getRates(params: ShipmentParams) {
const shipment = await easypost.Shipment.create({
from_address: {
zip: params.fromPostalCode,
country: 'US',
},
to_address: {
zip: params.toPostalCode,
country: 'US',
},
parcel: {
weight: params.weightOz,
length: params.lengthIn,
width: params.widthIn,
height: params.heightIn,
},
});
return shipment.rates
.filter(rate => !rate.list_rate || parseFloat(rate.rate) < parseFloat(rate.list_rate))
.map(rate => ({
rateId: rate.id,
carrier: rate.carrier,
service: rate.service,
priceCents: Math.round(parseFloat(rate.rate) * 100),
deliveryDays: rate.delivery_days,
deliveryDate: rate.delivery_date,
}))
.sort((a, b) => a.priceCents - b.priceCents);
}
async function buyLabel(shipmentId: string, rateId: string): Promise<string> {
const shipment = await easypost.Shipment.buy(shipmentId, rateId);
return shipment.postage_label.label_url;
}
ShipStation is an alternative to EasyPost that additionally provides an order management layer — useful for merchants who need batch label printing and shipping workflow management beyond just the API.
USPS: The National Carrier
USPS is essential for US e-commerce, especially for small packages and last-mile delivery in rural areas. USPS Web Tools API provides rate calculation and tracking, but the modern approach is to use USPS via EasyPost or ShipStation — the direct USPS API is SOAP-based and more difficult to maintain.
USPS key services for e-commerce:
- Priority Mail (1-3 days): Most popular for packages 1-70 lbs
- Priority Mail Express (1-2 days guaranteed): Premium overnight
- Ground Advantage (2-5 days): Cost-effective for heavier packages
- First-Class Package (2-5 days): Cheapest option for packages under 15.99 oz
USPS Cubic pricing is a significant opportunity for dense, small packages — the rate is based on the package dimensions rather than weight, which can dramatically reduce costs for high-density products like jewelry or electronics components.
FedEx and UPS: Speed and Reliability
FedEx and UPS serve similar market segments but have different network strengths:
| Carrier | Strengths | Limitations |
|---|---|---|
| USPS | Cost-effective; last-mile everywhere | Slower tracking updates; size limits |
| FedEx | Speed reliability; strong B2B network | Higher list rates; complex discount structure |
| UPS | Wide coverage; ground network strength | Contract negotiation required for good rates |
| DHL | International shipping leader | Less competitive for domestic US |
Both FedEx and UPS offer REST APIs for rate shopping, label generation, and tracking. However, their list rates without negotiated contracts are significantly higher than USPS or regional carriers. Getting competitive rates requires either a high-volume direct contract or using an aggregator with pre-negotiated rates.
Automatic Label Generation
Manual label generation is impractical above 30-40 orders per day. The automated process works like this: upon payment confirmation, the system automatically generates the carrier label based on a routing rule (weight, destination ZIP, promised delivery time, cost) and makes the PDF available for printing in the picking area.
async function generateShippingLabel(order: Order): Promise<ShippingLabel> {
// 1. Get rates from all carriers
const rates = await getRates({
fromPostalCode: process.env.WAREHOUSE_ZIP!,
toPostalCode: order.shippingAddress.zipCode,
weightOz: order.totalWeightOz,
lengthIn: order.packageDimensions.length,
widthIn: order.packageDimensions.width,
heightIn: order.packageDimensions.height,
});
// 2. Select best rate based on business rules
const selectedRate = selectOptimalRate(rates, {
maxDeliveryDays: order.promisedDeliveryDays,
maxCostCents: order.shippingPaidCents * 1.1, // Allow 10% overage
preferCarriers: ['USPS', 'FedEx'], // Preferred carriers
});
// 3. Create the shipment and buy the label
const shipment = await easypost.Shipment.create({
from_address: { /* warehouse address */ },
to_address: {
name: order.shippingAddress.fullName,
street1: order.shippingAddress.line1,
street2: order.shippingAddress.line2,
city: order.shippingAddress.city,
state: order.shippingAddress.state,
zip: order.shippingAddress.zipCode,
country: 'US',
phone: order.customer.phone,
email: order.customer.email,
},
parcel: {
weight: order.totalWeightOz,
length: order.packageDimensions.length,
width: order.packageDimensions.width,
height: order.packageDimensions.height,
},
});
const boughtShipment = await easypost.Shipment.buy(shipment.id, selectedRate.rateId);
await db.orders.updateShipping(order.id, {
carrier: selectedRate.carrier,
trackingCode: boughtShipment.tracking_code,
labelUrl: boughtShipment.postage_label.label_url,
});
return {
trackingCode: boughtShipment.tracking_code,
labelUrl: boughtShipment.postage_label.label_url,
};
}
Unified Tracking and Proactive Notifications
Tracking is the most visible part of logistics for the customer — and also the most technically neglected. Customers check order status with more anxiety than any other stage. A poor tracking experience (link that goes to the carrier's site without context, status in technical jargon, no proactive notification) is a missed loyalty opportunity.
EasyPost's tracking API provides a unified event stream across all carriers:
// Webhook for tracking updates from EasyPost
app.post('/webhooks/easypost/tracking', async (req, res) => {
const event = req.body;
if (event.object === 'Event' && event.description === 'tracker.updated') {
const tracker = event.result;
const order = await db.orders.findByTrackingCode(tracker.tracking_code);
if (order) {
const normalizedStatus = normalizeTrackingStatus(tracker.status);
await order.updateTrackingStatus(normalizedStatus);
// Send proactive notification at key moments
if (['out_for_delivery', 'delivered', 'delivery_failed'].includes(normalizedStatus)) {
await notifyCustomer(order, normalizedStatus);
}
}
}
res.status(200).send('OK');
});
Proactive notification via email or SMS at key moments (order shipped, out for delivery, delivered, delivery attempted) reduces the volume of "Where is my order?" support tickets — which represent 40-60% of customer service volume for e-commerce without proactive tracking.
UK and EU Shipping
For UK operations, the equivalent carriers are Royal Mail (equivalent to USPS), Evri (formerly Hermes), DPD, and DHL. Shippo and Sendcloud serve as aggregators covering these carriers with unified APIs. For EU, Sendcloud is the dominant aggregator with excellent coverage across Germany, France, Italy, Netherlands, and Spain.
Conclusion
Efficient logistics is built in layers: accurate quoting that does not surprise the customer at checkout, automatic label generation that eliminates the operational bottleneck, unified tracking that turns carrier jargon into clear communication, and proactive notification that reduces anxiety and support tickets.
At SystemForge, we build logistics modules integrated with e-commerce covering the entire flow, from checkout rate quoting to confirmed delivery. Talk to our team to understand how we can improve your store's logistics operation.
Need help?


