- Use cases
- Competitor tracking API
Competitor tracking API
Pull what a competitor posted this week on each platform, with the numbers.
The job
Pick the accounts, fetch their latest posts on a schedule, and store the counts. A change between runs is the signal.
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 |
|---|---|---|
| YouTube channel videos | 1 credit | |
| Instagram profile posts | 1 credit | |
| Facebook Ad Library search | 1 credit | |
| Create a monitor | Free |
Recipe
- List each account's latest posts.
- Store views, likes and comments with a date.
- Compare runs, or let a monitor send only new posts.
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 channel videos14youtube = get("/v1/youtube/channel/videos", handle="mkbhd", sort="latest")15# Instagram profile posts16instagram = get("/v1/instagram/profile/posts", handle="nasa")1718for feed in (youtube, instagram):19 for post in feed["items"][:5]:20 print(post["platform"], post["published_at"], post["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// YouTube channel videos12const youtube = await get("/v1/youtube/channel/videos", { handle: "mkbhd", sort: "latest" });13// Instagram profile posts14const instagram = await get("/v1/instagram/profile/posts", { handle: "nasa" });1516for (const feed of [youtube, instagram])17 for (const post of feed.items.slice(0, 5)) console.log(post.platform, post.published_at, post.url);Calls use api.socialscrape.dev and return the shapes in the reference.
Good to know
Instagram play counts are not in every list response; the reference shows when a request can add them.