sendlogistics-node-sdk
v0.0.1
Published
Send Logistics Merchant v2 API node SDK
Maintainers
Readme
Send Logistics Node SDK
Unofficial Node SDK for the Send Logistics merchant API. The TypeScript client is generated from the published OpenAPI spec via @hey-api/openapi-ts, and a thin createAPI() wrapper sets up Basic auth and sensible defaults.
Official Merchant v2 API docs: https://routing.sendlogistics.com/apidocs-merchantul
Send Logistics has OpenAPI specs for Network/Carrier and this SDK is not for those.
Install
npm i sendlogistics-node-sdkyarn add sendlogistics-node-sdkEnvironments
| Environment | Base URL |
| ----------- | ----------------------------------------- |
| Sandbox | https://routingunit.sendlogistics.com |
| Production | https://routing.sendlogistics.com |
Authentication
Basic auth via the Authorization header. For initial sandbox testing the API documents the credentials sample:merchant:
Authorization: Basic base64encode(sample:merchant)
Authorization: Basic c2FtcGxlOm1lcmNoYW50Production credentials are issued by Send Logistics. createAPI() accepts either a { username, password } pair (it base64-encodes for you) or a pre-encoded token string.
Usage
import { createAPI } from 'sendlogistics-node-sdk';
import { rateRequestFeeEstimation } from 'sendlogistics-node-sdk/dist/client/merchant-ul/sdk.gen';
// Configures the underlying client (Basic auth header, base URL).
createAPI(
{ username: 'sample', password: 'merchant' },
'https://routingunit.sendlogistics.com'
);
const { data, error } = await rateRequestFeeEstimation({
body: {
deliveryOption: 'SAME_DAY',
weight: '1',
signatureNeeded: true,
recipientAddress: {
street: '555 W Hastings St',
city: 'Vancouver',
stateProv: 'BC',
countryCode: 'CA',
postCode: 'V6B 4N7',
},
},
});
if (error) {
throw new Error(`rate request failed: ${JSON.stringify(error)}`);
}
console.log(`quote: $${data?.result} (${data?.daysToDeliver} days, ${data?.billWeight})`);The createAPI() return value also exposes generic get(path) / post(path, body) helpers for endpoints that the generated SDK can't model cleanly (see caveats below).
See test/sendlogistics-api.spec.ts for a runnable example.
Endpoints
All paths are under /ext-interface/echobase-web/rest/v1.
| Method | Path | Generated function | Purpose |
| ------ | ------------------------------------- | --------------------------- | ------------------------------------ |
| POST | /orders | createANewOrder | Create a new delivery order |
| GET | /orders/{trackNumber} | statusOfOrder (see ⚠) | Get current status of an order |
| GET | /orders/{trackNumber}/track | trackingEvents (see ⚠) | All tracking events for an order |
| GET | /orders/{trackNumber}/ShippingLabel | pdfShippingLabel (see ⚠)| PDF (6×4) shipping label URL |
| GET | /orders/{trackNumber}/ZplLabel | zebraShippingLabel (see ⚠)| Zebra (ZPL) shipping label URL |
| POST | /batchorders | batchOrders | Submit multiple orders at once |
| POST | /orders/fee_estimation | rateRequestFeeEstimation | Get a price/rate quote |
Allowed values
deliveryOption—SAME_DAY,NEXT_DAY,IN_TWO_DAYS,GROUNDdeliveryType—DROPOFF,PICKUP,SELF_PICKUPcategory—GROCERY,PACKAGE,DOCUMENT,OTHERzoneSkipping—CARRIER-COURIER(carrier handles zone skipping;pickUpAddressrequired),CUSTOMER-SHIPS(you deliver to the destination warehouse)- Order / event statuses —
DATA_RECEIVED,CUSTOMS_CLEARED,IN_TRANSIT_TO_HUB,ARRIVED_AT_TERMINAL,DATA_RECEIVED_GOODS_NOT_RECEIVED,READY_FOR_OUTBOUND,WAIT_TO_BE_STARTED,IN_PROGRESS,FIRST_ATTEMPT,SECOND_ATTEMPT,THIRD_ATTEMPT,ATTEMPTED_DELIVERY,DAMAGED,COMPLETED,DELIVERY_NOT_COMPLETED,LOST_IN_SORTING,LOST_BY_DRIVER,CANCELLED,RETURN_TO_CLIENT,HELD_BY_COURIER
Caveats in the upstream OpenAPI spec ⚠
Worth knowing if the generated client surprises you:
- The track-number endpoints write the path param as
[:trackNumber](Express style) instead of{trackNumber}, so the generated SDK functions hit the literal path. Use theget()/post()helpers fromcreateAPI()to call those endpoints with a real track number. signatureNeededis declared astype: bool(not valid OpenAPI), so the generated TypeScript type isunknown. Passtrue/falseas expected — the API itself accepts a boolean.goodsis declared as a single object instead of an array, so the generated type is theGoodsobject. The runtime API accepts and returns an array.- The
address.requiredlist is malformed in the spec, so generated optionality may not exactly match what the API enforces.
Regenerating the client
yarn generate:merchant-ulReads openapi-merchant-ul.yaml and writes the typed client to src/client/merchant-ul/.
