Get the current shipment status.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');
// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });
async function run() {
// Load the profile
const profile = await sdk.getProfile('delivery-tracking/shipment-info@1.1.1');
// Use the profile
const result = await profile
.getUseCase('ShipmentInfo')
.perform({
trackingNumber: '00340434292135100148'
}, {
provider: 'mock'
});
// Handle the result
try {
const data = result.unwrap();
console.log(data);
} catch (error) {
console.error(error);
}
}
run();
{
"trackingNumber": "00340434292135100148"
}
[
{
"carrier": "shippo",
"destination": {
"address": {
"addressLocality": "Chicago",
"countryCode": "US",
"postalCode": "60611"
}
},
"estimatedDeliveryDate": "2021-11-08T07:03:30.944Z",
"events": [
{
"statusCode": "unknown",
"statusText": "The carrier has received the electronic shipment information.",
"timestamp": "2021-11-01T19:54:08.906Z"
}
],
"origin": {
"address": {
"addressLocality": "San Francisco",
"countryCode": "US",
"postalCode": "94103"
}
},
"status": {
"location": {
"address": {
"addressLocality": "Chicago",
"countryCode": "US",
"postalCode": "60611"
}
},
"statusCode": "delivered",
"statusText": "Your shipment has been delivered.",
"timestamp": "2021-11-03T23:54:08.906Z"
},
"trackingNumber": "00340434292135100148"
}
]