Instagram Scraper in Python: 3 Ways That Work in 2026
Instagram has no official API for public data you don't own, so Python developers scrape it one of three ways: a local open-source library, a cloud scraping platform, or hand-rolled requests against private endpoints. Two of those work reliably in 2026. Here's the code for both — and why we'd skip the third.
Method 1: Instaloader (free, runs locally)
Instaloader is the standard open-source choice: MIT-licensed, actively maintained, and good for small jobs from your own machine.
pip install instaloader
import instaloader
L = instaloader.Instaloader()
profile = instaloader.Profile.from_username(L.context, "natgeo")
print(profile.followers, profile.biography)
# Iterate recent public posts
for post in profile.get_posts():
print(post.date_utc, post.likes, post.caption[:80])
if post.likes < 1000:
break
The catch: every request comes from your IP. Instagram rate-limits hard — expect 401 Unauthorized or temporary blocks after a few hundred requests. Fine for a nightly job on a handful of profiles; painful for anything bigger unless you add paid proxies.
Method 2: Apify client (cloud, no proxy management)
For anything beyond hobby scale, it's cheaper in practice to let a platform handle proxies, retries and parsing. The Apify Instagram Scraper has an official Python client, a free tier (~3,300 posts/month), then $1.50 per 1,000 posts.
pip install apify-client
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN") # free account token
run = client.actor("apify/instagram-scraper").call(run_input={
"directUrls": ["https://www.instagram.com/natgeo/"],
"resultsType": "posts",
"resultsLimit": 200,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item["timestamp"], item["likesCount"], item["caption"][:80])
- No proxies, no rate-limit handling, no HTML parsing — you get clean JSON
- Runs on Apify's infrastructure, so your IP and accounts are never exposed
- Same actor also does hashtags, comments, reels and profile metadata (
resultsType)
Method 3: requests + private endpoints (don't)
Tutorials still float around showing how to hit Instagram's internal GraphQL endpoints with requests and a session cookie. In 2026 this is the worst option: the endpoints change without notice, logged-in scraping risks the account you used, and Meta actively fingerprints these clients. Everything it offers, the two methods above do more safely.
Which method should you use?
| Approach | Cost | Scale ceiling | Maintenance |
|---|---|---|---|
| Instaloader | Free | ~hundreds of requests/day per IP | You handle blocks & retries |
| Apify client | Free tier, then $1.50/1k posts | Effectively unlimited | None — managed |
| Private endpoints | "Free" + burned accounts | Low | Constant breakage |
Not a Python person after all? The same Apify scraper runs entirely in the browser with no code, and there's a REST API if you're integrating from another language.
Skip the proxy headaches
Free tier ≈ 3,300 posts/month — enough to test any pipeline before paying a cent.
Get your free Apify token →