Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit 82bde7e

Browse files
committed
initial
0 parents  commit 82bde7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+8583
-0
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
example/ export-ignore
2+
.github/ export-ignore
3+
phpdoc.dist.xml export-ignore
4+
docs export-ignore

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "composer" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"

.github/workflows/tag.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Create Tag
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: Klemensas/action-autotag@stable
12+
with:
13+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
/composer.lock
3+
/example
4+
/.phpdoc

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Sovit Tamrakar
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Unofficial TikTok Private API library for PHP
2+
API Wrapper for private API access
3+
4+
# Installation via Composer
5+
`composer require ssovit/tiktok-private-api`
6+
7+
# Looking for Watermark-less video API?
8+
It's available on monthly subscription. See below for plans and contact details.
9+
10+
# Usage
11+
Follow examples in `/example` directory
12+
13+
```php
14+
$api=new \Sovit\TikTokPrivate\Api(array(/* config array*/));
15+
16+
$trendingFeed=$api->getForYou($maxCursor=0);
17+
18+
$userData=$api->getUser("USER_ID");
19+
20+
$userFeed=$api->getUserFeed("USER_ID",$maxCursor=0);
21+
22+
$challenge=$api->getChallenge("CHALLENGE_ID");
23+
24+
$challengeFeed=$api->getChallengeFeed("CHALLENGE_ID",$maxCursor=0);
25+
26+
$musc=$api->getMusic("6798898508385585925");
27+
28+
$musicFeed=$api->getMusicFeed("6798898508385585925",$maxCursor=0);
29+
30+
$videoData=$api->getVideoByID("6829540826570296577");
31+
32+
$videoData=$api->getVideoByUrl("https://www.tiktok.com/@zachking/video/6829303572832750853");
33+
34+
// More to come
35+
36+
```
37+
38+
# Available Options
39+
```php
40+
$api=new \Sovit\TikTokPrivate\Api(array(
41+
"proxy" => '', // proxy in url format like http://username:password@host:port
42+
"cache_timeout" => 3600 // 1 hours cache timeout
43+
"cookie_file" => sys_get_temp_dir() . 'tiktok.json', // cookie file path
44+
"transform_result" => true, // false if you want to get json without transforming it to more readable json dict
45+
"api_key" => "API_KEY" // see below on how to get API key
46+
), $cache_engine=false);
47+
```
48+
49+
# Cache Engine
50+
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.
51+
52+
Cache engine should have callable `get` and `set` methods that the API class uses
53+
```php
54+
// Example using WordPress transient as cache engine
55+
Class MyCacheEngine{
56+
function get($cache_key){
57+
return get_transient($cache_key);
58+
}
59+
function set($cache_key,$data,$timeout=3600){
60+
return set_transient($cache_key,$data,$timeout);
61+
}
62+
}
63+
64+
```
65+
**Usage**
66+
```php
67+
$cache_engine=new MyCacheEngine();
68+
$api=new \Sovit\TikTokPrivate\Api(array(/* config array*/),$cache_engine);
69+
```
70+
71+
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](https://www.webshare.io/?referral_code=kv04mj5v4ubw) is good. *It's my referral link and I would get a bit from it*
72+
73+
# Available methods
74+
- `getForYou` - Get trending feed `getForYou($maxCursor)`
75+
- `getUser` - Get profile data for TikTok User `getUser($username)`
76+
- `getUserFeed` - Get user feed by ID `getUserFeed($user_id,$maxCursor)`
77+
- `getChallenge` - Get challenge/hashtag info `getChallenge($challenge)`
78+
- `getChallengeFeed` - Get challenge feed by ID `getChallengeFeed($challenge_id, $maxCursor)`
79+
- `getMusic` - Get music info `getMusic($music_id)`
80+
- `getMusicFeed` - Get music feed `getMusicFeed($music_id,$maxCursor)`
81+
- `getVideoByID` - Get video by ID `getVideoByID($video_id)`
82+
- `getVideoByUrl` - Get video by URL `getVideoByUrl($video_url)`
83+
84+
`$maxCursor` defaults to `0`, and is offset for results page. `maxCursor` for next page is exposed on current page call feed data.
85+
86+
87+
## Pirvate API server subscription pricing
88+
| Package | Cost(per month) | Quota(requests per day) | Quota (requests per month) |
89+
| ------- | :---------------: | --------------: | -----------------: |
90+
| **Pro** *(popular)* | 50 USD | 5,000 | ~150,000 |
91+
| **Mega** | 100 USD | 12,000 | ~360,000 |
92+
| **Ultra** | custom pricing | ? | ? |
93+
94+
95+
# Disclaimer
96+
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.

composer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "ssovit/tiktok-private-api",
3+
"description": "Unofficial TikTok Private API for PHP",
4+
"license": "MIT",
5+
"homepage": "https://github.com/ssovit/tiktok-private-api",
6+
"keywords": [
7+
"tiktok",
8+
"tiktok-api",
9+
"tiktok-app-api",
10+
"tiktok-scraper"
11+
],
12+
"authors": [
13+
{
14+
"name": "Sovit Tamrakar",
15+
"email": "sovit.tamrakar@gmail.com",
16+
"homepage": "https://github.com/ssovit/",
17+
"role": "Developer"
18+
}
19+
],
20+
"support": {
21+
"source": "https://github.com/ssovit/tiktok-private-api",
22+
"issues": "https://github.com/ssovit/tiktok-private-api/issues",
23+
"email": "sovit.tamrakar@gmail.com"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"Sovit\\": "lib"
28+
}
29+
},
30+
"require": {
31+
"guzzlehttp/guzzle": "^6.5 || ^7.0"
32+
},
33+
"type": "library",
34+
"archive": {
35+
"exclude": [
36+
"/example",
37+
"/docs",
38+
"/phpdoc.dist.xml",
39+
"/.github"
40+
]
41+
}
42+
}

0 commit comments

Comments
 (0)