PHPackages                             ecomphp/tiktokshop-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ecomphp/tiktokshop-php

ActiveLibrary[API Development](/categories/api)

ecomphp/tiktokshop-php
======================

Unofficial Tiktok Shop API Client in PHP

v2.8.0(5mo ago)20766.9k—4.6%68[3 issues](https://github.com/EcomPHP/tiktokshop-php/issues)[1 PRs](https://github.com/EcomPHP/tiktokshop-php/pulls)Apache-2.0PHPPHP ^7.2|^8.0CI passing

Since Sep 20Pushed 5mo ago7 watchersCompare

[ Source](https://github.com/EcomPHP/tiktokshop-php)[ Packagist](https://packagist.org/packages/ecomphp/tiktokshop-php)[ RSS](/packages/ecomphp-tiktokshop-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (41)Used By (0)

TiktokShop API Client in PHP
============================

[](#tiktokshop-api-client-in-php)

[![Total Downloads](https://camo.githubusercontent.com/bdb085ca3498ec9d92e27aa6bbe590ad500b80d237d2c762c13641dee6f04b7f/68747470733a2f2f706f7365722e707567782e6f72672f65636f6d7068702f74696b746f6b73686f702d7068702f646f776e6c6f616473)](https://packagist.org/packages/ecomphp/tiktokshop-php)[![Latest Stable Version](https://camo.githubusercontent.com/d3d52e5139dd404760d4292e71feaf1ffc3f0d63c8fbf0913c8d34fad5474c0f/68747470733a2f2f706f7365722e707567782e6f72672f65636f6d7068702f74696b746f6b73686f702d7068702f762f737461626c65)](https://packagist.org/packages/ecomphp/tiktokshop-php)[![Latest Unstable Version](https://camo.githubusercontent.com/979c313176dbba1ee4929ed730cdab0c8e68a1c2ae8a91dfd63716a2d2600128/68747470733a2f2f706f7365722e707567782e6f72672f65636f6d7068702f74696b746f6b73686f702d7068702f762f756e737461626c65)](https://packagist.org/packages/ecomphp/tiktokshop-php)[![Build Status](https://camo.githubusercontent.com/38d0742abac62c71ac82f8a0711d8fa8358039777d23888061b40dd029948e42/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f65636f6d7068702f74696b746f6b73686f702d7068702f63692e796d6c3f6272616e63683d6d6173746572266c6162656c3d63692532306275696c64267374796c653d666c61742d737175617265)](https://github.com/ecomphp/tiktokshop-php/actions?query=workflow%3ATest)[![License](https://camo.githubusercontent.com/6ed1038d8c960b1bd632ca6aeab0f7c82f2971123e63a222018f2311ddbb96ba/68747470733a2f2f706f7365722e707567782e6f72672f65636f6d7068702f74696b746f6b73686f702d7068702f6c6963656e7365)](https://packagist.org/packages/ecomphp/tiktokshop-php)

Tiktok Shop API Client is a simple SDK implementation of Tiktok Shop API.

Since v2.x, library used API version 202309 and later. For older API version, please use v1.x

Installation
------------

[](#installation)

Install with Composer

```
composer require ecomphp/tiktokshop-php
```

Configure TiktokShop PHP Client
-------------------------------

[](#configure-tiktokshop-php-client)

```
use EcomPHP\TiktokShop\Client;

$app_key = 'your app key';
$app_secret = 'your app secret';

$client = new Client($app_key, $app_secret);
```

Grant token
-----------

[](#grant-token)

There is a Auth class to help you getting the token from the shop using oAuth.

```
$auth = $client->auth();
```

1. Create the authentication request

```
$_SESSION['state'] = $state = str_random(40); // random string
$auth->createAuthRequest($state);
```

> If you want the function to return the authentication url instead of auto-redirecting, you can set the argument $return (2nd argument) to true.

```
$authUrl = $auth->createAuthRequest($state, true);

// redirect user to auth url
header('Location: '.$authUrl);
```

2. Get authentication code when redirected back to `Redirect callback URL` after app authorization and exchange it for access token

```
$authorization_code = $_GET['code'];
$token = $auth->getToken($authorization_code);

$access_token = $token['access_token'];
$refresh_token = $token['refresh_token'];
```

3. Get authorized Shop cipher

```
$access_token = $token['access_token'];
$client->setAccessToken($access_token);

$authorizedShopList = $client->Authorization->getAuthorizedShop();

// extract shop_id & cipher from $authorizedShopList for use later
```

Refresh your access token
-------------------------

[](#refresh-your-access-token)

> Access token will be expired soon, so you need refresh new token by using `refresh_token`

```
$new_token = $auth->refreshNewToken($refresh_token);

$new_access_token = $new_token['access_token'];
$new_refresh_token = $new_token['refresh_token'];
```

Usage API Example
-----------------

[](#usage-api-example)

> You need `access_token` and `shop_cipher` to start using TiktokShop API

```
$client = new Client($app_key, $app_secret);
$client->setAccessToken($access_token);
$client->setShopCipher($shop_cipher);
```

- Get product list: [api document](https://developers.tiktok-shops.com/documents/document/237487)

```
$products = $client->Product->getProductList([
    'page_size' => 50,
]);
```

- Get order list: [api document](https://developers.tiktok-shops.com/documents/document/237434)

```
$orders = $client->Order->getOrderList([
    'order_status' => 100, // Unpaid order
    'page_size' => 50,
]);
```

Change API version
------------------

[](#change-api-version)

> As default, API version 202309 will be used in every api call. Use example below to change it

```
$products = $client->Product->useVersion('202312')->checkListingPrerequisites();
```

Webhook
-------

[](#webhook)

Use webhook to receive incoming notification from tiktok shop

```
$webhook = $client->webhook();
```

or manually configure the webhook receiver

```
use EcomPHP\TiktokShop\Webhook;
use EcomPHP\TiktokShop\Errors\TiktokShopException;

$webhook = new Webhook($client);
try {
    $webhook->verify();
    $webhook->capture($_POST);
} catch (TiktokShopException $e) {
    echo "webhook error: " . $e->getMessage() . "\n";
}
```

```
echo "Type: " . $webhook->getType() . "\n";
echo "Timestamp: " . $webhook->getTimestamp() . "\n";
echo "Shop ID: " . $webhook->getShopId() . "\n";
echo "Data: \n"; // data is array
print_r($webhook->getData());
```

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance72

Regular maintenance activity

Popularity51

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 55.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Recently: every ~95 days

Total

39

Last Release

159d ago

Major Versions

v1.2.0 → v2.0.02023-10-31

PHP version history (2 changes)v1.0.0PHP &gt;=7.1

v1.1.4PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7086b3bf4e8970e697e84056b9eff99021a395697375cc1f03b3bafea63f3972?d=identicon)[nVuln](/maintainers/nVuln)

---

Top Contributors

[![nVuln](https://avatars.githubusercontent.com/u/54855446?v=4)](https://github.com/nVuln "nVuln (25 commits)")[![marcum8er](https://avatars.githubusercontent.com/u/119655028?v=4)](https://github.com/marcum8er "marcum8er (7 commits)")[![fgmpr](https://avatars.githubusercontent.com/u/90197805?v=4)](https://github.com/fgmpr "fgmpr (4 commits)")[![snake-fl](https://avatars.githubusercontent.com/u/13670862?v=4)](https://github.com/snake-fl "snake-fl (3 commits)")[![aquariuscool](https://avatars.githubusercontent.com/u/192296?v=4)](https://github.com/aquariuscool "aquariuscool (3 commits)")[![kamil-fityka](https://avatars.githubusercontent.com/u/113036300?v=4)](https://github.com/kamil-fityka "kamil-fityka (1 commits)")[![febrihidayan](https://avatars.githubusercontent.com/u/42211742?v=4)](https://github.com/febrihidayan "febrihidayan (1 commits)")[![alvgalrus](https://avatars.githubusercontent.com/u/4166199?v=4)](https://github.com/alvgalrus "alvgalrus (1 commits)")

---

Tags

api-clientphpsdktiktok-apitiktok-shoptiktok-shop-apitiktokshop

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ecomphp-tiktokshop-php/health.svg)

```
[![Health](https://phpackages.com/badges/ecomphp-tiktokshop-php/health.svg)](https://phpackages.com/packages/ecomphp-tiktokshop-php)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
