Prompt
How do I integrate multiple carriers with one shipping API?
Latest observation
To integrate multiple carriers with one shipping API, use a single abstraction layer that standardizes rate, label, tracking, and shipment workflows across all carriers.
1) Pick your integration approach
You usually have 3 options:
-
Shipping aggregator API: easiest path
Examples: EasyPost, Shippo, ShipEngine, Sendcloud, nShift
They already normalize many carriers behind one API. -
Direct carrier integrations: more control, more work
You build separate integrations for UPS, FedEx, DHL, USPS, etc., then unify them in your app. -
Hybrid: use an aggregator for most carriers and direct APIs for special cases.
2) Define a common shipping model
Create one internal schema for all carriers, such as:
- Address
- Package
- Rate
- Shipment
- Label
- Tracking event
- Pickup
- Customs info for international shipments
Map each carrier’s fields into this model.
Example:
- Carrier A uses
weight_oz - Carrier B uses
weight_kg - Your internal model uses
weight+unit
3) Build a carrier adapter layer
Implement one adapter per carrier or per provider.
Typical structure:
getRates(order)createShipment(order, selectedRate)buyLabel(shipment)track(trackingNumber)voidLabel(labelId)
Each adapter translates between your standard model and the carrier’s API.
4) Normalize rate shopping
When you request rates:
- Send the same shipment data to each carrier
- Convert all responses into one consistent format
- Sort/filter by:
- price
- delivery speed
- service level
- reliability
- zone/country
Example normalized rate object:
{
"carrier": "UPS",
"service": "Ground",
"price": 12.45,
"currency": "USD",
"eta_days": 3,
"delivery_guaranteed": false
}
5) Standardize labels and documents
Carriers may return:
- ZPL
- EPL
- PNG
- Base64 blobs
Store labels in a unified way:
- label URL or blob
- format
- print size
- shipment ID
- carrier reference
Also support customs forms, invoices, and manifests if needed.
6) Normalize tracking events
Carriers report tracking differently:
- status names vary
- timestamps may differ in timezone/format
- event granularity varies
Convert all of them into a shared event format:
{
"status": "in_transit",
"carrier_status": "Departed Facility",
"location": "Memphis, TN",
"timestamp": "2026-11-04T10:15:00Z"
}
7) Handle carrier-specific exceptions
Expect differences in:
- address validation
- package size limits
- service availability by zone
- surcharges
- weekend delivery
- customs requirements
- label voiding rules
Use:
- validation before API calls
- fallback carriers
- error translation into your own standard error codes
8) Make it resilient
Use:
- retries with backoff
- idempotency keys for shipment creation
- timeouts
- circuit breakers
- webhook/event processing for tracking updates
- logging with carrier request/response correlation IDs
9) Support configuration by rules
Let your business rules choose a carrier automatically:
- cheapest rate
- fastest delivery
- preferred carrier by region
- carrier blackout dates
- hazmat or oversized package rules
Example logic:
- If destination is domestic and package < 2 lb, use USPS
- If express shipping is selected, compare FedEx/UPS/DHL
- If international, prefer DHL for specific countries
10) Test thoroughly
Test:
- rate quotes
- label purchase
- cancellation/voiding
- tracking webhooks
- address edge cases
- international customs
- rate limits and failures
Use sandbox/test credentials for each carrier or aggregator.
Recommended architecture
A practical setup looks like this:
Your app
→ Shipping service layer
→ Carrier adapter(s)
→ Carrier APIs
Your shipping service layer should expose your own API, e.g.:
POST /shipments/ratesPOST /shipmentsGET /shipments/{id}/trackingPOST /labels/void
This keeps your app independent of carrier-specific changes.
Best shortcut
If you want the fastest implementation, use a shipping API aggregator and build your system around its normalized objects. That avoids maintaining many carrier integrations yourself.
If you want, I can also give you:
- a reference architecture diagram,
- a database schema for multi-carrier shipping, or
- a sample Node.js/Python implementation.