An unoffical typed wrapper for the PirateShip API.
bun i pirateship-apiimport { fetchShippingRates } from "pirateship-api";
const options: ShippingOptions = {
originZip: "20001",
originCity: "Washington",
originRegionCode: "DC",
isResidential: true,
destinationZip: "90028",
destinationCountryCode: "US",
mailClassKeys: [
"PriorityExpress",
"First",
"ParcelSelect",
"Priority",
],
packageTypeKeys: ["SoftEnvelope"],
weight: 14,
dimensionX: 9,
dimensionY: 10,
dimensionZ: 5
showUpsRatesWhen2x7Selected: true,
};
const rates = await fetchShippingRates(options);
console.log(rates.map((rate) => rate.title + " - " + rate.carrier.title + " - $" + rate.totalPrice));Running the above code will output the following:
;['Priority Mail - USPS - $10.07', 'Priority Mail Express - USPS - $47.25']This is a work in progress and the types are accurate as of 2026-02-23 but can't be guaranteed to be 100% correct as this is an undocumented internal API.
© 2024-present Kieran Klukas
