# TikTok Profile API

> Get a public TikTok profile by handle, numeric id or secUid: nickname, bio, verified and private flags, follower, following, like and video counts, avatar and ids. 1 credit per call.

**Get a public TikTok profile as JSON** from a handle, a numeric user id or a `secUid`: nickname, bio and link, verified and private flags, follower, following, like and video counts, avatar, and the account's `id` and `sec_uid` for the other TikTok endpoints.

```
GET https://api.handlehaul.com/v1/tiktok/users/{user}
```

**Cost:** 1 credit per successful call (free from cache, kept 60 seconds). Not found and failed calls are free. The profile call never adds lookup credits: it is the lookup.

## 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. |
| `fresh` | query | `true` skips the cache. |
| `raw` | query | `true` returns TikTok's own JSON in `data` (same price). |

## Response

```json
{
  "data": {
    "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
    },
    "bio": "Sample TikTok profile for mila.studio.",
    "bio_link": null,
    "region": "US",
    "language": "en",
    "created_at": "2024-06-13T00:53:20.000Z"
  },
  "meta": {
    "request_id": "req_…",
    "cached": false,
    "cache_age_seconds": 0,
    "credits_charged": 1,
    "credits_remaining": 26943
  }
}
```

- `counts` are exact. (Counts embedded in post lists, under `author.counts`, are rounded by TikTok on big accounts.)
- `region`, `language` and `created_at` are filled when TikTok exposes them and are `null` otherwise.
- Private accounts still return their profile, with `is_private: true`; their lists answer `private_account`.

## Examples

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

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

```javascript
const res = await fetch("https://api.handlehaul.com/v1/tiktok/users/mila.studio", {
  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");
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", 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 TikTok follower counts with an API?
Call `GET /v1/tiktok/users/{handle}`. `data.counts.followers` is the exact follower count; `likes` is the total likes the account received and `videos` its public post count.

### What is a secUid?
TikTok's stable key for an account. Handles can change; the `secUid` and numeric `id` do not. Store `sec_uid` from the profile and send it to the list endpoints: it is the fastest identifier and never costs a lookup.
