1. Use cases
  2. Social media data for research

Social media data for research

Collect posts and comments for a study, with cursors you can resume.

The job

A study needs repeatable collection. Page through a feed with its cursor, keep the raw response, and record when each page was fetched.

Endpoints

Failed requests and cached repeats cost 0 credits. Send max_age_days to accept a recent cached copy. See credits and caching.

EndpointReturnsCost
YouTube search1 credit
YouTube video comments1 credit
TikTok videos by hashtag1 credit
Bluesky profile posts1 credit
Telegram channel posts1 credit

Recipe

  1. Define the query and the date window.
  2. Page with the cursor until has_more is false.
  3. Store the raw response and the fetch time.
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# YouTube search14page = get("/v1/youtube/search", query="climate policy", type="video", upload_date="month")15# YouTube video comments16comments = get("/v1/youtube/video/comments", url=page["items"][0]["url"], sort="top")1718print(page["has_more"], page["cursor"])19print(len(comments["items"]))

Calls use api.socialscrape.dev and return the shapes in the reference.

Good to know

A cached response carries cached_at, so you can tell fresh collection from a repeat. Check your ethics board and each platform's terms for your use.

Related