
TikTok Shop API Client
API Client • v1.0.6npm i tiktokshops-api-clienttiktokshops-api-client is a TypeScript library for TikTok Shop Open API. It speaks both v1 and v2 and covers seller OAuth, orders (getOrderList, getOrderDetail, getPriceDetail), products (getProductDetail, getCategories, getBrands, getAttributes, createProduct), fulfillment (shipPackage, getPackageTimeSlots, getPackageShippingDocument), and the logistic APIs. Request signing uses crypto-js and follows the signature scheme TikTok Shop expects.
Key Features
- ◆OAuth: generateAuthLink, fetchTokenWithAuthCode, refreshToken, getAuthorizedShop
- ◆Orders (v2): getOrderList, getOrderDetail, getPriceDetail
- ◆Products (v2): getProductDetail, getCategories, getBrands, getAttributes, createProduct
- ◆Fulfillment (v2): shipPackage, getPackageTimeSlots, getPackageShippingDocument
- ◆API v1 (legacy): order and product APIs
- ◆Config: appKey, appSecret, serviceId, shopId, shopCipher, accessToken, refreshToken
- ◆US domain support for the US Partner Center
Code Examples
Creating the client
import { TiktokModule } from "tiktokshops-api-client";
const tiktok = new TiktokModule({
appKey: process.env.TIKTOK_APP_KEY!,
appSecret: process.env.TIKTOK_APP_SECRET!,
serviceId: process.env.TIKTOK_SERVICE_ID!,
shopId: process.env.TIKTOK_SHOP_ID!,
shopCipher: process.env.TIKTOK_SHOP_CIPHER!,
accessToken: process.env.TIKTOK_ACCESS_TOKEN!,
refreshToken: process.env.TIKTOK_REFRESH_TOKEN!,
});Fetching orders
// Orders from the last 24 hours
const orders = await tiktok.getOrderList({
beforeHours: 24,
pageSize: 20,
sortField: "create_time",
sortOrder: "ASC",
});
console.log(orders);
// Detail for a single order
const detail = await tiktok.getOrderDetail("ORDER_NUMBER");
console.log(detail);Creating a product
import { TiktokModule } from "tiktokshops-api-client";
const tiktok = new TiktokModule({ /* config */ });
// Look up the category and its attributes
const categories = await tiktok.getCategories();
const attributes = await tiktok.getAttributes(categoryId);
// Create the product
const newProduct = await tiktok.createProduct({
product_name: "Product name",
category_id: "CATEGORY_ID",
description: "Product description...",
// ... remaining fields
});Resources
Related Article
Handling Shopee and TikTok Shop webhook pushes safely
HMAC signature verification fails for a reason that has nothing to do with the key or the algorithm: one JSON parse-and-reserialize step, done before signature check, is enough to change every byte.
TikTok Shop API Client — API Client • v1.0.6Trở về Trang chủ