Skip to content

PHP SDK

Install isaackogan/tiktok-shop-api, the typed TikTok Shop API client for PHP, with Composer and make your first call.

isaackogan/tiktok-shop-api is a typed PHP client for the TikTok Shop Partner API. It signs requests, handles OAuth, works with many shops at once, and verifies and types webhooks. It is published to Packagist, and its source is in php/.

Terminal window
composer require isaackogan/tiktok-shop-api

Needs PHP 8.2 or newer, with ext-curl, ext-json and ext-mbstring. The HTTP client is Guzzle 7.

The package is developed in the TikTok-Shop-Api-SDKs monorepo and mirrored to isaackogan/TikTok-Shop-Api-PHP, which is the repository Packagist reads. Please open issues in the main repository.

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

use TikTokShop\Api\TikTokShop;
$shop = new TikTokShop(appKey: 'YOUR_APP_KEY', appSecret: 'YOUR_APP_SECRET', accessToken: 'THE_SELLER_ACCESS_TOKEN');
// The shop cipher comes from the authorized-shops call.
$response = $shop->authorization->getAuthorizedShops();
foreach ($response->getData()->getShops() as $authorized) {
echo $authorized->getName(), ' ', $authorized->getRegion(), ' ', $authorized->getCipher(), PHP_EOL;
}

Every request is signed, timestamped and sent with your access token. With a shop cipher, the operations that need one work too; see calling the API.

  • Authorization: TikTokShopAuth, authorization URLs, token exchange, refresh and storing a TokenSet.
  • Calling the API: the client, API areas, many shops and the HTTP client.
  • Webhooks: Webhooks::verifyAndParse and typed events.
  • Errors: TikTokShopException and its codes.