Skip to content

Getting Started

Install a TikTok Shop API SDK, authorize a shop with OAuth, and make your first signed call in TypeScript, Python, Go, Java, Kotlin, PHP, Rust or C#.

The TikTok Shop API SDKs are typed clients for the TikTok Shop Partner API in eight languages. Every SDK is generated from one OpenAPI 3.1 spec, which is itself generated from TikTok Shop’s partner documentation, so the eight cover the same 318 operations and 44 webhooks with the same names and behavior.

The generator can’t write some parts, so each SDK adds them by hand:

  • request signing and shop cipher handling;
  • an OAuth helper for the authorization URL, token exchange and refresh;
  • webhook verification with typed events;
  • a single error type.

This is an unofficial project, not affiliated with or endorsed by TikTok or ByteDance. Request signing follows TikTok’s documentation and has not been verified against the live API yet. If TikTok rejects a signature, please open an issue at https://github.com/isaackogan/TikTok-Shop-Api-SDKs/issues.

  • A TikTok Shop app. Register it in TikTok Shop Partner Center. It gives you an app key and an app secret. Seller and partner apps also have a service ID, which authorization URLs need. Keep the app secret on your server.
  • A redirect URL registered on the app. TikTok sends the seller back there with an authorization code.
  • A supported runtime: Node.js 22, Python 3.11, Go 1.22, Java 11, PHP 8.2, Rust 1.88 or .NET 8, or newer.

The concepts page explains each credential and how they fit together.

Terminal window
npm install tiktok-shop-api

A seller authorizes your app in three steps:

  1. You send them to an authorization URL.
  2. TikTok redirects them back with a code.
  3. You trade that code for an access token and a refresh token.

The access token expires, so refresh it before it does. Each SDK’s OAuth helper builds the URL and calls the token endpoints.

import { TikTokShopAuth } from 'tiktok-shop-api';
const auth = new TikTokShopAuth({
appKey: process.env.TTS_APP_KEY!,
appSecret: process.env.TTS_APP_SECRET!,
serviceId: process.env.TTS_SERVICE_ID!, // seller and partner flows
});
// 1. Send the seller here. `type` is 'seller' | 'partner' | 'creator'; `region` is 'us' | 'row'.
const url = auth.authorizationUrl({ type: 'seller', region: 'us', state: 'csrf-token' });
// 2. TikTok redirects back with ?code=...; exchange it.
const code = new URL(callbackUrl).searchParams.get('code')!;
const tokens = await auth.exchangeCode(code);
// tokens.accessToken, tokens.refreshToken, tokens.openId, tokens.grantedScopes, ...
// 3. Before the access token expires (accessTokenExpireIn is a Unix timestamp):
const renewed = await auth.refresh(tokens.refreshToken);

Use the state parameter to tie the redirect to the session that started it, and check it when TikTok redirects back. See authorization for the authorization kinds, regions and token lifetimes.

Most operations act on one shop, identified by its shop cipher. Find it with the authorized-shops call, then give it to the client. The client:

  • signs each request;
  • adds app_key and timestamp;
  • sends your access token in the x-tts-access-token header;
  • adds shop_cipher to the operations that need it.
import { TikTokShop } from 'tiktok-shop-api';
const client = new TikTokShop({
appKey: process.env.TTS_APP_KEY!,
appSecret: process.env.TTS_APP_SECRET!,
accessToken: tokens.accessToken,
});
// Find the shop cipher
const shops = await client.authorization.getAuthorizedShops();
const shopCipher = shops.data?.shops?.[0]?.cipher;
const seller = client.withShop({ accessToken: tokens.accessToken, shopCipher });
const orders = await seller.orders.getOrderList({ pageSize: 20 });

Every SDK groups its operations by API area, with the same names as the spec’s tags: orders, products, fulfillment, logistics, finance, the three affiliate areas, and so on. A failed call raises the SDK’s error type, carrying TikTok’s code, message and request_id; see errors.

  • Concepts: credentials, shop ciphers, signing and IDs.
  • Webhooks: verify TikTok’s signature and parse typed events.
  • Choose an SDK: each language’s section covers its client, OAuth helper, webhooks and errors in detail.
  • OpenAPI: download the spec, or browse every operation and webhook in the API reference.