Api tik tok php
This is an unofficial TypeScript and Node.js implementation of the TikTok API. This module is not endorsed by, directly affiliated with, maintained, authorized, or sponsored by TikTok. Their internal API could change at any moment, and break this module’s code. I try my best to maintain it, and keep it up-to-date. If you find bugs or have any questions, please submit an issue, and I will try my best to help you out.
Get the follower count of a TikTok user:
Get the tags of the top trending videos:
Take a look at tiktok-web-api-example for an up-to-date web API using this module.
Import into your program.
At the moment, the majority of the API returns promises, and may throw errors in certain situations. When a promise is not returned, or if a function may throw an error, it will be mentioned.
To start using the API, you must first instantiate an instance of the application.
While instantiating a new instance of the application, the application’s settings will be set up.
If you would like to use your own signature service instead of the default option, you can specify this in a TikTokOptions object. See TikTokOptions for a definition of the TikTokOptions object.
Throughout the API, you may want to modify the starting point or count of a request. This is possible by specifying a SearchOptions object in a request. See SeachOptions for a definition of the SearchOptions object.
Any request which takes a SearchOptions object will return an async iterator, which will lazily load the next batch of videos when requested.
To get the top trending videos using the API is as simple as:
To retrieve User information within the API, you will first need to get a User object. See User for a definition of the User object.
Get a User object from a TikTok user’s username:
Will fetch ID of user from TikTok API. May throw an error in certain situations, see here.
Get a User object from a TikTok user’s id:
Will not fetch username of user from TikTok API.
Take note that getUserByID(id) does not return a promise, as it does not fetch any information from the TikTok API.
Now that we have a User object, we can retrieve some information from the TikTok user:
See UserInfo for a defintion of the UserInfo object. May throw an error in certain situations, see here.
Now, let’s get the user’s uploaded videos:
See VideoInfo for a definition of the VideoInfo object. May throw an error in certain situations, see here.
Same idea, we can get the user’s liked videos:
May throw an error in certain situations, see here.
That covers users. Let’s move on to TikTok videos.
Just like how previously we needed our User object, we now need our Video object. See Video for a definition of the Video object.
Take note that getVideo(id) does not return a promise, as it does not fetch any information from the TikTok API.
Now to get the information of this video:
May throw an error in certain situations, see here.
That’s all there is for videos, for now. Now on to Tiktok audios.
Just like Users and Videos, we first need an Audio object.
Take note that getAudio(id) does not return a promise, as it does not fetch any information from the TikTok API.
To get the information related to the audio:
See AudioInfo for a definition of the AudioInfo object. May throw an error in certain situations, see here.
To get the top videos related to an audio:
The first object of this VideoInfo array will be the original video with the audio. May throw an error in certain situations, see here.
Finally we have TikTok tags.
Just like Users, Videos, and Audios, we need a Tag object.
Will fetch the title from the TikTok API, therefore this function returns a promise. May throw an error in certain situations, see here.
To retrieve the information associated with the tag:
See TagInfo for a definition of the TagInfo object. May throw an error in certain situations, see here.
To get the top videos of a tag:
May throw an error in certain situations, see here.
Below you will find the data that each object contains.
Api tik tok php
Unofficial TikTok API
A fully managed hassle-free TikTok API solution with OAuth capabilities. You can get started instantly, all you need is an API Key.
Note: Spam/Abuse/Follower selling services are strictly not allowed.
Public endpoints do not require an user authorization
Get user profile information
GET /public/check
| Parameter | Location | Required | Description |
|---|---|---|---|
| username | query | true | The TikTok account username |
| secUid | query | false | The TikTok user secUid |
Response
Get recommended posts
GET /public/explore
| Parameter | Location | Required | Description |
|---|---|---|---|
| count | query | false |
Get posts of an user
GET /public/posts
| Parameter | Location | Required | Description |
|---|---|---|---|
| secUid | query | true | The user secUid |
| count | query | false | |
| cursor | query | false |
Response
Get liked posts of an user
GET /public/likes
| Parameter | Location | Required | Description |
|---|---|---|---|
| secUid | query | true | The user secUid |
| count | query | false | |
| cursor | query | false |
Get a video information/ Download a video
GET /public/video
| Parameter | Location | Required | Description |
|---|---|---|---|
| id | query | true | The video ID |
| username | query | false | The author username |
| download | query | false | Set this to 1 to get a mp4 file |
Search users, music, hashtags
GET /public/discover/users
| Parameter | Location | Required | Description |
|---|---|---|---|
| keyword | query | false | |
| count | query | false | |
| cursor | query | false |
GET /public/discover/music
| Parameter | Location | Required | Description |
|---|---|---|---|
| keyword | query | false | |
| count | query | false | |
| cursor | query | false |
Response
GET /public/discover/hashtag
| Parameter | Location | Required | Description |
|---|---|---|---|
| keyword | query | false | |
| count | query | false | |
| cursor | query | false |
Response
Get posts by hashtag ID.
Note: You can send the first request using the hashtag name («name») then get the ID.
GET /public/hashtag
| Parameter | Location | Required | Description |
|---|---|---|---|
| id | query | false | The hashtag ID |
| mame | query | false | The hashtag name |
| count | query | false | |
| cursor | query | false | The starting point of items list |
Response
Get posts by music ID.
GET /public/music
| Parameter | Location | Required | Description |
|---|---|---|---|
| id | query | true | The hashtag ID |
| count | query | false | |
| cursor | query | false | The starting point of items list |
Response
The user endpoints require an accountKey
Get current user profile information
GET /user/info
| Parameter | Location | Required | Description |
|---|
Response
Edit the user profile
POST /user/edit
| Parameter | Location | Required | Description |
|---|---|---|---|
| nickname | body | false | |
| username | body | false | |
| bio | body | false | |
| privacy | body | false |
Response
Get user notifications
GET /user/notifications
| Parameter | Location | Required | Description |
|---|---|---|---|
| filter | query | false | |
| count | query | false | |
| max_time | query | false | |
| min_time | query | false |
Get followers list
GET /user/followers
| Parameter | Location | Required | Description |
|---|---|---|---|
| count | query | false | |
| max_time | query | false | |
| min_time | query | false |
Get following list
GET /user/following
| Parameter | Location | Required | Description |
|---|---|---|---|
| count | query | false | |
| cursor | query | false |
POST /user/follow
| Parameter | Location | Required | Description |
|---|---|---|---|
| username | body | true | |
| user_id | body | true |
Response
POST /user/follow
| Parameter | Location | Required | Description |
|---|---|---|---|
| username | body | true | |
| user_id | body | true | The user ID |
Response
Get user feed posts
GET /user/feed
| Parameter | Location | Required | Description |
|---|---|---|---|
| count | query | false | |
| cursor | query | false | |
| secUid | query | false |
Get user liked posts
GET /user/likes
| Parameter | Location | Required | Description |
|---|---|---|---|
| count | query | false | |
| id | query | false | |
| secUid | query | false | |
| max_time | query | false | |
| min_time | query | false |
Get recommended posts
GET /user/explore
| Parameter | Location | Required | Description |
|---|---|---|---|
| count | query | false |
Get video information/Download video
GET /public/video
| Parameter | Location | Required | Description |
|---|---|---|---|
| id | query | true | The video ID |
| download | query | false |
POST /user/like
| Parameter | Location | Required | Description |
|---|---|---|---|
| media_id | body | true | The video ID |
Response
POST /user/like
| Parameter | Location | Required | Description |
|---|---|---|---|
| media_id | body | true | The video ID |
Response
Get a video comments list
GET /comment/list
| Parameter | Location | Required | Description |
|---|---|---|---|
| media_id | query | true | The video ID |
| count | query | false | |
| cursor | query | false | |
| author_id | query | false | |
| author_username | query | false |
Get a comment reply list
GET /comment/reply/list
| Parameter | Location | Required | Description |
|---|---|---|---|
| media_id | query | true | The video ID |
| comment_id | query | true | The comment ID |
| count | query | false |
Post a new comment
POST /user/comment
| Parameter | Location | Required | Description |
|---|---|---|---|
| media_id | body | true | The video ID |
| text | body | true | |
| reply_comment_id | body | false | You can reply to a comment by including a comment ID |
| has_tags | body | false | |
| author_id | body | false | |
| author_username | body | false |
Response
POST /user/comment/like
| Parameter | Location | Required | Description |
|---|---|---|---|
| media_id | body | true | The video ID |
| comment_id | body | true | The comment ID |
| author_id | body | false | |
| author_username | body | false |
Response
POST /user/comment/unlike
| Parameter | Location | Required | Description |
|---|---|---|---|
| media_id | body | true | The video ID |
| comment_id | body | true | The comment ID |
| author_id | body | false | |
| author_username | body | false |
Response
Get user conversations
GET /user/conversations
| Parameter | Location | Required | Description |
|---|---|---|---|
| cursor | query | false |
Response
GET /user/messages
| Parameter | Location | Required | Description |
|---|---|---|---|
| conversationId | query | true | |
| conversationShortId | query | true | |
| cursor | query | false | |
| limit | query | false |
Response
Start a live video
POST /user/live/start
| Parameter | Location | Required | Description |
|---|---|---|---|
| title | body | true |
Response
POST /user/live/stop
| Parameter | Location | Required | Description |
|---|
Response
Get a live video information
GET /user/live/check
| Parameter | Location | Required | Description |
|---|---|---|---|
| room_id | query | true |
Response
Get recommended live videos based on a live video
GET /user/live/recommend
| Parameter | Location | Required | Description |
|---|---|---|---|
| room_id | query | true |
Response
Get a ended live video statistics
GET /user/live/stats
| Parameter | Location | Required | Description |
|---|---|---|---|
| room_id | query | true |
Response
GET /user/live/enter
| Parameter | Location | Required | Description |
|---|---|---|---|
| room_id | query | true |
Response
GET /user/search
| Parameter | Location | Required | Description |
|---|---|---|---|
| query | query | true |
Get analytics for creator accounts
GET /creator/analytics/overview
| Parameter | Location | Required | Description |
|---|---|---|---|
| days | query | false |
Response
GET /creator/analytics/videos
| Parameter | Location | Required | Description |
|---|---|---|---|
| days | query | false |
Response
GET /creator/analytics/video
| Parameter | Location | Required | Description |
|---|---|---|---|
| days | query | false | |
| media_id | query | true |
Response
GET /creator/analytics/followers
| Parameter | Location | Required | Description |
|---|---|---|---|
| days | query | false |
Response
GET /creator/analytics/live
| Parameter | Location | Required | Description |
|---|---|---|---|
| days | query | false |
Response
This code is 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 API. Use at your own risk.
Api tik tok php
Unofficial TikTok API library for PHP
Unofficial TikTok API for PHP
Installation via Composer
composer require ssovit/tiktok-api
Looking for Watermark-less video API?
It’s available on monthly subscription. See below for plans and contact details.
Follow examples in /example directory
You can build your own engine that will store and fetch cache from your local storage to prevent frequent requests to TikTok server. This can help being banned from TikTok server for too frequent requests.
Cache engine should have callable get and set methods that the API class uses
Usage
Stream and Download videos
Follow examples on /example folder for video stream and download example Note: TikTok videos will not play directly when used in HTML video player as they require www.tiktok.com as http referrer.
It’s highly recommended to use Rotating Proxy service if you are making lots of requests in short interval of time. Webshare.io Proxy Service is good. It’s my referral link and I would get a bit from it
Non-watermarked video url for newer videos
TikTok videos don’t have video id as meta data on watermarked video posted after
24-28 July 2020. Check below for subscription plans for non watermarked video API.
Pirvate API server subscription pricing
| Package | Cost(per month) | Quota(requests per day) | Quota (requests per month) |
|---|---|---|---|
| Basic | 20 USD | 2,000 | |
| Pro (popular) | 50 USD | 5,000 | |
| Mega | 100 USD | 12,000 | |
| Ultra | custom pricing | ? | ? |
Looking for api source code?
Source code for TikTok Mobile App API available.
Available variations
Private APP API wrapper
Use issues ticket if you have questions regarding this library. Only inquiries regarding private API or custom works will be responded.
Use proxy. You are making too many API requests in short interval of time. Rotating proxy is recommended.
Want to improve this library? Want to contribute?
Don’t hesitate to create pull requests.
TikTok is always updating their API endpoints but I will try to keep this library whenever possible. I take no responsibility if you or your IP gets banned using this API. It’s recommended that you use proxy.
About
Unofficial TikTok API for PHP. Join our Discord server
Api tik tok php
Unofficial TikTok/Musical.ly API
This project is no longer maintained.
A reverse-engineered implementation of the TikTok (previously musical.ly) app’s API.
Creating an instance
Authenticates you with the API and stores your session data in a cookie jar. Subsequent requests will include these cookies.
See the login types for the response data.
Authenticates you with the API and stores your session data in a cookie jar. Subsequent requests will include these cookies.
See the login types for the response data.
Gets a user’s profile.
See the user types for the response data.
Searches for users.
See the search types for the complete request/response objects.
Gets the QR code for a user.
See the QR code types for the complete request/response objects.
See the post types for the complete response object.
Lists a user’s posts.
See the post types for the complete request/response objects.
Lists the users that follow the specified user.
See the follower types for the complete request/response objects.
Lists the users that the specified user follows.
See the following types for the complete request/response objects.
See the follow types for the response data.
Stops following a user.
See the follow types for the response data.
Lists the users that have requested to follow the logged in user.
See the follow types for the complete request/response objects.
Approves a user’s request to follow you.
See the follow types for the response data.
Rejects a user’s request to follow you.
See the follow types for the response data.
Lists comments for a post.
See the comment types for the response data.
.postComment(postId, text, )
Comments on a post.
See the comment types for the response data.
Lists popular categories/hashtags.
See the category types for the complete request/response objects.
Searches for hashtags.
See the search types for the complete request/response objects.
Lists posts in a hashtag.
See the hashtag types for the complete request/response objects.
Lists posts in the For You feed.
See the feed types for the complete request/response objects.
Lists posts in the Following feed.
See the feed types for the complete request/response objects.
Gets information about a sticker/effect.
See the sticker types for the complete response object.
Gets information about many stickers/effects.
See the sticker types for the complete response object.
Lists posts that use a sticker/effect.
See the sticker types for the complete request/response object.
Joins a live stream.
The rtmp_pull_url value can be used with VLC’s Open Network Stream option.
See the live stream types for the response data.
Leaves a live stream.
Determines if the current user is allowed to start a live stream.
See the live stream types for the response data.
Keep note of the room_id and stream_id properties because you will need them to end the live stream.
The rtmp_push_url value can be used with streaming applications such as OBS.
See the live stream types for the response data.
Ends a live stream.
You must call this method to so you are no longer marked as «live» in the app.
Creates a room to host a live stream.
The rtmp_push_url value can be used with streaming applications such as OBS.
Note: This method only creates the room for the live stream. You’ll need to call updateLiveStreamStatus to mark the stream as started. See startLiveStream for a helper method that makes these calls for you.
See the live stream types for the response data.
Updates the status of a live stream.
See the live stream types for the complete request/response objects.
This code is 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 API. Use at your own risk.