Instagram Hashtag Scraper

How to scrape Instagram hashtags, step by step

Published

To scrape an Instagram hashtag you need three things: a signed-in session for an Instagram account you control, a tool that reads the hashtag feed with that session, and a stopping rule (a row limit, a date, or both). Instagram only serves hashtag posts to signed-in requests, so every working method starts from a session. After that, the job is to read the recent feed page by page, keep the fields you need, drop duplicates, and stop at the right place. This guide walks through that job start to finish: by hand, with a script, and with a ready-made scraper, and it says when each one is the sensible choice.

If your goal is a research dataset with a written method, read how to build an Instagram hashtag dataset you can trust as well. This page is about the scrape itself: the mechanics of getting posts out.

Before you start: what scraping a hashtag actually means

A hashtag page on Instagram is a feed. It holds the most recent public posts that used the tag, newest first, and it loads more as you scroll. Scraping it means doing that scrolling with a program and writing down each post as a row.

A useful row usually carries:

Three facts shape everything below:

  1. There is no signed-out path. When we tested it in September 2026, a signed-out visitor got the hashtag page shell with no posts in it. Our guide to searching Instagram hashtags without an account covers what still works without one.
  2. The feed is recent, not complete. It is built for scrolling, so "every post ever made with #coffee" is not something any method returns. Plan around a time window.
  3. The same post can show up twice. Feeds shift while you page through them. Deduplicate on the shortcode or your counts will be wrong.

Step 1: set up an account you control

Use a separate Instagram account for scraping, never your personal one. Any tool that reads Instagram with your session makes requests as that account, and Instagram can rate limit or restrict an account that reads a lot. Pick an account you are willing to lose.

  1. Create the account with a work or research email.
  2. Sign in through a normal browser and use it briefly like a person would.
  3. Keep it for reading only. It does not need followers or posts.

Step 2: get the session cookie

Tools that read Instagram for you need two cookie values from that account: sessionid and csrftoken.

  1. Open https://www.instagram.com in a browser signed in to the scraping account.
  2. Open DevTools with F12, or Ctrl + Shift + I (Cmd + Option + I on a Mac).
  3. Go to the Application tab (Storage in Firefox), then Cookies, then https://www.instagram.com.
  4. Copy the value of sessionid and of csrftoken.
  5. Join them on one line: sessionid=<value>; csrftoken=<value>.

Treat that line like a password. Anyone holding it can act as the account until the session ends. Logging the account out in the browser ends the session, which is also how you revoke a tool's access.

Sessions do expire on Instagram's own schedule. When a scrape that worked last week starts failing with a login or refusal message, capture a fresh cookie first.

Step 3: decide where the scrape stops

This is the step people skip, and it decides your cost and your data quality. A busy hashtag produces posts faster than you will ever read them, so "scrape #travel" is not a finished instruction. Pick at least one of these:

Stopping ruleExampleGood for
A row limit500 postsA sample of what people post under a tag
A start datePosts newer than 7 daysWatching a tag over a known period
A date window1 August to 31 AugustA campaign, an event, a report period
A page limit50 feed pagesA hard ceiling on how many requests a run makes

A date that stops the run is much cheaper than a date applied afterwards. If a tool fetches everything and filters by date at the end, you pay for everything it read on the way, not just the week you wanted. You want the scrape to stop when the feed reaches your date.

Step 4: run the scrape

Here are the three realistic ways to do the reading itself, from least to most automatic.

The manual way

Open the tag in the Instagram app or website with your account, scroll the recent posts, and copy each one's link, date, account and caption into a spreadsheet. It needs no tools and no cookie handling.

It is slow, you lose your place easily, and counts are read by eye. For more than a few dozen posts, it stops being practical.

The script way

Open-source Python libraries can read Instagram with a session, and a short script can page through a hashtag feed and write rows to a file. Our comparison of Python Instagram API options shows the code for each approach, and the round-up of Instagram scraper GitHub projects covers which ones still run.

A script gives you full control. It also leaves you owning every part of the job: the stopping rule, deduplication, retries when a request fails, and repairs when Instagram changes the shape of its responses. That last one is the real cost, because it happens without warning and a broken parser often returns empty results that look like a quiet hashtag.

The ready-made way

A hosted scraper does the paging, parsing and deduplication for you and writes rows to a dataset you download as JSON, CSV or Excel. You supply the hashtag, the session cookie and your stopping rule.

Instagram Hashtag Scraper is one of these, built for exactly this job. You run it on Apify with these inputs:

InputWhat to put in it
hashtagThe tag, with or without the #
sessionCookieThe sessionid=...; csrftoken=... line from Step 2
resultsLimitThe most posts you want. The limit is exact: you never get or pay for more
onlyPostsNewerThanA date like 2026-08-01, a datetime, or a window like 7 days. The run stops when the feed reaches it
onlyPostsOlderThanOptional. Skips posts newer than this, so the two together give you a window
maxPagesA ceiling on feed pages, so a huge tag cannot page on forever

It charges $0.0005 per post delivered to your dataset and nothing else, so a run that finds nothing costs nothing. The getting started page has the cookie steps with a picture of the DevTools panel.

Step 5: check how the run ended

A scrape that returns 40 rows might mean the tag only had 40 posts in your window. It might also mean the session was refused halfway. Those two results look the same in a spreadsheet and mean opposite things. Before you trust a small result, find out why the scrape stopped.

With a script, that means logging the reason your loop exited. With Instagram Hashtag Scraper, the run's status message names the end state: result limit reached, date cutoff reached, feed ran out, session refused, rate limited, hashtag not found, and a few more. A run that could not reach Instagram fails as a failure instead of finishing with an empty dataset. The run outcomes list says what to do about each one.

Step 6: clean and read the data

A few habits make the rows usable:

If the destination is a spreadsheet, how to export Instagram posts to Excel covers the columns and the tidy-up.

How to scrape a hashtag on a schedule

Many hashtag jobs are ongoing: a branded campaign tag, a product name, an event. The pattern that keeps repeated scraping cheap is simple:

  1. Run once with a start date covering the period you care about.
  2. Schedule later runs with onlyPostsNewerThan set to the gap between runs, for example 1 day for a daily run.
  3. Append each run's rows to your store and deduplicate on the shortcode.

Because each run stops at the date, a daily run only reads a day of the feed. With per-row billing, a day with no new posts costs nothing. Our overview of Instagram hashtag tracker options compares this with monitoring tools that store the history for you.

Which method fits your job

You want toMethod that fits
Look at a few dozen posts onceManual
Full control, and time to maintain codeA script
Rows in a dataset without maintaining a parserA ready-made scraper
A tag watched every dayA ready-made scraper on a schedule
Just how busy a common tag isThe free hashtag checker, no scrape needed

When the manual way is enough

Not every hashtag question needs a scraper. Scroll by hand when:

Reach for a script or a scraper when you need the same collection again next week, when you need counts you can compare, or when the number of posts is more than you would scroll through in one sitting.

Summary

Scraping an Instagram hashtag comes down to six steps: a separate account, its session cookie, a stopping rule, the scrape itself, a check of why it stopped, and a cleanup that keeps missing values missing. The manual way works for small one-off looks. Scripts give control at the cost of maintenance. A ready-made scraper like Instagram Hashtag Scraper gives you rows with an exact limit, a date that stops the run, and a charge only for posts it delivers.

All articles