The TikTok Shop API Sample Application and Middleware Server includes an example React/Typescript frontend, and an example ExpressJS/Typescript middleware server.
It has the following architecture:
The ExpressJS server performs the following functions:
- Storage of secrets and user data using a simple file-based database.
- A REST API for user management, authorization and authentication, and TikTok Shop data for the front end UX.
- A typescript SDK for the TikTok Shop API.
Typescript types are shared between the frontend and backend, and are defined in the ttspc-sample-shared-types package. In most cases, the resources returned by the middleware service are simply the TikTok Shop API resource wrapped in the middleware service's payload wrapper:
export type ssaResponseWrapper<T> = {
code: number;
message: string;
request_id: string;
data: T;
}Currently, the following TikTok Shop API URIs are supported:
/api/v2/token/getuser/api/v2/token/refresh/authorization/202309/shops/product/202309/categories/product/202309/categories/${categoryId}/attributes/product/202309/categories/recommend/product/202309/categories/${categoryId}/rules/product/202312/products/create/product/202312/prerequisites/product/202309/products/search/product/202309/images/upload
To use this package locally with the sample application, clone this repository and follow these steps:
npm install
npm run build
npm linkOnce the package is linked, you can install it in the sample application:
npm link ttspc-sample-shared-types