InstagramAnswer

Instagram reels API: list any public account's reels

Meta's API publishes reels and reads your own. Ours lists any public account's reels with play counts, 12 a call, 1 credit. Python CSV script.

5 min read

Short answer

  • Instagram's API supports reels for professional accounts: you publish a reel with media_type=REELS and read your own reels and their metrics. Other accounts' reels come only through Business Discovery.
  • Meta lists no reels edge, so no official call returns an account's Reels tab, and media_url is left out when a reel's owner has turned downloads off.
  • ToolzerHub's /v1/instagram/user/reels lists a public account's reels with play counts, 12 per call at 1 credit. It paged MrBeast to the end: 705 reels in 59 calls.
On this page

Instagram's API publishes reels and reads your own, from a professional account you log in as. Other accounts' reels come only through Business Discovery, for Business and Creator accounts. ToolzerHub lists any public account's reels by username, 12 per call, with play counts but no watch-time metrics.

What Meta's API does with reels

Meta's content publishing guide covers reels: you create a container with media_type=REELS and a video_url, then publish it. You read your own reels from the media edge, and media insights add watch time, reach and skip rate. For anyone else's, Business Discovery is the route, from an app with Facebook Login and only for Business or Creator targets, and its sample returns view_count for a reel. Meta lists no reels edge, so no call returns an account's Reels tab, and it leaves out media_url when the reel's owner has turned off downloads. Use Meta's API to publish reels and to read your own reels' watch time, skip rate and reach.

List a public account's reels

We make ToolzerHub. Our Instagram API lists the reels on a public account's Reels tab by username, with one API key and no Meta app. GET /v1/instagram/user/reels returns 12 reels per call and costs 1 credit; pass paging_info.max_id back as cursor until more_available is false. Each reel has code, taken_at, play_count, like_count, comment_count and its caption. play_count is the number shown on the Reels tab.

The posts list doesn't replace it. MrBeast's posts list (/v1/instagram/user/posts) held 211 reels; his reels list held 705. Our post on getting a user's posts covers that list.

This script writes each account's reels to CSV. The owner column shows who posted each reel, since collaborative reels from other accounts appear in the list.

python
import csv
import os
import sys
import time
from datetime import datetime, timezone

import requests

URL = "https://api.toolzerhub.com/v1/instagram/user/reels"
HEADERS = {"x-api-key": os.environ.get("TOOLZERHUB_API_KEY", "")}
FIELDS = ["account", "owner", "code", "url", "posted_at", "plays", "likes", "comments", "caption"]
calls = 0


def cell(value):
    # Spreadsheets run text starting with = + - or @ as a formula; an apostrophe keeps it text.
    if isinstance(value, str) and value[:1] in ("=", "+", "-", "@", "\t", "\r"):
        return "'" + value
    return value


def get(params, tries=4):
    # 429 and 503 are retried; the wait comes from the error body or the Retry-After header.
    global calls
    for attempt in range(tries):
        r = requests.get(URL, headers=HEADERS, params=params, timeout=90)
        calls += 1
        if r.status_code == 400:  # malformed username: skip this account
            print("bad request:", r.json()["error"]["message"].splitlines()[0])
            return None
        if r.status_code not in (429, 503) or attempt == tries - 1:
            if r.status_code >= 500:  # any 5xx, or a 503 past the retries: skip
                print(f"HTTP {r.status_code}, skipping:", r.text[:120].replace("\n", " "))
                return None
            r.raise_for_status()
            return r.json().get("data")
        try:
            wait = r.json()["error"]["details"]["retryAfter"]
        except (ValueError, KeyError, TypeError):
            wait = None
        try:
            wait = int(wait or r.headers.get("Retry-After") or 5 * (attempt + 1))
        except ValueError:
            wait = 5 * (attempt + 1)
        time.sleep(min(wait, 60))


def export_account(writer, account, max_pages):
    params, seen, pages = {"username_or_url": account}, set(), 0
    status = "page cap reached, more available"
    while pages < max_pages:
        data = get(params)
        if not data or not data.get("items"):
            status = "stopped early: failed or empty page" if pages else "nothing returned"
            break
        pages += 1
        for item in data["items"]:
            reel = item.get("media") or item
            key = reel.get("pk") or reel.get("code")
            if not key or key in seen:  # pages can repeat a reel
                continue
            seen.add(key)
            code = reel.get("code") or ""
            caption = (reel.get("caption") or {}).get("text") or ""
            writer.writerow({
                "account": account, "owner": (reel.get("user") or {}).get("username"),  # collabs differ
                "code": code, "url": f"https://www.instagram.com/reel/{code}/" if code else "",
                "posted_at": datetime.fromtimestamp(reel["taken_at"], timezone.utc).isoformat()
                if reel.get("taken_at") else "",
                "plays": reel.get("play_count"), "likes": reel.get("like_count"),
                "comments": reel.get("comment_count"),
                "caption": cell(caption.replace("\r", " ").replace("\n", " ")),
            })
        info = data.get("paging_info") or {}
        if not (info.get("more_available") and info.get("max_id")):
            status = "end"
            break
        params["cursor"] = info["max_id"]
        time.sleep(0.3)
    print(f"{account}: {len(seen)} reels, {pages} pages ({status})")
    return len(seen)


def main(accounts, max_pages="50", out="reels.csv"):
    total = 0
    with open(out, "w", newline="", encoding="utf-8-sig") as f:  # BOM: Excel reads emoji
        writer = csv.DictWriter(f, fieldnames=FIELDS)
        writer.writeheader()
        for account in [a.strip().lstrip("@") for a in accounts.split(",") if a.strip()]:
            total += export_account(writer, account, int(max_pages))
    print(f"wrote {total} reels to {out} in {calls} calls")


if __name__ == "__main__":
    if len(sys.argv) < 2:
        sys.exit("usage: python instagram_reels.py spacex,nasa [max_pages] [file.csv]")
    if not HEADERS["x-api-key"]:
        sys.exit("set TOOLZERHUB_API_KEY first")
    main(*sys.argv[1:])

python instagram_reels.py spacex,bbcnews 30 reels.csv writes both accounts to one CSV; the 30 caps the pages read per account.

What the reels lists showed

Each run went until more_available was false.

Account Reels Calls Oldest
SpaceX 78 7 2022-02-03
BBC News 207 18 2022-12-14
NASA 292 25 2022-08-01
MrBeast 705 59 2022-12-23
  • SpaceX's reels had a median of about 2.4 million plays.
  • Every page held 12 reels except the last, with no repeats. count accepts up to 50, but Instagram serves 12.
  • detail=summary is lighter and faster (median 1.2 seconds a call against 3.2 on SpaceX) but has no date or caption.

What it costs

One credit buys a call of 12 reels. MrBeast's 705 reels took 59 credits, and 1,000 reels are about 84 calls, 84 credits. The 100 free credits a month cover about 1,200 reels; $19 buys 10,000 credits that never expire, and plans for higher volume cover more accounts. Set your key and run the script on your first account.

For comments on a reel, see getting Instagram comments. For the reels ranking on a hashtag, see the Instagram hashtag API.

We are not affiliated with Meta Platforms, Inc. or Instagram.

Get this data from your own code

The Instagram API returns it as JSON with one x-api-key header. 100 free credits monthly.