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
| Endpoint | Returns | Cost |
|---|---|---|
GET /v1/tiktok/videos/popular | Popular TikTok videos | 1 credit |
GET /v1/tiktok/search/hashtag | TikTok videos by hashtag | 1 credit |
GET /v1/tiktok/song | TikTok song details | 1 credit |
GET /v1/instagram/reels/trending | Instagram trending reels | 1 credit |
GET /v1/youtube/shorts/trending | Trending YouTube Shorts | 1 credit |
GET /v1/github/trending/repositories | GitHub trending repositories | 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
- Fetch each trending feed.
- Save it with the date.
- Diff against yesterday.
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"]
# Popular TikTok videos
popular = get("/v1/tiktok/videos/popular", period=7, sort="views")
# GitHub trending repositories
repos = get("/v1/github/trending/repositories", since="weekly", language="python")
for v in popular["items"][:10]:
print(v["stats"]["views"], v["url"])
for r in repos["items"][:10]:
print(r["url"])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;
}
// Popular TikTok videos
const popular = await get("/v1/tiktok/videos/popular", { period: 7, sort: "views" });
// GitHub trending repositories
const repos = await get("/v1/github/trending/repositories", { since: "weekly", language: "python" });
for (const v of popular.items.slice(0, 10)) console.log(v.stats.views, v.url);
for (const r of repos.items.slice(0, 10)) console.log(r.url);Good to know
The anonymous feeds (Instagram Reels, YouTube Shorts, TikTok For You) differ on every call. They sample a feed; they are not a chart.