How to scrape data from Instagram: profiles, comments, posts and photos

Learn how to scrape Instagram data with our unofficial Instagram API.

Content

We're Apify. We've created 1,500+ data extraction tools and unofficial APIs for popular websites, including Instagram. Check us out.

The limitations of the Instagram APIs brought about the need to find alternatives to get around these limitations such as Instagram Scraper. This scraper is one of the first web scrapers developed and published on Apify Store. It was developed as an unofficial Instagram API to help extract data from Instagram.

30K+ users and a few behind-login policies from Instagram later, it's still going strong, enabling users to extract data from profiles, posts, comments and media. And the best part: you don't have to have deep technical knowledge to be able to use this scraper. You won't have to use a terminal, line up queries, get authorization tokens, and all that jazz. So let's learn how to use it together.

๐Ÿ’ฟ Why not use the official Instagram API for scraping?

Instagram does provide two free public APIs that can be used for various purposes, including web scraping and data extraction. But would those APIs be enough for scraping Instagram?

Not really. The official public Instagram API comes in two forms: Instagram Basic Display API and Instagram Graph API. Both of them allow you to programmatically access posts on Instagram. However, the extent and scope of it varies depending on the API type.

โ—๏ธ
In short, official Instagram APIs wonโ€™t allow you to get posts made by regular users, extract profile info, comments, reels, or a list of posts that share a particular hashtag. Last but not least, you have to have technical knowledge to be able to use them.

Instagram Basic Display API

The secret lies in its name. Instagram Basic Display API is, well, basic. You can use it to scrape Instagram profiles but the data output will be limited to very basic IG post data such as username, account type, caption, media type, media URL, permalink, timestamp, and thumbnail. You cannot use Instagram Basic Display API to scrape comments, stories, reels, promoted posts, and IGTV content. Needless to say, accessing Basic Display API has a few prerequisites: you should have/submit a Facebook developer account, an Instagram account, and a public website of your own.

Instagram Graph API

You can use the Instagram Graph API to find mentions, get basic data on other businesses such as the number of followers, likes, number of comments, or get hashtagged photos. You cannot use Instagram Graph API to get regular Instagram user data; it is created specifically for Instagram business accounts and creators. Besides, accessing this API requires an Instagram Business or Creator account, a Facebook page connected to this account, a Facebook Developer account, and a registered Facebook App with basic settings.

You don't have to jump through any of these loops if you're using Instagram Scraper. And you don't have to apply any technical skills unless you want to.

๐Ÿ›  How does this Instagram web scraper work?

It's built to take a list of Instagram profile URLs, and then search for and scrape page details, posts, or comments from those URLs. By a similar logic, it can scrape Instagram feed guided by one or multiple search queries.

All of the resulting data gets stored in a structured form as a dataset, from which you can download it in formats such as JSON, XML, Excel, CSV, etc. Or extract it using API Endpoints or a Client which turns this scraper into a full-fledged Instagram API of its own.

โ—๏ธ
Before you get started scraping Instagram, note that we do not consider web scraping vast amounts of personal data ethical and discourage anyone from doing so. Besides, our scraper does not extract personal information such as gender or age.

๐Ÿ“ What data can I extract from Instagram?

It is free to use and will let you download public data from Instagram, namely:

  • Profiles
  • Hashtags (top 50 results)
  • Comments (up to 50 per post)
  • User and place searches (via Google Search)
  • Likes

To see why we have such precise limitations on hashtags and comments, see the โ“FAQ section below. Here's a more detailed list of what your regular Instagram dataset could look like:

๐Ÿ†” Profile ID, username, full name, and URL ๐Ÿ“ Bio and external URLs ๐Ÿ“ธ Profile picture URLs
๐Ÿ“Š Followers and follows count ๐Ÿ“บ IGTV video and highlight reel count โœ… Verified status
๐Ÿ“ Post ID, caption and hashtags ๐Ÿ”— Post URL and shortcode ๐Ÿ—จ๏ธ Comments and likes count
โฐ Timestamp ๐Ÿ‘ฅ Mentions in the post ๐Ÿ–ผ๏ธ Image URL
๐Ÿ”ต Business account and category ๐Ÿ”’ Private account ๐Ÿ‘ Post likes count
๐Ÿ“… Joined recently status ๐Ÿ“ก Has channel status ๐Ÿ‘ฅ Related profiles

๐ŸŽž How to scrape Instagram 101

Let's learn how to use Instagram Scraper to extract data from Instagram profiles and their posts. This step-by-step guide should get you started in just a few minutes.

Step 1. Go to Instagram Scraper

In the Apify Store, search for Instagram and find this Instagram Scraper page. Once you find it, go straight for the Try for free button.

Step 1. Go to Instagram Scraper
Step 1. Go to Instagram Scraper

If you don't have an Apify account yet, you can sign up for free using your email account, Google, or GitHub. After this, you will be redirected to Apify Console, which is your workspace to run tasks for your scrapers such as scraping profiles, posts, hashtags, and so on.

You can sign up for free using your email account, Google, or GitHub.
You can sign up for free using your email account, Google, or GitHub.

Step 2. Add Instagram URLs or search queries

Head over to the Instagram website and pick the profiles you want to scrape. Copy and paste each profile URL into the input. You can add as many profiles as you want using the + Add button, or upload a whole list of them at once using the Bulk edit button nearby.

Then choose Details from the drop-down list of what you want to scrape. Now insert the maximum number of items you want to scrape in the Max items field. We're going to put 200.

instagram scraping.png
Step 2. Add Instagram URLs or search queries
Step 2. Add Instagram URLs or search queries

You can also choose other parameters of this scraper such as Add metadata, Get tagged posts, Add time frame. You can also set it up to scrape comments and posts, or scrape Instagram feed using search queries. We don't have to set these for now, feel free to explore these in your next run.

Step 3. Click Start โ–ถ๏ธ to run the web scraper

Once you are all set, click the Start button. Your task will change its status to Running ๐Ÿƒ๐Ÿปโ€โ™€๏ธ, so just wait for the scraper's run to finish. It will be a minute before you see the status switch to Succeeded โœ… โ€” 10 seconds in our case.

Step 3. Click Start โ–ถ๏ธ to run the web scraper
Step 3. Click Start โ–ถ๏ธ to run the web scraper

Each username we scraped will come up as a separate result, which is why our output says 3 results. At the end of the run, you will see a preview table with Output results.

Step 4. Export your Instagram data

Now you can move to the Storage tab to view all the results of your scraping. This tab contains your data in lots of versatile formats: HTML table, JSON, CSV, Excel, XML, and RSS feed.

You can open them by clicking on View in another tab, Preview, or Download. You can then share the data, or upload it anywhere you like. You can also clean and preprocess the scraped data before downloading it by removing any irrelevant information.

Here, in our example, we only want username, latest posts, follows count, related profiles, and some other details such as bio, profile pic, and URL in our dataset. In order to export only that data, weโ€™ll choose the relevant tags from the list of Selected fields before downloading them.

Step 5. Bonus: integrate your data, export it using API, or set up a scraping schedule

The previous four steps are really all you need to get started for scraping Instagram. But the Apify platform has much more to offer such as scheduling scraping, exporting data using an API or connecting it with integration platforms such as Zapier or Make. Make sure to check out those opportunities as well!

Step 5. Bonus: integrate your data, export it using API, or set up a scraping schedule
Step 5. Integrate your data, export it using API, or set up a scraping schedule

๐Ÿ’ฌ Just want to extract Instagram posts, comments or photos?

You can use the Instagram data scraper from this tutorial to scrape data from Instagram in multiple different ways. However, if you want to scrape specific Instagram data, let's say comments only, you might like our dedicated Instagram web scrapers more.

Compared to the original IG Scraper, there are fewer settings to change and you'll get fast, precise results. As a rule, all you have to do is paste one or more Instagram URLs (or usernames) and click to scrape.

๐Ÿ“ท Instagram Post Scraper ๐Ÿ’ฌ Instagram Comments Scraper ๐Ÿ‘ค Instagram Profile Scraper ๐Ÿท๏ธ Instagram Mentions Scraper ๐ŸฆฟInstagram API Scraper
๐ŸŽž๏ธ Instagram Reel Scraper #๏ธโƒฃ Instagram Hashtag Scraper ๐Ÿ” Quick Instagram Posts Checker ๐Ÿ“Š Instagram Hashtag Stats ๐Ÿ’ฏ Instagram Followers Count Scraper
๐ŸŽž
To learn how to use a simpler Instagram scraper to extract IG posts, check out this tutorial โ†’

Quick tutorial on how to use one of the Instagram web scrapers

โ“ FAQ

What about Instagram data available without login?

There isn't much Instagram data that's publicly available without login.

Search. You used to be able to search for profiles, hashtags, and places, and Instagram would return the top 100 posts. Not anymore. The search feature on Instagram.com is not available directly unless you log in or think of workarounds such as Google Search. Which is why the number of scraped results might turn out in a different order than compared to native Instagram search.

Profiles, hashtags, and locations. When you open any public Instagram page that contains posts (e.g. profile, hashtag or location), Instagram will show you a page with the first few posts preloaded. However, you can not see further than just a couple of posts โ€” they simply won't be displayed. With an exception for profile which still has the See more posts button that has to be clicked every time. And even that will get you so far.

Comments. Every Instagram post used to have publicly visible comments and a Load more comments button for infinite scrolling. That data is not available without login anymore.

Our scrapers do not support logging into Instagram, so there are some limits on what you can and cannot scrape. Our scraper is capable of getting around those limitations (such as using proxies or Google Search results) but only to an extent.

Example of Instagram data put behind the login wall
Example of Instagram data put behind the login wall

Can I get Instagram data available only after login?

In theory, yes. But this is not what our scraper can do. If you check the Instagram website in an incognito browser window, youโ€™ll quickly find that there's very little data that you can view and access freely without logging in. Most Instagram data is either blocked or requires you to log in, for example: list of followers or list of people a user follows.

Although it would be possible to automatically log in to Instagram to access this data, this approach is risky since it can lead to the banning of your account by Instagram. Sure, you could create a fake Instagram account and use that instead, but thatโ€™s beyond the scope of this article and against Instagram's terms and conditions. We don't recommend that you do this and none of our scrapers support it.

Over time, Instagram has been increasingly limiting the data you can access without login, so youโ€™ll need to test to see what you can scrape without logging in.

Can I create my own Instagram scraper on your platform?

Yes, you can build your own Instagram scraper on the Apify platform in Python or JavaScript โ€” either just for deployment or for full production โ€” and take advantage of built-in proxies, infrastructure, scheduling, and storage. If the platform seems too limiting, you can also make good use of our free web scraping library.

Do you need proxies to scrape Instagram?

These days, you generally need proxies to have a successful and generally reliable scraping process. Social media websites often use blocking technologies to prevent scraping. We recommend using residential proxies as the most reliable way to go about scraping anything from Meta in 2024. Fortunately, our free plan offers a free trial of residential proxies, so you can fully test this scraper tool on getting data from Instagram, Facebook or Threads.

Can I use this scraper with API?

This Instagram Scraper is one of many Actors available in Apify Store. As with the other Actors, you can use this scraper directly on the platform with a few clicks, or using an API or scheduler. So basically, you can consider it your own personal Instagram API. You can call this Instagram web scraper using an API Client in Python, JavaScript, and curl. You can also use available API Endpoints to get the scraped Instagram data to where you need it.

Scraping publicly available data is legal, but you need to be careful not to extract content that is protected by copyright or contains personal information. So, after scraping Instagram, double-check your output for data that would go against GDPR, CCPA, or could be considered intellectual property. Read more about the legality of web scraping in our blog post on the subject.

Can I scrape both Instagram users and Threads users?

Since Instagram and Threads share userbase, you can scrape both Threads users and Instagram users since they share the same usernames and profiles. By using scraping techniques, you can extract data from both platforms simultaneously and get insights into user profiles and their activities on both Meta platforms. You may want to check out our Threads Profile Scraper as well.

How to scrape Threads
Find out what data you can extract by scraping Threads.
Natasha Lekh
Natasha Lekh
Crafting content that charms both readers and Googleโ€™s algorithms: readmes, blogs, and SEO secrets.

Get started now

Step up your web scraping and automation