Skip to content

Repository files navigation

Pirateship API

An unoffical typed wrapper for the PirateShip API.

Installation

bun i pirateship-api

Usage

import { 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

About

the pirateship api - typed

Topics

Resources

Contributing

Stars

19 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages