PHPackages                             haianibrahim/tiktok-scraper - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. haianibrahim/tiktok-scraper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

haianibrahim/tiktok-scraper
===========================

Custom TikTok scraper for video posts, photo posts and user profiles (PHP 8, PSR-4, Guzzle)

v2.1.1(5d ago)0143GPL-3.0PHPPHP ^8.1

Since Aug 12Pushed 2w agoCompare

[ Source](https://github.com/haianibrahim/tiktok-scraper)[ Packagist](https://packagist.org/packages/haianibrahim/tiktok-scraper)[ RSS](/packages/haianibrahim-tiktok-scraper/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (5)Used By (0)

TikTok Custom PHP Scraper
=========================

[](#tiktok-custom-php-scraper)

[![GitHub Repo](https://camo.githubusercontent.com/ef94a3c51e4058f046bc090589ccddb4da0815169891fac64f9ab696b1b932d3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769744875622d74696b746f6b2d2d736372617065722d626c61636b3f6c6f676f3d676974687562)](https://github.com/haianibrahim/tiktok-scraper)[![GitHub Stars](https://camo.githubusercontent.com/31eb923131253a803a6eeeecdab0fd4be3ba773df41a7d9b199f53401f5041b6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f686169616e6962726168696d2f74696b746f6b2d73637261706572)](https://github.com/haianibrahim/tiktok-scraper/)[![Packagist Version](https://camo.githubusercontent.com/a00a956e9d6c237c6f3b4d3297acdcbe2518259ca74c2bbe4451000e746bc663/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686169616e6962726168696d2f74696b746f6b2d736372617065723f636f6c6f723d253233303038434646266c6f676f3d7061636b6167697374)](https://packagist.org/packages/haianibrahim/tiktok-scraper)[![PHP](https://camo.githubusercontent.com/df94ad74b504bf6f6a4d5ad17449f070d142c1e92428b567f7820e23348ff616/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d3737374242343f6c6f676f3d706870)](https://camo.githubusercontent.com/df94ad74b504bf6f6a4d5ad17449f070d142c1e92428b567f7820e23348ff616/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d3737374242343f6c6f676f3d706870)[![License](https://camo.githubusercontent.com/cf08f9d9c81e88957c30b8b0752a5e08ac3cc3c4b764aada8c341eee34a27238/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c2d2d332e302d626c7565)](https://camo.githubusercontent.com/cf08f9d9c81e88957c30b8b0752a5e08ac3cc3c4b764aada8c341eee34a27238/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c2d2d332e302d626c7565)[![Static Analysis](https://camo.githubusercontent.com/2b392591eb690c1ee8d511380acd01da480bee2b905808c7cfdd340f7f617d2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d31322d626c756576696f6c6574)](https://camo.githubusercontent.com/2b392591eb690c1ee8d511380acd01da480bee2b905808c7cfdd340f7f617d2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d31322d626c756576696f6c6574)

Scrape basic details from public TikTok video posts, photo posts and user profiles in PHP. This is a cleaned-up, PSR‑4, PHP 8 rewrite using Guzzle and zero private APIs.

Features
--------

[](#features)

- Public video posts (`/video/`): canonical URL, IDs, username, nickname, description, thumbnail and counters
- Public photo posts (`/photo/`): same normalized shape as videos
- Public user profiles: identity, avatars, bio, verification and follower/heart/video stats
- PSR‑4 autoloaded library with typed, immutable DTO output
- Pluggable Guzzle client for testing and timeouts
- No headless browser, no TikTok private API usage

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

[](#installation)

Install via Composer:

```
composer require haianibrahim/tiktok-scraper
```

Quick Start
-----------

[](#quick-start)

```
use GuzzleHttp\Client; // Or any ClientInterface
use Hki98\TikTok\TikTokScraper;

require __DIR__ . '/vendor/autoload.php';

$client = new Client();
$scraper = new TikTokScraper($client);

// Works for both video posts and photo posts
$details = $scraper->scrape('https://www.tiktok.com/@scout2015/video/6718335390845095173');

print_r($details->toArray());
```

Post output shape (`VideoDetails`):

- status: "ok"
- link
- user (nickname)
- username
- user\_id
- video\_id
- video\_desc
- thumbnail
- views, likes, comments, shares, favorites

Scraping User Profiles
----------------------

[](#scraping-user-profiles)

Fetch public profile information by bare username, `@username`, or a full profile URL:

```
use GuzzleHttp\Client;
use Hki98\TikTok\TikTokScraper;

require __DIR__ . '/vendor/autoload.php';

$scraper = new TikTokScraper(new Client());

$info = $scraper->scrapeUser('scout2015');
// Also valid: '@scout2015' or 'https://www.tiktok.com/@scout2015'

print_r($info->toArray());
```

Profile output shape (`UserInfo`):

- status: "ok"
- user\_id, sec\_uid, username, nickname
- signature (bio)
- avatar\_thumb, avatar\_medium, avatar\_larger
- verified, private\_account
- create\_time, region
- follower\_count, following\_count, heart\_count, video\_count, digg\_count, friend\_count
- profile\_url
- share\_title, share\_desc

API
---

[](#api)

- TikTokScraper::scrape(string $url): VideoDetails — video and photo posts
- TikTokScraper::scrapeUser(string $usernameOrUrl): UserInfo — user profiles
- VideoDetails::toArray(): array
- UserInfo::toArray(): array

Exceptions

- Base: Hki98\\TikTok\\Exception\\TikTokScraperException (catch-all)
- Specific:
    - Hki98\\TikTok\\Exception\\InvalidUrlException
    - Hki98\\TikTok\\Exception\\HttpRequestException
    - Hki98\\TikTok\\Exception\\EmptyResponseException
    - Hki98\\TikTok\\Exception\\ParseException

Notes
-----

[](#notes)

- TikTok frequently changes HTML structure; this scraper parses the rehydration JSON in a script tag. If the key paths change, update the normalization method.
- Respect robots.txt and terms of service in your jurisdiction.

Development
-----------

[](#development)

- PHP 8.1+
- PSR‑12 coding style recommended
- Autoload: PSR‑4 under namespace `Hki98\\TikTok` (src/)

Run autoload dump after cloning:

```
composer dump-autoload
```

Credit
------

[](#credit)

- Original author: Haian K. Ibrahim ()
- HTML parsing here is regex-based for one script tag; the bundled `simple_html_dom.php` is kept for historical context but not used by the new class.

License
-------

[](#license)

GPL-3.0

###  Health Score

43

↑

FairBetter than 89% of packages

Maintenance97

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~107 days

Total

4

Last Release

5d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/205984087?v=4)[Haian Ibrahim](/maintainers/haianibrahim)[@haianibrahim](https://github.com/haianibrahim)

---

Top Contributors

[![haianibrahim](https://avatars.githubusercontent.com/u/205984087?v=4)](https://github.com/haianibrahim "haianibrahim (7 commits)")

---

Tags

TikTok PHP scrapertiktok apitiktok-scrapertiktok php api

### Embed Badge

![Health badge](/badges/haianibrahim-tiktok-scraper/health.svg)

```
[![Health](https://phpackages.com/badges/haianibrahim-tiktok-scraper/health.svg)](https://phpackages.com/packages/haianibrahim-tiktok-scraper)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M45](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[oat-sa/tao-core

TAO core extension

66143.7k124](/packages/oat-sa-tao-core)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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