Skip to content

Rust SDK

Install tiktok-shop-api, the typed async TikTok Shop API client for Rust, and make your first call.

tiktok-shop-api is a typed Rust client for the TikTok Shop Partner API. Its calls are async and run on tokio. It signs requests, handles OAuth, works with many shops at once, and verifies and types webhooks. It is published to crates.io, and its source is in rust/.

Terminal window
cargo add tiktok-shop-api

Requires Rust 1.88 or newer. The calls are async and run on tokio, so add it too (cargo add tokio --features macros,rt-multi-thread). TLS is native-tls by default; to use rustls instead:

[dependencies]
tiktok-shop-api = { version = "0.1", default-features = false, features = ["rustls"] }

The crate is tiktok_shop_api. Models are in tiktok_shop_api::generated::models.

With an access token from the OAuth helper, create a client and call an operation:

use tiktok_shop_api::{Options, TikTokShop};
#[tokio::main]
async fn main() -> Result<(), tiktok_shop_api::Error> {
let client =
TikTokShop::new(Options::new("APP_KEY", "APP_SECRET").access_token("ACCESS_TOKEN").shop_cipher("SHOP_CIPHER"))?;
// page_size, then sort_order, page_token, sort_field and the request body, all optional.
let orders = client.orders.get_order_list(20, None, None, None, None).await?;
if let Some(data) = orders.data {
println!("{:?} orders; request {:?}", data.total_count, orders.request_id);
}
Ok(())
}

Every call is signed, timestamped and sent with your access token. The shop_cipher query parameter is added for you on the endpoints that need it.

  • Authorization: TikTokShopAuth, authorization URLs, token exchange and refresh.
  • Calling the API: the client, API areas, many shops and options.
  • Webhooks: webhooks::verify_and_parse and typed events.
  • Errors: the Error enum and its variants.