# How do I get Instagram posts for a hashtag through an API?

> Instagram's Hashtag Search needs App Review and a business account, and allows 30 tags a week. Pull public posts for any hashtag by name: fields, cost, Python and limits.

Canonical page: https://okdata.online/answers/instagram-hashtag-posts-api/

**Short answer: **Call Instagram hashtag posts with the tag's name, without the #: each page returns about 10 public posts with caption, author, likes, comments and time posted, for $0.004. There is no business account, App Review or weekly hashtag limit, but you get a sample of the tag rather than every post, and not in time order. Five pages for each of 20 hashtags cost $0.40.

A camping-gear brand wants to see what people post under #vanlife, #overlanding and a dozen smaller tags each week, to spot photos worth licensing and creators worth contacting. Instagram's own route is [Hashtag Search](https://developers.facebook.com/docs/instagram-platform/instagram-api-with-facebook-login/hashtag-search) in the Graph API. It needs an Instagram Business or Creator account connected to your app, and App Review for the Instagram Public Content Access feature. Each account can query 30 unique hashtags in any rolling 7 days. The `recent_media` edge only returns posts from the last 24 hours, and you cannot request the `username` of the accounts that posted them. That last rule is why people asking for "all posts for a hashtag, with who posted them" keep hitting a wall.

[Instagram hashtag posts](/apis/instagram/hashtags/posts/list/) takes the tag as `id` and returns each post with its author.

## Steps

1. **List the tags.** Mix the big generic tag with the specific ones your buyers use. The small tags are often more useful than the big one.
2. **Page through each tag** with `cursor`, a few pages per tag.
3. **Merge and rank.** One post often carries several of your tags, so remove duplicates by `id`, then sort by `metrics.likes` and `metrics.comments`.
4. **Go deeper on the keepers.** [Instagram post detail](/apis/instagram/posts/get/) ($0.004) adds plays for reels, every image of a carousel and the other authors of a collab post. For a reel, [Instagram reel transcript](/apis/instagram/posts/transcript/get/) returns what is said in it ($0.004, videos up to two minutes).

## A weekly pull

```python
import csv, os, requests

API = "https://api.okdata.online"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}
TAGS = ["vanlife", "overlanding", "rooftoptent", "campervan"]

def tag_posts(tag, max_pages=5):
    cursor = None
    for _ in range(max_pages):
        params = {"id": tag, **({"cursor": cursor} if cursor else {})}
        body = requests.get(API + "/v1/instagram/hashtags/posts/list", headers=H, params=params, timeout=60).json()
        if body["code"] != "ok":
            raise RuntimeError(f"{body['code']}: {body['message']}")
        yield from body["data"]["items"]
        if not body["page"]["has_more"]:
            return
        cursor = body["page"]["next_cursor"]

posts = {}
for tag in TAGS:
    for p in tag_posts(tag):
        posts.setdefault(p["id"], {**p, "tags": set()})["tags"].add(tag)

score = lambda p: (p["metrics"]["likes"] or 0) + (p["metrics"]["comments"] or 0)
with open("hashtag-posts.csv", "w", newline="", encoding="utf-8") as f:
    w = csv.writer(f)
    w.writerow(["url", "author", "likes", "comments", "published_at", "tags", "caption"])
    for p in sorted(posts.values(), key=score, reverse=True):
        w.writerow([p["url"], p["author"]["username"], p["metrics"]["likes"], p["metrics"]["comments"],
                    p["published_at"], " ".join(sorted(p["tags"])), p["text"][:200]])
```

## Cost

| Job | Calls | Cost |
|---|---|---|
| One tag, 5 pages | 5 | $0.02 |
| 20 tags, 5 pages each | 100 | $0.40 |
| The same every week for a month | 400 | $1.60 |
| Detail on the 50 best posts | 50 | $0.20 |

A list call is charged even when a page comes back empty or fails at the data source; only calls refused before that, such as bad parameters, are free.

## Limits

- Posts come in the order search engines found them. You get a sample of the tag, not its full history, and you cannot ask for everything posted in the last 24 hours.
- Paging ends after a limited number of pages per tag. To see more, add related tags rather than paging deeper.
- Now and then a page comes back without author names or counts, and `meta.unavailable` lists the fields left empty. Fetch those posts with post detail if you need them.
- Stories are not included, and neither are posts from private accounts.

## When the Graph API is the better choice

If you already run an approved business app and need the newest posts under your own campaign tag within hours, `recent_media` returns up to 50 posts a page from the last 24 hours, and `top_media` returns the most popular ones. Thirty tags a week is enough for one branded campaign. For research across many tags, or without a business account, the sample here is simpler to get. The [content research page](/solutions/content-research/) has more on this job.

## Endpoints used

- [Instagram hashtag posts](https://okdata.online/apis/instagram/hashtags/posts/list/) `instagram.hashtags.posts.list`: $0.004 per call · about 10 posts per page
- [Instagram post detail](https://okdata.online/apis/instagram/posts/get/) `instagram.posts.get`: $0.004 per call
- [Instagram reel transcript](https://okdata.online/apis/instagram/posts/transcript/get/) `instagram.posts.transcript.get`: $0.004 per call

## More about Instagram

- [Instagram API](https://okdata.online/apis/instagram/)
- [Instagram API in Python: profiles, posts and comments (2026)](https://okdata.online/guides/instagram-api-python/)
- [Is there an MCP server that lets Cursor search TikTok, Instagram and Reddit?](https://okdata.online/answers/cursor-mcp-tiktok-instagram-reddit/)
- [How do I find Instagram creators in a niche and sort them by follower count?](https://okdata.online/answers/find-instagram-creators-by-niche/)
- [How can I get the comments on someone else's Instagram post through an API?](https://okdata.online/answers/instagram-comments-api-other-accounts/)
- [How do I get the transcript of an Instagram reel?](https://okdata.online/answers/instagram-reel-transcript-api/)
- [How do I get an Instagram account's follower count through an API?](https://okdata.online/answers/instagram-follower-count-api/)
- [Hashtag posts API](https://okdata.online/roles/topics-posts-list/)
- [Post detail API](https://okdata.online/roles/posts-get/)
- [Transcript API](https://okdata.online/roles/transcripts-get/)

## Sources

Where people asked this (read 2026-11-15): 

- https://stackoverflow.com/questions/43655098
- https://stackoverflow.com/questions/79335781
- https://stackoverflow.com/questions/74022819

Updated 2026-11-15
