# Instagram API get user posts: Meta's 10K cap and a script

> Meta lists your own posts, 10K at most, and other accounts only via Business Discovery. Ours pages any public account by username, 50 posts a call.

- URL: https://toolzerhub.com/blog/instagram-api-get-user-posts
- Published: 2026-10-16; updated 2026-10-17
- Publisher: ToolzerHub (we sell the API this post describes)

## Short answer

- Meta's API reads your own posts, at most the 10K most recent, and only for Business and Creator accounts. Other accounts' posts come only through Business Discovery.
- ToolzerHub's /v1/instagram/user/posts reads a public account by username, up to 50 posts per call at 1 credit. It paged SpaceX to the end: 1,087 posts in 22 calls.
- The posts list can leave out reels, so use the reels route for those: MrBeast's posts list held 211 reels and his reels list 705.

Instagram's official API gets posts only from Business and Creator accounts: your own through the media edge, which returns at most the 10,000 most recent, and other accounts through Business Discovery. It does not read personal accounts. ToolzerHub reads a public account's posts by username, 50 a call, and the script below saves any list of accounts to CSV.

## What Meta's API is for

Meta's [media edge](https://developers.facebook.com/documentation/instagram-platform/instagram-graph-api/reference/ig-user/media) lists your own posts, up to the 10K most recent, and takes `since` and `until` for time ranges. It works for professional accounts only; for why the personal-account APIs ended, see our [Basic Display replacement post](https://toolzerhub.com/blog/instagram-basic-display-api-replacement). Business Discovery is the only official route to another account's posts: you call it on your own professional account with the other account's username, the target must be a Business or Creator account, and you build the next-page URL from its cursors yourself. Use Meta's API for your own account or your customers' with their consent.

## Get a public account's posts with ToolzerHub

We make ToolzerHub. Our [Instagram API](https://toolzerhub.com/apis/instagram) reads a public account's posts from a username, with one API key and no Meta app, Facebook Page or professional account of your own. `GET /v1/instagram/user/posts` takes `username_or_url` (or `user_id`), `count` up to 50 and a `cursor`, and costs 1 credit per call. It returns `more_available` and `next_max_id`, which you pass back as `cursor`.

Each post has `code`, `taken_at`, `product_type`, `like_count`, `comment_count` and `caption`. `view_count` was null on the NASA reel we checked, while `/v1/instagram/user/reels` returned `play_count` 9,955,101 for the same post, the plays shown on the owner's Reels tab. This script pages every username you give it to one CSV.

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

import requests

URL = "https://api.toolzerhub.com/v1/instagram/user/posts"
HEADERS = {"x-api-key": os.environ.get("TOOLZERHUB_API_KEY", "")}
FIELDS = ["username", "code", "posted", "type", "likes", "comments", "caption", "url"]
calls = 0
FAILED = object()  # marks a 400 or a 503 that outlasted the retries, so the run can tell it from "empty"


def cell(value):
    # Spreadsheets run text that starts 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=3):
    # 429 and 503 are retryable; 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:  # bad username: skip this account, keep the rest of the run
            print("bad request:", r.json()["error"]["message"].splitlines()[0])
            return FAILED
        if r.status_code not in (429, 503) or attempt == tries - 1:
            if r.status_code == 503:  # an unknown username also ends here
                return FAILED
            if r.status_code >= 400:
                sys.exit(f"HTTP {r.status_code}: {r.text[:200]}")
            return r.json().get("data")  # None when there is nothing to return
        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, name, max_pages):
    params, seen, pages, more, failed = {"username_or_url": name, "count": 50}, set(), 0, False, False
    while pages < max_pages:
        data = get(params)
        if data is FAILED:
            failed = True
            break
        if not data or not data.get("items"):
            break  # null data, a private account or no posts
        pages += 1
        for m in data["items"]:
            if m["code"] in seen:  # pages can repeat a post
                continue
            seen.add(m["code"])
            writer.writerow({
                "username": cell(name), "code": m["code"],
                "posted": datetime.fromtimestamp(m["taken_at"], timezone.utc).isoformat(timespec="minutes"),
                "type": m.get("product_type"), "likes": m.get("like_count"),
                "comments": m.get("comment_count"),
                "caption": cell(((m.get("caption") or {}).get("text") or "").replace("\n", " ")),
                "url": f"https://www.instagram.com/p/{m['code']}/",
            })
        more = bool(data.get("more_available") and data.get("next_max_id"))
        if not more:
            break
        params["cursor"] = data["next_max_id"]
        time.sleep(0.3)
    if failed:
        status = " (gave up: bad request or 503 after retries; unknown usernames end up here)"
    elif not pages:
        status = " (nothing returned: private or empty)"
    else:
        status = " (stopped at the page cap, more available)" if more else " (reached the end)"
    print(f"{name}: {len(seen)} posts, {pages} pages{status}")
    return len(seen)


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


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

The script strips spaces and a leading `@`, de-duplicates by `code`, and reports whether each account ended or hit your page cap. `python instagram_posts.py spacex,mrbeast 30 posts.csv` wrote 1,589 posts to one CSV. The `type` column uses Instagram's labels, and `clips` are reels. Pinned posts can come first, so sort by `posted` for newest first.

## How deep the list goes

We compared each list with the account's post count from `/v3/instagram/user/details` (`media_count`, 3 credits). "Reached" means `more_available` turned false.

| Account | Profile count | Rows read | Calls | End |
|---|---:|---:|---:|---|
| SpaceX | 1,087 | 1,087 | 22 | reached |
| MrBeast | 520 | 502 | 11 | reached |
| Taylor Swift | 713 | 701 | 15 | reached |
| NASA | 4,967 | 2,000 | 40 | not reached |

SpaceX matched its profile count exactly. MrBeast ended 18 short and Taylor Swift 12 short, so expect a small gap. We stopped NASA at 2,000 rows after 40 calls, with `more_available` still true.

## Reels in the posts list

The posts list can leave out reels. MrBeast's posts list held 211 reels, while `/v1/instagram/user/reels` listed 705 for the same account, 12 a call. Our [Instagram reels API post](https://toolzerhub.com/blog/instagram-reels-api) covers that list.

## What it costs

Each call is 1 credit and returns 50 posts, so 1,000 posts cost 20 credits. SpaceX's 1,087 posts took 22 credits and MrBeast's 502 took 11. The 100 free credits a month cover about 5,000 posts; $19 buys 10,000 credits that never expire, and [plans for higher volume](https://toolzerhub.com/pricing) cover more accounts. Set your key and run the script on your first account.

For comments on one post, see [how to export Instagram comments](https://toolzerhub.com/blog/export-instagram-comments). To turn usernames into user IDs first, see [Instagram API get user ID](https://toolzerhub.com/blog/instagram-api-get-user-id). For posts by tag rather than by account, see [the Instagram hashtag API](https://toolzerhub.com/blog/instagram-hashtag-api).

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