1. Use cases
  2. 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.

EndpointReturnsCost
Is a TikTok user live1 credit
TikTok live room info1 credit
Twitch stream schedule1 credit
Twitch user videos1 credit
YouTube channel live streams1 credit

Recipe

  1. Check the creator's live room.
  2. Read the Twitch schedule.
  3. 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"])

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.

Related