- Use cases
- Trend research from platform feeds
Trend research from platform feeds
Read what is trending on each platform today and store the snapshot.
The job
Trends are a time series. Take the same snapshot daily and the list of what rose becomes a query on your own table.
Endpoints
Failed requests and cached repeats cost 0 credits. Send max_age_days to accept a recent cached copy. See credits and caching.
| Endpoint | Returns | Cost |
|---|---|---|
| Popular TikTok videos | 1 credit | |
| TikTok videos by hashtag | 1 credit | |
| TikTok song details | 1 credit | |
| Instagram trending reels | 1 credit | |
| Trending YouTube Shorts | 1 credit | |
| GitHub trending repositories | 1 credit |
Recipe
- Fetch each trending feed.
- Save it with the date.
- Diff against yesterday.
1import os2import requests34API = "https://api.socialscrape.dev"5HEADERS = {"x-api-key": os.environ["SOCIALSCRAPE_API_KEY"]}678def get(path, **params):9 res = requests.get(API + path, headers=HEADERS, params=params, timeout=60)10 res.raise_for_status()11 return res.json()["data"]1213# Popular TikTok videos14popular = get("/v1/tiktok/videos/popular", period=7, sort="views")15# GitHub trending repositories16repos = get("/v1/github/trending/repositories", since="weekly", language="python")1718for v in popular["items"][:10]:19 print(v["stats"]["views"], v["url"])20for r in repos["items"][:10]:21 print(r["url"])1const API = "https://api.socialscrape.dev";2const headers = { "x-api-key": process.env.SOCIALSCRAPE_API_KEY! };34async function get(path: string, params: Record<string, string | number | boolean>) {5 const query = new URLSearchParams(Object.entries(params).map(([k, v]) => [k, String(v)]));6 const res = await fetch(`${API}${path}?${query}`, { headers });7 if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);8 return (await res.json()).data;9}1011// Popular TikTok videos12const popular = await get("/v1/tiktok/videos/popular", { period: 7, sort: "views" });13// GitHub trending repositories14const repos = await get("/v1/github/trending/repositories", { since: "weekly", language: "python" });1516for (const v of popular.items.slice(0, 10)) console.log(v.stats.views, v.url);17for (const r of repos.items.slice(0, 10)) console.log(r.url);Calls use api.socialscrape.dev and return the shapes in the reference.
Good to know
The feeds (Instagram Reels, YouTube Shorts, TikTok For You) differ on every call. They sample a feed; they are not a chart.