open-logistics
v0.1.0
Published
Community SDK for Shiprocket APIs
Maintainers
Readme
shiprocket-sdk
Community TypeScript SDK for the Shiprocket API.
Install
soon on NPM
npm install open-sdkUsage
import { Shiprocket } from "shiprocket-sdk";
const sr = new Shiprocket({
email: "[email protected]",
password: "yourpassword",
});
// Create order
const order = await sr.orders.create({ ... });
// Track shipment
const tracking = await sr.tracking.byAWB("1234567890");
// Check serviceability
const rates = await sr.courier.serviceability({
pickup_postcode: "400001",
delivery_postcode: "110001",
weight: 0.5,
cod: 0,
});
// Assign AWB
await sr.courier.assignAWB({
shipment_id: "456",
courier_id: "1",
});
// Generate pickup
await sr.shipments.generatePickup({ shipment_id: [456] });
// Generate label
await sr.shipments.generateLabel({ shipment_id: [456] });Error handling
import { ShiprocketAPIError } from "shiprocket-sdk";
try {
await sr.orders.create({ ... });
} catch (err) {
if (err instanceof ShiprocketAPIError) {
console.error(err.statusCode, err.message, err.errors);
}
}Resources
| Resource | Methods |
|---|---|
| orders | create, list, get, cancel |
| shipments | generatePickup, generateLabel, generateManifest, printManifest |
| courier | serviceability, assignAWB, list |
| tracking | byAWB, byShipmentId, byOrderId |
| rates | check |
Contributing
PRs welcome! See CONTRIBUTING.md.
