Skip to content

Calling the API

Create the TikTokShopClient, call operations by API area, work with many shops, and set the HTTP handler in C#.

TikTokShopClient is the API client. Create one and reuse it for the life of your app: it owns the connection pool. Each request it sends gets the following automatically:

  • the app_key, timestamp and sign query parameters;
  • your access token, in the x-tts-access-token header;
  • shop_cipher, on the operations that need one.
using System;
using TikTokShop.Api;
var client = new TikTokShopClient(
appKey: "YOUR_APP_KEY",
appSecret: "YOUR_APP_SECRET",
accessToken: "THE_SELLER_ACCESS_TOKEN",
shopCipher: "THE_SHOP_CIPHER");
// Every request is signed, and shop_cipher is added to the operations that take one.
var orders = await client.Orders.GetOrderListAsync(pageSize: 20);
Console.WriteLine($"{orders.Data.TotalCount} orders");

One property per API area hangs off the client, matching the spec’s tags. Each is the concrete generated API class, so your IDE completes the operations and models (in TikTokShop.Api.Generated.Model).

PropertyArea
AffiliateCreator, AffiliatePartner, AffiliateSellerAffiliate creator, partner and seller
AnalyticsAnalytics
AuthorizationAuthorization, including GetAuthorizedShopsAsync
CustomerEngagement, CustomerServiceCustomer engagement and customer service
EventEvent (webhook subscriptions)
FinanceFinance
FulfilledByTikTokFulfilled by TikTok (FBT)
Fulfillment, LogisticsFulfillment and logistics
Orders, Products, PromotionOrders, products and promotion
ReturnAndRefundReturn and refund
Seller, SupplyChain, ToolsSeller, supply chain and tools

Every call is async with a CancellationToken, and has a synchronous twin. The generated methods take their parameters in the order of the generated signature, ending with an optional CancellationToken. The shop_cipher parameter is not among them: the client adds it. Method names follow the API reference, in Pascal case with an Async suffix. 64-bit IDs are never rounded.

WithShop returns a client for another shop. It shares this client’s connections, and the original is not changed, so you can keep one per shop:

using TikTokShop.Api;
var client = new TikTokShopClient("YOUR_APP_KEY", "YOUR_APP_SECRET", accessToken: "TOKEN_A", shopCipher: "CIPHER_A");
// Another shop, sharing this client's connections. `client` is not changed.
var other = client.WithShop(accessToken: "TOKEN_B", shopCipher: "CIPHER_B");
// An argument you leave out keeps this client's value; null (or "") clears it.
var sameShopNewToken = client.WithShop(accessToken: "TOKEN_A2");
var noShop = client.WithShop(shopCipher: new Optional<string?>(null));

TikTokShopClient takes these named constructor arguments, or a TikTokShopOptions object with the same members:

OptionMeaning
appKey, appSecretYour app’s credentials.
accessTokenThe seller’s access token, sent in x-tts-access-token.
shopCipherThe shop cipher added to operations that need one.
baseUrlThe API host, an origin such as https://host:8443 with no path prefix: signing and shop-cipher matching use the request path. Defaults to https://open-api.tiktokglobalshop.com (DefaultBaseUrl).
timeoutA TimeSpan for the whole exchange. Defaults to 30 seconds (DefaultTimeout); TimeSpan.Zero means no limit.
handlerAn HttpMessageHandler, used as is for API calls, so its redirect, proxy and certificate settings apply.

By default the SDK builds a SocketsHttpHandler that never follows redirects, uses the system proxy, and recycles pooled connections every two minutes so DNS changes are picked up. A 3xx reply is a TikTokShopException with code 302, so the access token is never forwarded to another host. Pass your own handler:; its redirect policy applies to API calls. The OAuth calls never follow redirects: a handler with AllowAutoRedirect set to true is refused, because the token URL holds your app secret.

Three operations are GETs with a body: GetConversationList, MapTokopediaToTikTokShopProductIDs and GetShippingTemplateAvailability. The SDK sends the body and signs it.

Requests carry the User-Agent tiktok-shop-api-csharp/<version>, exposed as TikTokShopClient.UserAgent.