- Use cases
- Livestream monitoring
Livestream monitoring
Check whether a creator is live and when they usually stream.
The job
Live is time-bound. Check on a schedule, record when a stream starts, and keep the Twitch schedule beside what actually happened.
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 |
|---|---|---|
| Is a TikTok user live | 1 credit | |
| TikTok live room info | 1 credit | |
| Twitch stream schedule | 1 credit | |
| Twitch user videos | 1 credit | |
| YouTube channel live streams | 1 credit |
Recipe
- Check the creator's live room.
- Read the Twitch schedule.
- Store start times next to the schedule.
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# Twitch stream schedule14schedule = get("/v1/twitch/user/schedule", handle="shroud")15# Twitch user videos16videos = get("/v1/twitch/user/videos", handle="shroud", type="archive", sort="time", limit=10)1718print(schedule)19for v in videos["items"]:20 print(v["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// Twitch stream schedule12const schedule = await get("/v1/twitch/user/schedule", { handle: "shroud" });13// Twitch user videos14const videos = await get("/v1/twitch/user/videos", { handle: "shroud", type: "archive", sort: "time", limit: 10 });1516console.log(schedule);17for (const v of videos.items) console.log(v.url);Calls use api.socialscrape.dev and return the shapes in the reference.
Good to know
TikTok live data is room-level. Find the room first with the profile live endpoint.