# TikTok Posts API

> Get the videos and photo posts of a public TikTok account newest first, plus its reposts, liked videos, playlists and stories, as JSON with view, like, comment, share and save counts. 1 credit per page.

**Get the posts of a public TikTok account**, newest first, with caption, date, duration, cover, media URL, view / like / comment / share / save counts, music and hashtags. The same post shape comes back for reposts, liked videos and stories.

```
GET https://api.handlehaul.com/v1/tiktok/users/{user}/posts
GET https://api.handlehaul.com/v1/tiktok/users/{user}/reposts
GET https://api.handlehaul.com/v1/tiktok/users/{user}/liked
GET https://api.handlehaul.com/v1/tiktok/users/{user}/playlists
GET https://api.handlehaul.com/v1/tiktok/users/{user}/stories
```

- `GET /v1/tiktok/users/{user}/posts`: videos and photo posts, newest first (about 16 a page)
- `GET /v1/tiktok/users/{user}/reposts`: videos the account reposted (up to 30 a page)
- `GET /v1/tiktok/users/{user}/liked`: videos the account liked. Most accounts hide this list: the page is then empty and `meta.list_hidden` is `true`
- `GET /v1/tiktok/users/{user}/playlists`: public playlists (id, name, video count, cover)
- `GET /v1/tiktok/users/{user}/stories`: stories up right now (often empty: stories expire)

**Cost:** 1 credit per page (free from cache). Failed calls and private accounts are free.

**Handles and ids:** list endpoints work on the account's `secUid`. Send a handle we have not looked up in the last 7 days and we look it up first, which adds **1 credit** (`meta.lookup_credits`, `X-Credits-Lookup`). A `secUid`, a numeric id, a handle we already know and later pages never pay it. Every profile and list item returns `id` and `sec_uid`: store them.

## Parameters

| Parameter | In | Description |
|---|---|---|
| `user` | path | TikTok handle (`mila.studio`, with or without `@`), numeric user id, or `secUid` (`MS4wLjABAAAA…`). All digits means an id; write `@12345` for a handle made only of digits. |
| `cursor` | query | `pagination.next_cursor` from the previous page. |
| `fresh` | query | `true` skips the cache. |
| `raw` | query | `true` returns TikTok's own JSON in `data` instead of our fields (same price). |

## Response

```json
{
  "data": [
    {
      "id": "7300004256287789000",
      "url": "https://www.tiktok.com/@mila.studio/video/7300004256287789000",
      "caption": "Sample post 1 by @mila.studio #luna #fyp",
      "created_at": "2026-11-30T00:53:20.000Z",
      "media_type": "video",
      "duration_seconds": 15,
      "cover_url": "https://p16-sign.tiktokcdn-us.com/…/cover/7300004256287789000.jpeg",
      "play_url": "https://v16-webapp-prime.tiktok.com/…/7300004256287789000.mp4",
      "images": null,
      "counts": {
        "views": 499242,
        "likes": 29955,
        "comments": 998,
        "shares": 499,
        "saves": 1498
      },
      "author": {
        "id": "6800603536904605282",
        "sec_uid": "MS4wLjABAAAAFjCNJUq7pGOuS6YC8bTNAHRKWqIShz6s9C1EkRYtfRk",
        "handle": "mila.studio",
        "nickname": "Mila Studio",
        "avatar_url": "https://p16-sign.tiktokcdn-us.com/…/avatar/6800603536904605282~c5_1080x1080.jpeg",
        "is_verified": false,
        "is_private": false,
        "url": "https://www.tiktok.com/@mila.studio",
        "counts": {
          "followers": 340593,
          "following": 913,
          "likes": 10558383,
          "videos": 933
        }
      },
      "music": {
        "id": "7200000000000000000",
        "title": "original sound",
        "artist": "Mila Studio",
        "is_original": true,
        "duration_seconds": 30,
        "cover_url": "https://p16-sign.tiktokcdn-us.com/…/music/7200000000000000000~c5_720x720.jpeg",
        "play_url": "https://v16-webapp-prime.tiktok.com/…/music/7200000000000000000.mp3",
        "post_count": null,
        "url": "https://www.tiktok.com/music/original-sound-7200000000000000000"
      },
      "hashtags": [
        "luna",
        "fyp"
      ],
      "mentions": [],
      "language": "en",
      "location": null,
      "has_captions": true,
      "is_ad": false
    }
  ],
  "pagination": {
    "next_cursor": "eyJ2…sealed…",
    "has_more": true,
    "page_size": 16
  },
  "meta": {
    "request_id": "req_…",
    "cached": false,
    "cache_age_seconds": 0,
    "credits_charged": 1,
    "credits_remaining": 26943
  }
}
```

- `media_type` is `video` or `photo`; photo posts list their slides in `images` and have no `play_url`.
- `play_url` is a short-lived TikTok media URL; TikTok's CDN may refuse it outside a browser. Use it promptly or fetch the post again.
- `has_captions` tells you whether [the transcript endpoint](/docs/tiktok-transcript-api) will find text.
- TikTok sometimes returns a short or empty page while `has_more` is still `true`: follow `next_cursor`, not the page size.

## Examples

```bash
curl "https://api.handlehaul.com/v1/tiktok/users/mila.studio/posts" -H "X-Api-Key: $HANDLEHAUL_API_KEY"
```

```python
import os, requests
r = requests.get("https://api.handlehaul.com/v1/tiktok/users/mila.studio/posts",
                 headers={"X-Api-Key": os.environ["HANDLEHAUL_API_KEY"]}, timeout=60)
r.raise_for_status()
for p in r.json()["data"]:
    print(p["created_at"], p["counts"]["views"], p["url"])
```

```javascript
const res = await fetch("https://api.handlehaul.com/v1/tiktok/users/mila.studio/posts", {
  headers: { "X-Api-Key": process.env.HANDLEHAUL_API_KEY },
});
const { data, meta } = await res.json();
```

```php
$ch = curl_init("https://api.handlehaul.com/v1/tiktok/users/mila.studio/posts");
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => ["X-Api-Key: " . getenv("HANDLEHAUL_API_KEY")],
    CURLOPT_RETURNTRANSFER => true,
]);
$body = json_decode(curl_exec($ch), true);
print_r($body["data"]);
```

```go
req, _ := http.NewRequest("GET", "https://api.handlehaul.com/v1/tiktok/users/mila.studio/posts", nil)
req.Header.Set("X-Api-Key", os.Getenv("HANDLEHAUL_API_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer res.Body.Close()
var body map[string]any
json.NewDecoder(res.Body).Decode(&body)
fmt.Println(body["data"])
```

## FAQ

### How do I get all videos of a TikTok account?
Call `GET /v1/tiktok/users/{user}/posts` and pass `pagination.next_cursor` back as `cursor` while `pagination.has_more` is `true`. Each page is one call.

### Why is the liked list empty?
The account hides its liked videos (the default on TikTok). The call still answers, with `meta.list_hidden: true`.
