Skip to content

Fetching Posts

We've seen how to fetch data related to TikTok users, now let's see how we can fetch post-specific data using the EnsembleData API.

Post Info API

API Documentation

Sample Response

The simplest endpoint to fetch post data is the Post Info API; it just requires the post url.

import requests

result = requests.get(
    "https://ensembledata.com/apis/tt/post/info",
    params={
        "url": "https://www.tiktok.com/@therock/video/6950314200000000000",
        "token": "API_TOKEN",
    }
).json()["data"]

post = result[0]
from ensembledata.api import EDClient

client = EDClient("API_TOKEN")
result = client.tiktok.post_info(
    url="https://www.tiktok.com/@daviddobrik/video/7286900345836424479"
)

post = result.data[0]
import { EDClient } from "ensembledata";

const client = new EDClient({ token: "API_TOKEN" });
const result = await client.tiktok.postInfo({
    url: "https://www.tiktok.com/@daviddobrik/video/7286900345836424479"
});

const post = result.data[0];

Post data

Multi Post Info API

API Documentation

Sample Response

If you are looking to fetch data for many posts at once, then the Multi Post Info API is the way to go. Instead of urls, it requires a list of post ids as we'll see below.

With this endpoint we can fetch up to 100 posts in one go.

result = requests.get(
    "https://ensembledata.com/apis/tt/post/multi-info",
    params={
        "ids": "7286900345836424479;7411198650782731563;7286900345836424479",
        "token": "API_TOKEN",
    }
).json()["data"]

posts = result
print("Number of posts:", len(posts))
result = client.tiktok.multi_post_info(
    aweme_ids=[
        "6950314200000000000",
        "6950314200000000001",
        "6950314200000000002",
    ]
)

posts = result.data
print("Number of posts:", len(posts))
const result = await client.tiktok.multiPostInfo({
    awemeIds: [
        "6950314200000000000",
        "6950314200000000001",
        "6950314200000000002",
    ]
});

const posts = result.data;
console.log("Number of posts:", posts.length);

Output:

Number of posts: 3