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-lalamove

v1.1.0

Published

Production-ready Lalamove Delivery REST API v3 SDK for RedAI Monorepo (Motorcycle, Van 500kg, Truck 1T-2T, HMAC-SHA256)

Readme

@redai/shipping-lalamove

TypeScript License: MIT

SDK TypeScript/JavaScript chính thức và độc lập cho nền tảng giao hàng đa phương tiện Lalamove (REST API v3), hỗ trợ từ Xe máy đến Xe tải 2 tấn, tích hợp chữ ký bảo mật HMAC-SHA256 tự động và tuân thủ chuẩn giao diện IShippingProvider của RedAI Ecosystem.

Cài đặt

npm install @redai/shipping-lalamove @redai/shipping-common
# hoặc với pnpm
pnpm add @redai/shipping-lalamove @redai/shipping-common
# hoặc với yarn
yarn add @redai/shipping-lalamove @redai/shipping-common

Khởi tạo và Sử dụng Nhanh

import { LalamoveClient } from "@redai/shipping-lalamove";

// 1. Khởi tạo Client
const lalamove = new LalamoveClient({
  apiKey: process.env.LALAMOVE_API_KEY!,
  apiSecret: process.env.LALAMOVE_API_SECRET!,
  market: "VN",
  environment: "sandbox", // hoặc "production"
});

// 2. Lấy báo giá chuyến đi
const quotation = await lalamove.quotations.createQuotation({
  serviceType: "MOTORCYCLE",
  stops: [
    {
      coordinates: { lat: "10.7769", lng: "106.7009" },
      address: "Bưu cục Quận 1, TP. Hồ Chí Minh",
    },
    {
      coordinates: { lat: "10.7925", lng: "106.6881" },
      address: "Phường Đa Kao, Quận 1, TP. Hồ Chí Minh",
    },
  ],
});

console.log(`Mã báo giá: ${quotation.quotationId}`);
console.log(`Cước phí: ${quotation.priceBreakdown.total} ${quotation.priceBreakdown.currency}`);

// 3. Đặt xe giao hàng
const order = await lalamove.orders.createOrder({
  quotationId: quotation.quotationId,
  sender: {
    stopId: "stop_0",
    name: "Kho Hàng RedAI",
    phone: "0901234567",
  },
  recipients: [
    {
      stopId: "stop_1",
      name: "Nguyễn Văn B",
      phone: "0987654321",
      remarks: "Giao giờ hành chính, gọi trước khi đến",
    },
  ],
  isPODEnabled: true,
});

console.log(`Đã tạo cuốc xe: ${order.orderId} - Trạng thái: ${order.status}`);

Tính năng Nổi bật

  • Kiến trúc Monorepo Speakeasy: Phân tách rành mạch src/lib (HTTP, Security HMAC, Retries), src/hooks (Lifecycle Hooks), src/sdk (Quotations, Orders, Webhook).
  • Hỗ trợ 4 Loại Phương Tiện Vận Tải: MOTORCYCLE (Xe máy $\le$ 30kg), VAN_500KG (Bán tải $\le$ 500kg), TRUCK_1000KG (Xe tải 1 tấn), TRUCK_2000KG (Xe tải 2 tấn).
  • HMAC-SHA256 Signature Tự Động: Tính toán và gắn chữ ký bảo mật Authorization: hmac <apiKey>:<timestamp>:<signature> trên mọi HTTP request.
  • Tuân thủ Chuẩn IShippingProvider: Dễ dàng tích hợp vào hệ sinh thái quản lý vận chuyển đa sàn cùng ViettelPost và GrabExpress.
  • Thẩm định Webhook An toàn: Xác thực chữ ký webhook bằng cơ chế so sánh hằng thời gian (crypto.timingSafeEqual) chống tấn công Timing Attack.
  • Khả năng Phục hồi Cao (Resilience): Cơ chế Exponential Backoff với Full Jitter tự động xử lý mã lỗi 429 Too Many Requests và lỗi máy chủ mạng 5xx.

Cấu trúc Thư mục

packages/shipping-lalamove/
├── docs/
│   ├── sdks/
│   │   ├── quotations/README.md
│   │   ├── orders/README.md
│   │   └── webhook/README.md
│   └── models/
│       └── models.md
├── examples/
│   ├── demo.ts
│   └── test-mock-and-hooks.ts
├── src/
│   ├── hooks/
│   │   ├── hooks.ts
│   │   └── types.ts
│   ├── lib/
│   │   ├── config.ts
│   │   ├── http.ts
│   │   ├── retries.ts
│   │   └── security.ts
│   ├── sdk/
│   │   ├── lalamove.ts
│   │   ├── orders.ts
│   │   ├── quotations.ts
│   │   └── webhook.ts
│   ├── index.ts
│   ├── lalamove.mapper.ts
│   └── lalamove.types.ts
├── package.json
├── tsconfig.json
└── README.md

Tài liệu Chi tiết