jsonscraper / tiktok-api-php
TikTok Scraper API for PHP — typed response models, video, profiles, comments and search
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.4
- sergeykomlev/lazyjsonmapper: ^2.0.0
Requires (Dev)
None
Suggests
- ext-curl: Required for CURL handler support in requests
Provides
None
Conflicts
None
Replaces
None
README
Composer client with LazyJsonMapper response models and ready-to-run examples. Supports 54 TikTok Scraper API methods.
Package: jsonscraper/tiktok-api-php · Methods · Examples · Documentation
Quick start
1. Get your key from the TikTok API product page and set it on your server:
export JSONSCRAPER_TIKTOK_LICENSE_KEY='your-license-key'
2. Install the package:
composer require jsonscraper/tiktok-api-php:^0.1
3. Make a request:
<?php require __DIR__.'/vendor/autoload.php'; $client = new TikTokRESTAPI\TikTok(getenv('JSONSCRAPER_TIKTOK_LICENSE_KEY')); $client->setCacheTimeout(60); $response = $client->getUserInfo('therock'); if ($response->isOk() && $response->getTiktok()?->isUser()) { echo $response->getTiktok()->getUser()->getUniqueId(); }
The API payload is in tiktok. Live calls require a valid API license and may consume quota. Response examples and status handling.
Main methods
54 methods are available. Common starting points:
| What you need | Method |
|---|---|
| Read a profile | getUserInfo() |
| Read a video | getVideoByID() |
| Get a video download URL | getNoWatermarkUrl() |
| Read comments | getCommentsByID() |
| Search videos | searchVideo() |
| List profile videos | getUserFeed() |
Ready-to-run examples
- Read a profile.
- Read a video.
- Read comments.
- Search videos.
- List profile videos.
- Video, author, statistics and playback URL models.
Each example includes command-line parameters, key setup, timeouts, error handling and response output. Run it with --help first; this makes no API request.
Browse all 54 complete examples · Full method and parameter reference
Response models
The PHP client uses Guzzle + LazyJsonMapper. A response is an APIResponse with nested models and readable getters:
$video = $response->getTiktok()?->getAwemeDetail(); echo $video?->getAuthor()?->getNickname(); echo $video?->getStatistics()?->getPlayCount();
Model hierarchy and complete usage guide · All model classes
Configuration
Requests use a 30-second timeout by default. Configure caching and retries to fit your application's request budget. Keys are read from your server environment; redirects are disabled.
Configuration options, HTTP errors, caching and pagination · Full integration guide
Use with ChatGPT and Codex
Prefer an assistant connection? Use the separate TikTok MCP server. It accepts the same product API license and uses the normal API quota. MCP source and setup.
Access, pricing and support
The SDK source is MIT-licensed. Hosted API access requires a separate TikTok license. Check current plans and get access.
Service support · SDK issues · Changelog · MIT license
Development
composer test
Tests use a local/mock server and require no API key. A GitHub Actions template is available for optional automation.
The SDK has no installation or usage telemetry. README links use campaign parameters for website referral analytics. jsonscraper is independent and is not affiliated with TikTok.