npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@redonvn/shipping-supership

v0.2.0

Published

TypeScript SDK for SuperShip Partner API

Readme

@redai/shipping-supership

SDK TypeScript/Node.js cho SuperShip Partner API v1. Node.js 18+.

Đăng ký, cài đặt và xác thực

  1. Mở trang khách hàng SuperShip, chọn Đăng ký ngay để tạo tài khoản. Có thể vào trang đăng ký trực tiếp. Nếu được đối tác giới thiệu, dùng đúng đường dẫn có mã giới thiệu của họ.
  2. Đăng nhập trang khách hàng, mở mục API và lấy Personal Access Token theo hướng dẫn xác thực.
  3. Nếu tích hợp nhiều shop bằng client_id, client_secret và Password Grant, liên hệ SuperShip Support APIs để được cấp quyền đối tác. SDK hiện nhận access token đã cấp qua accessToken hoặc tokenProvider.
npm install @redai/shipping-supership

Lấy Personal Access Token tại mục API trong tài khoản SuperShip. Chỉ dùng token trên server. Sandbox SuperShip hiện bảo trì; SuperShip cấp tài khoản test để thử trên production.

import { SuperShipClient } from '@redai/shipping-supership';

const ship = new SuperShipClient({ accessToken: process.env.SUPERSHIP_ACCESS_TOKEN });
const provinces = await ship.areas.provinces();
const districts = await ship.areas.districts(provinces[0].code);
const communes = await ship.areas.communes(districts[0].code);
const quotes = await ship.rates.quote({
  sender_province: 'Thành phố Hồ Chí Minh', sender_district: 'Quận Tân Bình',
  receiver_province: 'Thành phố Hà Nội', receiver_district: 'Quận Ba Đình', weight: 500, value: 100000,
});

Các API trả trực tiếp results từ envelope SuperShip. Nếu HTTP hoặc status báo lỗi, SDK ném SuperShipApiError với statusCode và endpoint. Nội dung phản hồi thô có thể chứa dữ liệu khách hàng nên không được gắn vào exception.

Tạo và quản lý đơn

const warehouses = await ship.warehouses.list();
const order = await ship.orders.create({
  pickup_code: warehouses[0].code,
  name: 'Khách thử nghiệm', phone: '0900000000', address: '1 Phố mẫu',
  province: 'Thành phố Hà Nội', district: 'Quận Ba Đình', commune: 'Phường Điện Biên',
  amount: 0, value: 100000, weight: 500, soc: 'TEST-ORDER-001',
  service: '1', config: '1', payer: '1', product_type: '1', product: 'Hàng thử nghiệm',
});
const current = await ship.orders.get(order.code);
const byMerchantCode = await ship.orders.get('TEST-ORDER-001', '2');
const statuses = await ship.orders.statuses();
const printUrl = await ship.labels.printUrl([order.code], 'A5');
// Chỉ hủy đơn thử nghiệm khi cần:
// await ship.orders.cancel(order.code);

weight tính bằng gram; amount (COD) và value (trị giá bảo hiểm) tính bằng VND nguyên. value bắt buộc theo changelog v1.0.14. Có thể gửi đủ các trường pickup_* thay cho pickup_code. product_type: '2' dùng mảng products thay product. soc là mã đơn của bạn; code là mã SuperShip; shortcode dùng cho barcode. Sau timeout khi tạo đơn, tra cứu theo soc trước khi quyết định tạo lại.

printUrl lấy print token rồi tạo URL trình duyệt ở khachhang.supership.vn. URL chứa token, cần giữ kín. SDK không khẳng định URL này là PDF tải trực tiếp.

Kho và webhook

const warehouse = await ship.warehouses.create({
  name: 'Kho thử nghiệm', phone: '0900000000', contact: 'Người liên hệ',
  address: '1 Đường mẫu', province: 'Thành phố Hà Nội',
  district: 'Quận Ba Đình', commune: 'Phường Điện Biên', primary: '2',
});
await ship.warehouses.update({ code: warehouse.code, name: 'Kho thử nghiệm', phone: '0900000000', contact: 'Người liên hệ' });
const webhookConfig = await ship.webhooks.get();
// await ship.webhooks.set('https://example.com/supership/callback');
const event = ship.webhooks.parse('{"type":"update_status","code":"TEST123","status":"2"}');

Sửa địa chỉ kho cần tạo kho mới theo tài liệu SuperShip. webhooks.set thay URL hiện tại và áp dụng cho đơn tạo sau khi đổi. Parser chỉ kiểm tra cấu trúc cơ bản: tài liệu webhook chưa công bố chữ ký xác minh. Ứng dụng cần bảo vệ callback, lưu sự kiện để xử lý trùng và trả HTTP 200 sau khi nhận thành công.

Tài liệu API

Xem hướng dẫn sử dụng, tài liệu tích hợp tổng hợp, bảng endpoint và giới hạn, kế hoạch triển khai, xác thực, đơn hàng, kho, webhook.