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

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

robert-grubb/tiktok-php
=======================

TikTok Scraper in PHP

v1.9.16(2y ago)03.5k↓100%MITPHPPHP &gt;=5.4.0

Since Jun 8Pushed 2y agoCompare

[ Source](https://github.com/femtoeu/tiktok-php)[ Packagist](https://packagist.org/packages/robert-grubb/tiktok-php)[ Docs](https://github.com/RobertGrubb/tiktok-php)[ RSS](/packages/robert-grubb-tiktok-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (39)Used By (0)

TikTok Scraper in PHP
=====================

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

```
By default, this scraper will attempt to use NodeJS to sign the URL. If you do not have node installed, it will attempt to install it during the composer install step. If you do, it will simply find the path to it. If you'd like to change this logic, you can read more below about setting your signMethod => 'datafetch', an API I have created for signing tiktok urls.

```

1.9.14
======

[](#1914)

Updates to the `user->account` method have been made. No changes in the response object.

1.9.13
======

[](#1913)

Introducing `$scraper->user->videoFromEmbed('id');`

This will return video data from the embed endpoint. Right now it's more stable than the normal video route. The only catch is that it does not return

1.9.12
======

[](#1912)

Setting verifyFp manually is now an option, as captcha verification has been taking TikTok by storm. You can set it like so:

```
$scraper = new Scraper([
  'verifyFp' => 'verify_xxxxx_xxxx_xxxx_xxx...'
])

```

If you do not set one, by default, the scraper will attempt to generate the following cookies for you:

```
verifyFp, tt_webid, and tt_webid_v2

```

However, in most cases at this moment, the fp token will end up being a trigger for captcha.

Cookie File
===========

[](#cookie-file)

In `v1.8.0`, the scraper now sets cookies by default, which means that you must provide writable permissions for a `cookies.json` file, and then set it in the configuration (see example config below).

Need to disable cookies? Set `'disableCookies' => true` in the configuration.

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

[](#installation)

```
composer require robert-grubb/tiktok-php

```

Instantiation
-------------

[](#instantiation)

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

use TikTok\Scraper;

// Instantiate TikTok Scraper library
$scraper = new Scraper([
  // Sign method
  'signMethod' => 'datafetch'
  'datafetchApiKey' => ''
  'userAgent' => '',
  'proxy' => [
    'protocol' => 'http',
    'address' => '127.0.0.1:8080',
    'auth' => 'username:password'
  ],
  'timeout' => 20,

  // Since v1.8.0 (Must set cookie file)
  'cookieFile' => __DIR__ . '/cookies.json'

  // If not using cookies:
  'disableCookies' => true
]);

```

Configuration Explained
-----------------------

[](#configuration-explained)

```
[
  // Sign method
  'signMethod' => 'node' // Or datafetch

  // User agent
  'userAgent' => '',

  // Optional proxy (auth is also optional)
  'proxy' => [
    'protocol' => 'http',
    'address' => '127.0.0.1:8080',
    'auth' => 'username:password'
  ],

  // Time before curl request times out
  'timeout' => 20
]

```

Search for a user
-----------------

[](#search-for-a-user)

```
// 30 being the number of results
$scraper->user->search('username', 30);

```

User data
---------

[](#user-data)

```
$scraper->user->details('username');

```

User videos
-----------

[](#user-videos)

```
$scraper->user->videos(123415125125);

// Or use username, 10 is the count of videos to return.
$scraper->user->videos('iratee', 10);

```

All User Videos
---------------

[](#all-user-videos)

```
$scraper->user->allVideos(123415125125);

// Or use username
$scraper->user->allVideos('iratee');

```

Specific User Video
-------------------

[](#specific-user-video)

```
$scraper->user->video('username', 123415125125);

```

Download User Video
-------------------

[](#download-user-video)

```
/**
 * 1st Param: username
 * 2nd Param: video_id
 * 3rd Param: watermark (default true)
 * 4th Param: path to download
 */
$scraper->user->downloadVideo('username', 123415125125, true, './');

```

Discover
--------

[](#discover)

```
$scraper->discover->get('music');
$scraper->discover->get('user');
$scraper->discover->get('hashtag');

// Offset and count:

$scraper->general->discover('music', [
  'count' => 10,
  'offset' => 10
]);

```

Trending
--------

[](#trending)

```
// 25 being the number of items to return.
$scraper->trending->videos(25);

```

Music Data
----------

[](#music-data)

```
// Gets data for music by id
$scraper->music->data(12312512512);

```

Music Videos
------------

[](#music-videos)

```
// Gets videos for music (25 being the count)
$scraper->music->videos(12124124124, 25)

```

Download Music by ID
--------------------

[](#download-music-by-id)

```
/**
 * 1st Param: music_id
 * 2nd Param: path (optional)
 * 3rd Param: custom name (optional)
 */
$scraper->music->download(6821468236035541766, './', 'custom-name');

```

Hashtag Data
------------

[](#hashtag-data)

```
$scraper->hashtag->data('beatbox');

```

Hashtag Videos
--------------

[](#hashtag-videos)

```
// 30 being the count of videos to return
$scraper->hashtag->videos('beatbox', 30);

```

Signing a URL
-------------

[](#signing-a-url)

2 methods of signing the URL is provided.

1. You can use nodejs, this package will look to see if you have it installed, however, if you do not, it will attempt to install it.
2. You can use the datafet.ch api that I have personally built to accept requests from anyone to sign a tiktok url. (This package handles it automatically if you set `'signMethod' => 'datafetch'` in the configuration.)

```
$scraper->signUrl('TIKTOK_URL_HERE');

```

DataFetch API Key
-----------------

[](#datafetch-api-key)

DataFetch API does rate limit your requests at a max of 100 requests per 15 minutes. This can be avoided by obtaining an API key, which will then give you access to unlimited requests. You can obtain access by contacting me at `matt [at] grubb [dot] com`.

Errors
======

[](#errors)

If anything error happens throughout the scraper, it will set the error at the following:

```
$scraper->error

```

Which will return the following structure:

```
[
  'error' => true,
  'message' => 'Detailed error message here.'
]

```

Also, the method you called will also return `false`.

---

If there was no error, two things you will notice:

1. `$scraper->error` is set to `false`
2. The method you called will not return `false`

Legal
=====

[](#legal)

This repo and it's contents are in no way affiliated with, authorized, maintained, sponsored or endorsed by TikTok or any of its affiliates or subsidiaries. This is an independent and unofficial package. Use at your own risk.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 99% 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 ~37 days

Recently: every ~307 days

Total

38

Last Release

770d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b567f9c60ff84df54500d95bf131baf5e01cc99d55449a78aed437dfbad5d57d?d=identicon)[RobertGrubb](/maintainers/RobertGrubb)

---

Top Contributors

[![RobertGrubb](https://avatars.githubusercontent.com/u/13295554?v=4)](https://github.com/RobertGrubb "RobertGrubb (96 commits)")[![femtoeu](https://avatars.githubusercontent.com/u/98698729?v=4)](https://github.com/femtoeu "femtoeu (1 commits)")

---

Tags

scraperTikTok

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/robert-grubb-tiktok-php/health.svg)

```
[![Health](https://phpackages.com/badges/robert-grubb-tiktok-php/health.svg)](https://phpackages.com/packages/robert-grubb-tiktok-php)
```

###  Alternatives

[raiym/instagram-php-scraper

Instagram PHP Scraper. Get account information, photos and videos without any authorization

3.3k1.2M6](/packages/raiym-instagram-php-scraper)[vdb/php-spider

A configurable and extensible PHP web spider

1.4k181.0k7](/packages/vdb-php-spider)[nelexa/google-play-scraper

Scrapes app data from Google Play store.

88487.4k](/packages/nelexa-google-play-scraper)[crwlr/crawler

Web crawling and scraping library.

37214.8k2](/packages/crwlr-crawler)[raulr/google-play-scraper

A PHP scraper to get app data from Google Play

12892.7k](/packages/raulr-google-play-scraper)

PHPackages © 2026

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