Skip to content
HomeCase studiesThoughtsOpen source
Case studies

Making multiple shipping companies' APIs work as one taught me when not to abstract

22 Feb 2025

The problem

Same job, different rules

Shipping companies do pretty much the same thing. They pick up a package and deliver it somewhere.

Their APIs, however, tell a completely different story.

Some send tracking updates through webhooks. Others expect you to keep asking for them. Some let you cancel a package, others don't.

Even something as simple as identifying a city can work differently from one carrier to another.

My approach

Sharing what actually makes sense

We already had a common delivery service when I joined the project, but there was still room for improvement.

Take tracking statuses. Each carrier had its own status mapping and its own copy of the conversion logic.

I moved the conversion logic into a shared service. Each carrier only needed to describe how its statuses mapped to ours.

Tracking status
Carrier ADELIVERED
Carrier BDEL
Carrier C30
Shared converter Mapping table
DeliveredOur status
DELdeliveredSame conversion logic
Choose a tracking event to see how different carrier codes map to a common status. Sample codes only.

Adding support for a new status could now be as simple as adding an entry to a mapping table.

The interesting part

Not every carrier can do everything

Some carriers require us to register merchants before creating shipments. Others don't.

Yet our contract required every carrier to implement a registration method, even when it had nothing to do.

That's where abstraction gets a little silly.

When introducing newer capabilities like return requests and package update notifications, I took a different approach.

Carriers could implement what they supported. Unsupported operations had an explicit way of saying so.

Carrier capabilities
Select a cell to see how the operation is handled.
Supported Unsupported
OperationCarrier ACarrier BCarrier C
Create shipment
Tracking history
Cancel shipment
Update notification
Optional
Return request
Optional
Carrier A
Return request
Unsupported
Shared contract
createReturnRequest()
Default implementation
NotImplementedEndpointException
The base service reports that this operation is unsupported. The carrier does not need to override the method.
Interactive example using illustrative carrier capabilities.

There was no reason to make every carrier pretend it could do everything.

What changed

A new carrier, a familiar process

Integrating a new shipping company became a familiar process, even when its API was completely different.

New capabilities could be introduced without requiring every existing integration to change.

The goal wasn't to make all shipping companies identical. It was to make working with them feel consistent.

Next case studyHow we made shipping with multiple carriers feel like shipping with one
WhatsApp LinkedIn GitHub