The job
Search your brand name and campaign hashtag, then open the comments on the videos that matter. Keep the ids to avoid reading the same video twice.
Endpoints
| Endpoint | Returns | Cost |
|---|---|---|
GET /v1/tiktok/search/hashtag | TikTok videos by hashtag | 1 credit |
GET /v1/tiktok/search/keyword | TikTok video search | 1 credit |
GET /v1/youtube/search | YouTube search | 1 credit |
GET /v1/tiktok/video/comments | TikTok video comments | 1 credit |
GET /v1/youtube/video/comments | YouTube video comments | 1 credit |
Failed requests and cached repeats cost 0 credits. Send max_age_days to accept a recent cached copy. See credits and caching.
Recipe
- Search the brand and the hashtag.
- Open comments on the top videos.
- Store what you have seen by id.
Preview
The API is in early access. Calls use
api.socialscrape.io and return the shapes in the reference.Python
import os
import requests
API = "https://api.socialscrape.io"
HEADERS = {"x-api-key": os.environ["SOCIALSCRAPE_API_KEY"]}
def get(path, **params):
res = requests.get(API + path, headers=HEADERS, params=params, timeout=60)
res.raise_for_status()
return res.json()["data"]
# TikTok videos by hashtag
tagged = get("/v1/tiktok/search/hashtag", hashtag="standingdesk")
# TikTok video comments
comments = get("/v1/tiktok/video/comments", url=tagged["items"][0]["url"])
for c in comments["items"]:
print(c["stats"]["likes"], c["text"])TypeScript
const API = "https://api.socialscrape.io";
const headers = { "x-api-key": process.env.SOCIALSCRAPE_API_KEY! };
async function get(path: string, params: Record<string, string | number | boolean>) {
const query = new URLSearchParams(Object.entries(params).map(([k, v]) => [k, String(v)]));
const res = await fetch(`${API}${path}?${query}`, { headers });
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
return (await res.json()).data;
}
// TikTok videos by hashtag
const tagged = await get("/v1/tiktok/search/hashtag", { hashtag: "standingdesk" });
// TikTok video comments
const comments = await get("/v1/tiktok/video/comments", { url: tagged.items[0].url });
for (const c of comments.items) console.log(c.stats.likes, c.text);Good to know
TikTok hashtag search can return duplicates, so de-duplicate by id.