dhl-ts
v1.1.9
Published
Type-safe TypeScript SDK for DHL Shipment Tracking API
Maintainers
Readme
The Three DHL Clients
DHL is not one API.
So we didn’t build one client.
We built three.
Each one does one thing. Cleanly. Completely. Without surprises.
1. DHLExpress
Shipping lives here.
Rates. Shipments. Pickups. Duties.
This client talks only to MyDHL Express. It knows exactly how to authenticate. You don’t have to think about it.
You give it two things:
- API Key
- API Secret
Nothing else.
import { DHLExpress } from 'dhl-ts';
const express = new DHLExpress({
apiKey: process.env.DHL_EXPRESS_KEY,
apiSecret: process.env.DHL_EXPRESS_SECRET,
environment: 'production'
});Now do the work:
const landedCost = await express.getLandedCost({...});That’s it.
2. DHLGlobalForwarding
Freight lives here.
Heavy shipments. Deep tracking. Logistics flows.
This client speaks directly to DHL Global Forwarding.
It needs one thing:
- API Key
import { DHLGlobalForwarding } from 'dhl-ts';
const forwarding = new DHLGlobalForwarding({
apiKey: process.env.DHL_FORWARDING_KEY,
environment: 'production'
});Ask for what you need:
const tracking = await forwarding.getShipment({
searchType: 'shipmentID',
value: '777333555'
});Done.
3. DHLUnifiedTracking
Tracking lives here.
Simple. Fast. Reliable.
One key. One call.
import { DHLUnifiedTracking } from 'dhl-ts';
const tracking = new DHLUnifiedTracking({
apiKey: process.env.DHL_UNIFIED_TRACKING_KEY
});Check status:
const status = await tracking.trackShipment('1234567890');No ceremony.
Why This Exists
Most SDKs try to hide DHL.
That’s where they break.
They mix:
- Basic Auth
- OAuth2
- API keys
into one “smart” wrapper.
It feels clever.
Until it fails.
We did the opposite.
We made the boundaries obvious.
Each client mirrors a real DHL system.
So:
- No hidden rules
- No leaking auth
- No silent failures
What You Get
- The right auth, every time
- Methods that belong where they should
- Autocomplete that makes sense
You don’t guess.
You call the method.
It works.
Install
npm install dhl-tsErrors (That Actually Help)
When something breaks, it tells you why.
import { DHLError } from 'dhl-ts';
try {
await express.createShipment({...});
} catch (error) {
if (error instanceof DHLError) {
console.error(error.code);
console.error(error.message);
}
}No mysteries.
Extend It
Need a new endpoint?
Open the client. Add the method.
That’s it.
No wrappers. No magic.
The client already knows:
- where to send the request
- how to authenticate
You just describe the call.
The Idea
Don’t fight DHL.
Respect its shape.
Pick the client.
Ship the code.
License
MIT
