The job
Pick the accounts, fetch their latest posts on a schedule, and store the counts. A change between runs is the signal.
Endpoints
| Endpoint | Returns | Cost |
|---|---|---|
GET /v1/youtube/channel/videos | YouTube channel videos | 1 credit |
GET /v1/instagram/profile/posts | Instagram profile posts | 1 credit |
GET /v1/facebook/ad-library/search | Facebook Ad Library search | 1 credit |
POST /v1/monitors | Create a monitor | Free |
Failed requests and cached repeats cost 0 credits. Send max_age_days to accept a recent cached copy. See credits and caching.
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.
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"]
# YouTube channel videos
youtube = get("/v1/youtube/channel/videos", handle="mkbhd", sort="latest")
# Instagram profile posts
instagram = get("/v1/instagram/profile/posts", handle="nasa")
for feed in (youtube, instagram):
for post in feed["items"][:5]:
print(post["platform"], post["published_at"], post["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;
}
// YouTube channel videos
const youtube = await get("/v1/youtube/channel/videos", { handle: "mkbhd", sort: "latest" });
// Instagram profile posts
const instagram = await get("/v1/instagram/profile/posts", { handle: "nasa" });
for (const feed of [youtube, instagram])
for (const post of feed.items.slice(0, 5)) console.log(post.platform, post.published_at, post.url);Good to know
Instagram play counts are not in every list response; the reference shows when a request can add them.