Recipes for agentsMenu
Recipes for agents
Metrics your agent can compute from fields the API already returns, and how to keep responses small enough for a model's context.
Engagement rate, views and posting frequency
One list call gives you enough for all three. instagram.reels and x.posts return the follower count next to the items, so no second call is needed.
- Engagement rate per post = (likes + comments, plus replies, reposts and quotes on X) ÷ followers × 100. Report the median: one viral post skews the mean.
- Views: the median of
view_count(play_counton TikTok). On YouTube and Telegram these are approximate. - Posting frequency: posts minus one, divided by the weeks between the oldest and newest item.
JavaScript
// data = the "data" object of an instagram.reels, instagram.photos or x.posts response
function metrics(data) {
const items = data.reels ?? data.posts ?? [];
const followers = data.follower_count;
const median = (xs) => {
const s = xs.filter((x) => typeof x === "number").sort((a, b) => a - b);
if (!s.length) return null;
const m = Math.floor(s.length / 2);
return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2;
};
// Engagement rate per post: interactions / followers x 100. Skip posts whose counts are hidden.
const rates = items
.filter((p) => !p.like_and_view_counts_disabled && typeof p.like_count === "number")
.map((p) => {
const interactions =
p.like_count + (p.comment_count ?? 0) + (p.reply_count ?? 0) + (p.retweet_count ?? 0) + (p.quote_count ?? 0);
return followers ? (interactions / followers) * 100 : null;
});
// Posts per week: Instagram taken_at is Unix seconds, X created_at is a date string
const times = items
.map((p) => (typeof p.taken_at === "number" ? p.taken_at * 1000 : Date.parse(p.created_at)))
.filter((t) => Number.isFinite(t))
.sort((a, b) => a - b);
const weeks = times.length > 1 ? (times.at(-1) - times[0]) / (7 * 24 * 3600 * 1000) : null;
return {
posts: items.length,
median_engagement_rate: median(rates),
median_views: median(items.map((p) => p.view_count)),
posts_per_week: weeks ? (times.length - 1) / weeks : null,
};
}| Endpoint | Interactions | Views | Time |
|---|---|---|---|
| instagram.reels | like_count, comment_count | view_count | taken_at (Unix seconds, approximate) |
| instagram.photos | like_count, comment_count | none | taken_at (Unix seconds) |
| x.posts | like_count, reply_count, retweet_count, quote_count | view_count | created_at (X date string) |
| tiktok.posts | none (use tiktok.video per video) | play_count | none (use tiktok.video) |
| youtube.videos | none (use youtube.video per video) | view_count (approximate) | published_text (relative, e.g. 2 days ago) |
| telegram.posts | none | view_count (approximate) | posted_at (ISO 8601) |
The Agent Skills include a ready-made post-metrics.mjs script that computes these from a saved response.
Keeping responses small
Response size depends mostly on how many items a list returns and how long their text is (captions, comments, transcripts). Single-object endpoints, such as a profile or one post, stay small. Lists grow with limit, so ask for only what the task needs.
| List endpoint | Default limit | Maximum |
|---|---|---|
| instagram.photos | 12 | 60 |
| instagram.comments | 15 | 15 |
| instagram.reels | 12 | 50 |
| instagram.reels_search | 10 | 10 |
| x.posts | 20 | 60 |
| tiktok.posts | 12 | 12 |
| tiktok.comments | 20 | 100 |
| tiktok.music | 12 | 12 |
| youtube.videos | 12 | 30 |
| youtube.search | 20 | 50 |
| youtube.comments | 20 | 100 |
| youtube.playlist | 50 | 100 |
| telegram.posts | 20 | 100 |
| pinterest.pins | 12 | 50 |
| pinterest.search | 20 | 50 |
| pinterest.board | 20 | 25 |
| twitch.videos | 20 | 50 |
| twitch.clips | 20 | 50 |
- Our MCP server caps each tool result at 100,000 characters and says so when it truncates. Change the cap with
SCRAPEEVERYTHING_MCP_MAX_CHARS. - Transcripts return timed segments and the joined text, so a long video produces a long response. Summarize in steps for long videos.
- To check the size of a typical response for your own targets, count the bytes once:
Terminal
curl -s -X POST https://api.scrapeeverything.com/v1/instagram/reels \
-H "Authorization: Bearer $SCRAPEEVERYTHING_API_KEY" \
-H "Content-Type: application/json" \
-d '{"username": "nasa", "limit": 12}' | wc -cToken counts depend on the model's tokenizer. Measure with your model's token counter rather than relying on a fixed ratio.