# tiktok-private-api

> Unofficial TikTok Private API SDK for Python. Full mobile signing, 50+ endpoints, Android + iOS.

## Install

```
pip install tiktok-private-api
```

## Quick Start

```python
from tiktokflow import TikTokAPI

api = TikTokAPI()  # trial: 10 requests/day, no key needed
# or: api = TikTokAPI(api_key="sk_...")  # unlimited

feed = api.feed.for_you(count=5)
for video in feed["aweme_list"]:
    print(video["desc"], video["statistics"]["digg_count"], "likes")
```

## Available Endpoints

### Feed
- `api.feed.for_you(count)` — For You page
- `api.feed.following(count)` — Following feed
- `api.feed.user_posts(sec_user_id)` — User's videos
- `api.feed.hashtag(ch_id)` — Hashtag feed
- `api.feed.music(music_id)` — Music/sound feed

### User
- `api.user.info(sec_user_id)` — User profile
- `api.user.profile_self()` — Own profile
- `api.user.followers(sec_user_id)` — Follower list
- `api.user.following(sec_user_id)` — Following list
- `api.user.search(keyword)` — Search users
- `api.user.block_list()` — Blocked users

### Video
- `api.video.detail(aweme_id)` — Video info + stats
- `api.video.multi_detail(ids)` — Batch video info
- `api.video.my_posts()` — Own posted videos
- `api.video.favorites()` — Liked videos
- `api.video.delete(aweme_id)` — Delete own video

### Social Actions (Write)
- `api.social.like(aweme_id)` — Like a video
- `api.social.unlike(aweme_id)` — Unlike
- `api.social.follow(user_id)` — Follow a user
- `api.social.unfollow(user_id)` — Unfollow
- `api.social.block(user_id)` — Block a user
- `api.social.unblock(user_id)` — Unblock

### Comments (Read + Write)
- `api.comment.list(aweme_id)` — Get comments
- `api.comment.replies(comment_id)` — Get replies
- `api.comment.publish(aweme_id, text)` — Post comment
- `api.comment.delete(comment_id)` — Delete comment
- `api.comment.like(comment_id)` — Like comment

### Search
- `api.search.general(keyword)` — General search
- `api.search.users(keyword)` — Search users
- `api.search.videos(keyword)` — Search videos
- `api.search.music(keyword)` — Search music
- `api.search.hashtags(keyword)` — Search hashtags
- `api.search.live(keyword)` — Search lives

### Music
- `api.music.detail(music_id)` — Music/sound info
- `api.music.videos(music_id)` — Videos using sound

### Direct Messages
- `api.dm.conversations()` — Conversation list
- `api.dm.messages(conversation_id)` — Read messages
- `api.dm.unread_count()` — Unread count

### Live
- `api.live.search(keyword)` — Search live streams
- `api.live.enter(room_id)` — Enter live room

### Account
- `api.passport.email_login(email, pw)` — Email login
- `api.passport.sms_login(phone, code)` — SMS login
- `api.passport.register(email, pw)` — Register account
- `api.passport.logout()` — Logout

## Configuration

```python
api = TikTokAPI(
    api_key="sk_...",              # optional for trial
    platform="android",            # or "ios"
    proxy="socks5://user:pass@host:1080",
    proxies=["socks5://..."],      # list for rotation
    proxy_rotate="round_robin",    # or "random"
    rate_limit=2.0,                # max req/sec
    timeout=30.0,
)
```

## Response Format

All endpoints return raw TikTok JSON. Common fields:
- `aweme_list` — list of video objects
- `user` / `user_list` — user objects
- `has_more` — pagination flag
- `max_cursor` — cursor for next page
- `statistics` — contains `digg_count`, `comment_count`, `share_count`, `play_count`

## Links

- PyPI: https://pypi.org/project/tiktok-private-api/
- GitHub: https://github.com/molkex/tiktok-private-api
- Contact: https://t.me/mxmtkchk
