Lesson completed!
-

Lesson 9 / 21 · Connect Your Instagram (Meta MCP)

Build Your Own Puller

Max Techera
Next

Build Your Own Puller

Option A was the MCP — fast, someone else's code. Option B is you asking Claude Code to write a small script that hits the Graph API directly and saves your reels to disk. Same data, code you own, no third-party server holding your token.

Remember the reframe: you're not writing this. You describe the script and the output, and Claude Code builds it. This is the vibe-coding skill from Chapter 1 applied to a real task.

The build prompt

Paste this into Claude Code, verbatim:

Write a Python script `pull_mine.py` that calls the Instagram Graph API
GET /v25.0/{media-id}/insights for my last 30 reels. Pull these fields:
views, reach, ig_reels_avg_watch_time (convert from ms to seconds), saved, shares, comments, likes,
total_interactions, reels_skip_rate. The token is in $IG_TOKEN. Save each reel as
data/mine/<id>.json. Rate-limit to 1 req/sec and cache the raw responses in cache/.

That's the whole thing. Claude writes pull_mine.py, you run it, and data/mine/ fills up with one JSON file per reel.

What each piece of that prompt is doing

Read the prompt again with these notes and you'll understand the API without a docs deep-dive:

  • GET /v25.0/{media-id}/insights — the endpoint. For each reel (identified by its media-id), it returns that reel's metrics. Version v25.0 is a stable Graph API version.
  • The field listviews, reach, ig_reels_avg_watch_time, saved, shares, comments, likes, total_interactions, reels_skip_rate. These are the exact Meta field names. Ask for them explicitly or you get defaults.
  • ig_reels_avg_watch_time in ms → seconds — Meta returns average watch time in milliseconds. The conversion is called out in the prompt so the numbers read like seconds, the way you think about them.
  • data/mine/<id>.json — one file per reel. This is the whole system's storage model: files, not a chat. It's why your data compounds instead of evaporating.

Why the rate-limit and cache lines matter

Two lines in that prompt look boring but save you real pain:

  • Rate-limit 1 req/seg — Meta throttles aggressive callers. One request per second keeps you well under the limit so the script doesn't get blocked mid-run.
  • cacheá las respuestas crudas en cache/ — caching the raw responses means re-running the script costs nothing and never re-hammers the API. You can iterate on how you process the data without re-pulling it.
Success:

Everything lands in data/mine/ as plain JSON you own. Later chapters build the dashboard and the format analyzer straight on top of these files — nothing here is throwaway. This is the same folder the MCP path writes to, so the rest of the system doesn't care which option you chose.

Knowledge check

Which Graph API endpoint does the puller hit for each reel's metrics?

Key takeaway

You don't need the MCP — ask Claude Code to build pull_mine.py, which hits GET /v25.0/{media-id}/insights, requests the exact Meta fields (converting ig_reels_avg_watch_time from ms to seconds), rate-limits to 1 req/sec, and saves each reel to data/mine/<id>.json. Same data as the MCP, code you control.

Share