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
| Endpoint | Returns | Cost |
|---|---|---|
GET /v1/tiktok/profile/live | Is a TikTok user live | 1 credit |
GET /v1/tiktok/live | TikTok live room info | 1 credit |
GET /v1/twitch/user/schedule | Twitch stream schedule | 1 credit |
GET /v1/twitch/user/videos | Twitch user videos | 1 credit |
GET /v1/youtube/channel/lives | YouTube channel live streams | 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
- Check the creator's live room.
- Read the Twitch schedule.
- Store start times next to the schedule.
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"]
# Twitch stream schedule
schedule = get("/v1/twitch/user/schedule", handle="shroud")
# Twitch user videos
videos = get("/v1/twitch/user/videos", handle="shroud", type="archive", sort="time", limit=10)
print(schedule)
for v in videos["items"]:
print(v["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;
}
// Twitch stream schedule
const schedule = await get("/v1/twitch/user/schedule", { handle: "shroud" });
// Twitch user videos
const videos = await get("/v1/twitch/user/videos", { handle: "shroud", type: "archive", sort: "time", limit: 10 });
console.log(schedule);
for (const v of videos.items) console.log(v.url);Good to know
TikTok live data is room-level. Find the room first with the profile live endpoint.