On this page
- Status: Accepted
- Date: 2026-06
- Context owner: Platform / Connectors
- Applies to:
packages/connectors/tiktok-shop,packages/connectors/lazada,packages/connectors/shopee, and all future platform connectors
Context#
UCIP ingests sales data from TikTok Shop, Shopee, and Lazada via their respective Open Platform APIs. Each platform publishes an official SDK (npm packages maintained by the vendor). The question arose: should connectors consume these vendor SDKs, or implement HTTP calls directly against the platform REST/JSON APIs?
The decision affects maintainability, type safety, debugging surface, and long-term stability for a system where data correctness is load-bearing (BLO revenue figures, NMV formulas, audit trails).
Decision#
D1 — No vendor SDKs; raw fetch + hand-rolled signing in each connector
All connectors implement platform communication via Node.js native fetch with a purpose-built signing module (signing.ts) per platform, rather than importing any npm package from the platform vendor.
D2 — Shared infrastructure lives in @yng/connectors-core
Retry logic, error classification, unified output schemas (Zod-validated), queue payloads, and rate-limit helpers are centralised in the packages/connectors/core workspace package. Platform connectors depend only on this internal package plus zod for boundary validation.
D3 — One signing.ts module per platform encodes the full algorithm
Each platform has subtly different signing: Lazada UPPERCASE-hex path-prefixed HMAC-SHA256; TikTok Shop lowercase-hex app_secret-wrapped; Shopee lowercase-hex with non-shop vs shop base-string variants and Unix-second timestamps. These are 30–50 line pure functions that are easy to unit-test and audit against the spec.
Rationale#
Why not vendor SDKs?
- Poor maintenance cadence. TikTok Shop and Lazada Node.js SDKs lag behind their own API specs by weeks to months. Shopee has no official Node.js SDK at all. When a new endpoint ships or a signing spec changes, the SDK may not reflect it for a long time — or ever.
- No TypeScript types. Vendor SDKs either ship no types or provide types so loose (
any,Record<string, unknown>) that consuming them adds no safety and actually suppresses the type errors we rely on to catch schema drift. - Hidden signing black box. Signature bugs surface as opaque 403/invalid-signature responses. When signing is in our own
signing.tsthe full algorithm is readable, testable, and debuggable in one place. - Abandonment risk. Lazada's Node SDK has seen no maintenance activity for extended periods. Depending on an abandoned SDK creates a cliff: either stay on the broken version or do the raw-HTTP rewrite under pressure.
- Unnecessary abstraction layer. Platform APIs are simple JSON REST with HMAC auth. The "convenience" a thin SDK wrapper provides is offset by the indirection it adds to debugging, dependency audits, and version management.
Why this approach scales
- The signing algorithm is the hardest platform-specific piece; it is stable once implemented and unlikely to change without a versioned API bump that we control.
- All connectors share the same retry, rate-limit, and error-classification infrastructure through
@yng/connectors-core— improvements propagate automatically to all platforms. - Zod validation at the mapping layer (
mappers.ts) catches API schema drift immediately at the point of ingestion, before bad data reaches the warehouse. - Adding a new platform means: one
signing.ts, oneclient.ts, onemappers.ts— the same bounded shape every time.
Connector inventory (2026-06)#
| Platform | Signing | Timestamp unit | Hex case | Status |
|---|---|---|---|---|
| TikTok Shop | app_secret wraps (prefix + suffix); query params + body | Unix seconds | lowercase | ✅ Live |
| Lazada | Path-prefixed; sorted key=value concat | Unix ms | UPPERCASE | ✅ Live |
| Shopee | Non-shop: partner_; Shop: adds access_ |
Unix seconds | lowercase | ✅ Live (2026-06) |
Shopee connector specifics#
The Shopee connector was the last of the three to be fully implemented (previously a stub). Key implementation notes:
- Base URL:
https://partner.shopeemobile.com(prod),https://partner.uat.shopeemobile.com(sandbox). - Order list → detail pattern:
GET /api/v2/order/get_order_listreturns cursor-paginated order SNs;GET /api/v2/order/get_order_detailfetches details in batches of 50. Optional fields requested:voucher_info,actual_shipping_fee,actual_shipping_fee_confirmed,pay_time. - NMV inputs populated:
gmvVnd(Σ model_discounted_price×qty),subtotalBeforeDiscountVnd(Σ model_original_price×qty),shopVoucherVnd(voucher_type=2),platformDiscountVnd(voucher_type=1),nmvVnd=total_amount(what buyer pays after all discounts). - Inventory:
GET /api/v2/product/get_item_list(offset pagination) →GET /api/v2/product/get_item_base_info(batch of 50); stock fromstock_info_v2.summary_info.total_available_stockper model. - Token refresh:
POST /api/v2/auth/access_token/getwith non-shop signing (partner_id + path + timestamp only). - Creators: intentional no-op — Shopee affiliate data is not exposed via the standard Open Platform API.
Consequences#
- Positive: full control over the signing algorithm, zero vendor SDK dependency risk, TypeScript-strict from boundary to DB, signing is auditable and unit-testable in isolation.
- Negative: new platform onboarding requires reading the raw API spec and implementing signing from scratch — there is no shortcut. This is offset by the bounded, repeatable shape (
signing + client + mappers + connector). - Ongoing obligation: when a platform changes its signing spec or introduces a new API version, we update
signing.tsandclient.tsdirectly. No SDK release to wait for.