Get TikTok video stats by ID or URL with the API
One TikTok video or photo post by id or URL. Complete code for GET /v1/tiktok/posts/{post} in six languages and both official SDKs, each tested against the documented response.
Short answer. GET /v1/tiktok/posts/{post} takes a post id or a tiktok.com link and returns one video or photo post: caption, date, duration, views, likes, comments, shares, saves, author, music and hashtags.
Facts checked 2 December 2026. Prices change: follow the links before you decide.
Why call it
- Clipping platforms: verify a submitted video's view count from its link before paying per view.
- Campaign tracking: re-check views, likes and shares on sponsored posts for client reports.
- Link enrichment: turn a TikTok link a user pastes into author, sound and hashtag data in one call.
The request
GET https://api.handlehaul.com/v1/tiktok/posts/{post} with your key in the X-Api-Key header. One TikTok video or photo post by id or URL. One TikTok video or photo post by id or URL. 1 credit. Docs: https://api.handlehaul.com/docs/tiktok-post-api
| Parameter | In | Description |
|---|---|---|
post required | path | TikTok post id, or a tiktok.com/@user/video/<id> URL (URL-encoded). |
fresh | query | true skips the cache (full price). |
raw | query | true returns TikTok's raw JSON in data instead of our fields (same price). |
Code in 6 languages
Each sample is a complete program: it reads the key from HANDLEHAUL_API_KEY, waits and retries when the API answers 429 (using Retry-After), stops with the error code on anything else. The SDK versions do the retries for you.
tiktok-video.sh
# One TikTok video or photo post by id or URL. --retry waits out a 429 using its Retry-After header;
# --fail exits with code 22 on any other error (drop it to read the error JSON).
curl -sS --fail --retry 3 "https://api.handlehaul.com/v1/tiktok/posts/7300000000000000123" \
-H "X-Api-Key: $HANDLEHAUL_API_KEY"
tiktok_video.pyInstall: pip install requestsRun: python tiktok_video.py
# One TikTok video or photo post by id or URL: GET /v1/tiktok/posts/{post}
# pip install requests
import os
import time
import requests
API = "https://api.handlehaul.com/v1"
HEADERS = {"X-Api-Key": os.environ["HANDLEHAUL_API_KEY"]}
def get(path, params=None):
"""GET one endpoint. Waits and retries on 429 (Retry-After); stops on any other error."""
for attempt in range(5):
r = requests.get(API + path, headers=HEADERS, params=params, timeout=60)
if r.status_code == 429:
time.sleep(float(r.headers.get("Retry-After") or 2 ** attempt))
continue
body = r.json()
if not r.ok:
err = body.get("error", {})
raise SystemExit(f"{r.status_code} {err.get('code')}: {err.get('message')}")
return body
raise SystemExit("Still rate limited after 5 tries")
body = get("/tiktok/posts/7300000000000000123")
data = body["data"]
print(data["counts"]["views"], data["counts"]["likes"], data["counts"]["comments"], data["counts"]["shares"])
print("credits used:", body["meta"]["credits_charged"])
tiktok_video_sdk.pyInstall: pip install handlehaulRun: python tiktok_video_sdk.py
# One TikTok video or photo post by id or URL: GET /v1/tiktok/posts/{post}
# pip install handlehaul
from handlehaul import HandleHaul, HandleHaulError
hh = HandleHaul() # reads HANDLEHAUL_API_KEY; retries 429 using Retry-After
try:
res = hh.tiktok.post("7300000000000000123")
data = res.data
print(data["counts"]["views"], data["counts"]["likes"], data["counts"]["comments"], data["counts"]["shares"])
print("credits used:", res.meta["credits_charged"])
except HandleHaulError as e:
raise SystemExit(f"{e.status} {e.code}: {e.message}")
tiktok-video.mjsRun: node tiktok-video.mjs
// One TikTok video or photo post by id or URL: GET /v1/tiktok/posts/{post}
// Node.js 18+ (built-in fetch, no packages). Save as tiktok-video.mjs: top-level await needs .mjs.
const API = "https://api.handlehaul.com/v1";
const KEY = process.env.HANDLEHAUL_API_KEY;
// GET one endpoint. Waits and retries on 429 (Retry-After); throws on any other error.
async function get(path, params = {}) {
const url = new URL(API + path);
for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
for (let attempt = 0; attempt < 5; attempt++) {
const res = await fetch(url, { headers: { "X-Api-Key": KEY } });
if (res.status === 429) {
const wait = Number(res.headers.get("retry-after")) || 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, wait * 1000));
continue;
}
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.error?.code}: ${body.error?.message}`);
return body;
}
throw new Error("Still rate limited after 5 tries");
}
const { data, meta } = await get("/tiktok/posts/7300000000000000123");
console.log(data.counts.views, data.counts.likes, data.counts.comments, data.counts.shares);
console.log("credits used:", meta.credits_charged);
tiktok-video-sdk.mjsInstall: npm install handlehaulRun: node tiktok-video-sdk.mjs
// One TikTok video or photo post by id or URL: GET /v1/tiktok/posts/{post}
// npm install handlehaul (save as tiktok-video-sdk.mjs)
import { HandleHaul, HandleHaulError } from "handlehaul";
const hh = new HandleHaul(); // reads HANDLEHAUL_API_KEY; retries 429 using Retry-After
try {
const { data, meta } = await hh.tiktok.post("7300000000000000123");
console.log(data.counts.views, data.counts.likes, data.counts.comments, data.counts.shares);
console.log("credits used:", meta.credits_charged);
} catch (e) {
if (!(e instanceof HandleHaulError)) throw e;
console.error(`${e.status} ${e.code}: ${e.message}`);
process.exit(1);
}
tiktok-video.phpRun: php tiktok-video.php
<?php
// One TikTok video or photo post by id or URL: GET /v1/tiktok/posts/{post}
// PHP 8 with the curl extension. Run: php tiktok-video.php
const API = "https://api.handlehaul.com/v1";
// GET one endpoint. Waits and retries on 429 (Retry-After); throws on any other error.
function get(string $path, array $params = []): array
{
$url = API . $path . ($params ? "?" . http_build_query($params) : "");
for ($attempt = 0; $attempt < 5; $attempt++) {
$retryAfter = 0;
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_HTTPHEADER => ["X-Api-Key: " . getenv("HANDLEHAUL_API_KEY")],
CURLOPT_HEADERFUNCTION => function ($ch, $line) use (&$retryAfter) {
if (stripos($line, "retry-after:") === 0) {
$retryAfter = (float) trim(substr($line, 12));
}
return strlen($line);
},
]);
$raw = curl_exec($ch);
if ($raw === false) {
throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status === 429) {
usleep((int) (($retryAfter ?: 2 ** $attempt) * 1000000));
continue;
}
$body = json_decode($raw, true);
if ($status >= 400) {
throw new RuntimeException("$status {$body["error"]["code"]}: {$body["error"]["message"]}");
}
return $body;
}
throw new RuntimeException("Still rate limited after 5 tries");
}
// Print values on one line (strings as they are, everything else as JSON).
function show(...$values): void
{
echo implode(" ", array_map(fn($v) => is_string($v) ? $v : json_encode($v), $values)), "\n";
}
$body = get("/tiktok/posts/7300000000000000123");
$data = $body["data"];
show($data["counts"]["views"], $data["counts"]["likes"], $data["counts"]["comments"], $data["counts"]["shares"]);
show("credits used:", $body["meta"]["credits_charged"]);
tiktok_video.goRun: go run tiktok_video.go
// One TikTok video or photo post by id or URL: GET /v1/tiktok/posts/{post}
// Go 1.18+, standard library only. Run: go run tiktok_video.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
"os"
"strconv"
"time"
)
const api = "https://api.handlehaul.com/v1"
var client = &http.Client{Timeout: 60 * time.Second}
type objectResponse struct {
Data map[string]any `json:"data"`
Meta struct {
CreditsCharged float64 `json:"credits_charged"`
} `json:"meta"`
}
type apiError struct {
Error struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"error"`
}
// get calls one endpoint and decodes the answer into out. It waits and retries on 429
// (Retry-After) and returns an error for any other failure.
func get(path string, params url.Values, out any) error {
u := api + path
if len(params) > 0 {
u += "?" + params.Encode()
}
for attempt := 0; attempt < 5; attempt++ {
req, err := http.NewRequest(http.MethodGet, u, nil)
if err != nil {
return err
}
req.Header.Set("X-Api-Key", os.Getenv("HANDLEHAUL_API_KEY"))
res, err := client.Do(req)
if err != nil {
return err
}
raw, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return err
}
if res.StatusCode == http.StatusTooManyRequests {
wait, _ := strconv.ParseFloat(res.Header.Get("Retry-After"), 64)
if wait <= 0 {
wait = float64(int(1) << attempt)
}
time.Sleep(time.Duration(wait * float64(time.Second)))
continue
}
if res.StatusCode >= 400 {
var e apiError
_ = json.Unmarshal(raw, &e)
return fmt.Errorf("%d %s: %s", res.StatusCode, e.Error.Code, e.Error.Message)
}
dec := json.NewDecoder(bytes.NewReader(raw))
dec.UseNumber() // keeps big ids and counts exact
return dec.Decode(out)
}
return fmt.Errorf("still rate limited after 5 tries")
}
// field reads a nested value, e.g. field(row, "counts", "views"); nil when it is missing.
func field(m map[string]any, keys ...string) any {
var v any = m
for _, k := range keys {
obj, ok := v.(map[string]any)
if !ok {
return nil
}
v = obj[k]
}
return v
}
func main() {
params := url.Values{}
var body objectResponse
if err := get("/tiktok/posts/7300000000000000123", params, &body); err != nil {
log.Fatal(err)
}
fmt.Println(field(body.Data, "counts", "views"), field(body.Data, "counts", "likes"), field(body.Data, "counts", "comments"), field(body.Data, "counts", "shares"))
fmt.Println("credits used:", body.Meta.CreditsCharged)
}
tiktok-video.rbRun: ruby tiktok-video.rb
# One TikTok video or photo post by id or URL: GET /v1/tiktok/posts/{post}
# Ruby 3, standard library only. Run: ruby tiktok-video.rb
require "json"
require "net/http"
require "uri"
API = "https://api.handlehaul.com/v1"
# GET one endpoint. Waits and retries on 429 (Retry-After); stops on any other error.
def get(path, params = {})
uri = URI(API + path)
uri.query = URI.encode_www_form(params) unless params.empty?
5.times do |attempt|
req = Net::HTTP::Get.new(uri)
req["X-Api-Key"] = ENV.fetch("HANDLEHAUL_API_KEY")
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https", read_timeout: 60) do |http|
http.request(req)
end
if res.code == "429"
sleep((res["Retry-After"] || 2**attempt).to_f)
next
end
body = JSON.parse(res.body)
abort "#{res.code} #{body.dig("error", "code")}: #{body.dig("error", "message")}" unless res.is_a?(Net::HTTPSuccess)
return body
end
abort "Still rate limited after 5 tries"
end
body = get("/tiktok/posts/7300000000000000123")
data = body["data"]
puts [data.dig("counts", "views"), data.dig("counts", "likes"), data.dig("counts", "comments"), data.dig("counts", "shares")].join(" ")
puts "credits used: #{body["meta"]["credits_charged"]}"
Response
One object in data and meta with what the call cost. Example values, from the API docs. Lists are cut to two rows here.
{
"data": {
"id": "7300000000000000123",
"url": "https://www.tiktok.com/@river_wren29/video/7300000000000000123",
"caption": "Sample post 124 by @river_wren29 #pixel #fyp",
"created_at": "2026-07-30T00:53:20.000Z",
"media_type": "video",
"duration_seconds": 18,
"cover_url": "https://p16-sign.tiktokcdn-us.com/…/cover/7300000000000000123.jpeg",
"play_url": "https://v16-webapp-prime.tiktok.com/…/7300000000000000123.mp4",
"images": null,
"counts": {
"views": 538234,
"likes": 32294,
"comments": 1076,
"shares": 538,
"saves": 1615
},
"author": {
"id": "6804246811370395890",
"sec_uid": "MS4wLjABAAAAsKNrxsBn-IUSma2viuD_ShtPMiRgkVWSjeDiJxNJZ2w",
"handle": "river_wren29",
"nickname": "River Wren",
"avatar_url": "https://p16-sign.tiktokcdn-us.com/…/avatar/6804246811370395890~c5_1080x1080.jpeg",
"is_verified": false,
"is_private": false,
"url": "https://www.tiktok.com/@river_wren29",
"counts": {
"followers": 579298,
"following": 318,
"likes": 17958238,
"videos": 338
}
},
"music": {
"id": "7200000000000000000",
"title": "original sound",
"artist": "River Wren",
"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": [
"pixel",
"fyp"
],
"mentions": [],
"language": "en",
"location": "US",
"has_captions": true,
"is_ad": false
},
"meta": {
"request_id": "req_…",
"cached": false,
"cache_age_seconds": 0,
"credits_charged": 1,
"credits_remaining": 26943
}
}
Cost, cache and limits
- 1 credit per call. At $1.40 to $0.80 per 1,000 calls. Cache hits, failed calls and
429answers are free;meta.credits_chargedsays what each call cost. - Cache. Identical calls that arrive while an answer is cached are served from it. Add
fresh=trueto force a live call (billed). - Speed. Over your plan's requests-per-second limit the API answers
429 rate_limitedwithRetry-After; the samples wait that long and retry. - Private accounts. Public data only: a private account answers
403 private_account, and that call is free. - Testing. A
kd_test_key returns sample data in this exact shape at no cost, so you can run the code before you spend anything.
Things to know
- Send a link URL-encoded in the path. Both
/video/<id>and/photo/<id>links work. - A post that does not exist answers
404 user_not_found, free. On this route, read that code as a missing post. has_captionstells you whether the transcript endpoint will find text, before you spend a call on it.- Photo posts return slides in
imagesand noplay_url. On videos,play_urlis short-lived.
Next steps
- TikTok transcript API: transcript of a TikTok video from its auto-captions.
- TikTok comments API: comments on a TikTok post.
- TikTok posts API: videos and photo posts of a TikTok account, newest first.
- Full script for a real job: TikTok scraper in Python: video views and likes to CSV or TikTok video views and likes to CSV with Node.js.
- TikTok video or photo post API overview: what it returns and how it compares.
- API reference: every field and error code.
- All TikTok API tutorials, or no code at all with n8n, Make, Zapier and Google Sheets.
TikTok video or photo post API: questions
Can I pass the TikTok link instead of the video id?
/v1/tiktok/posts/https%3A%2F%2Fwww.tiktok.com%2F%40user%2Fvideo%2F7300000000000000123.How do I get the sound used in a TikTok video?
data.music: id, title, artist, is_original and duration. Its post_count is null here; send music.id to the sound endpoint to get it.Run it on real data
One key for Instagram and TikTok. $1.40 to $0.80 per 1,000 calls; failed calls and cache hits are free.
Want to test first? Sandbox keys are free and unlimited, with sample data in the live schema.