Complete Guide

Complete Guide to Instagram Scraping API: Extract Posts, Stories, User Data & More

Everything you need to know about scraping Instagram data—from downloading photos and reels to extracting user profiles, comments, and analytics.

Instagram API Photo Scraping Social Media
Instagram mobile app showing photo feed and analytics interface for data scraping

Look, I'm not gonna sugarcoat it—scraping Instagram is a pain. With 2 billion users posting millions of photos and videos daily, it's one of the best data sources out there. But Instagram doesn't exactly roll out the welcome mat for developers. Their official API is locked down tighter than Fort Knox, and their bot detection? Yeah, it's brutal.

I've spent way too much time figuring this stuff out, so I'm gonna save you the headache. This guide walks through all the Instagram endpoints you actually need, what data you'll get, and real code you can copy-paste and start using today.

Why Instagram Scraping Sucks (And Why You Need Help)

Before we get to the good stuff, here's why trying to scrape Instagram on your own is usually a losing battle:

What You're Up Against

  • The official API is basically useless: You need app review, tons of permissions, and even then you can barely access anything
  • Their bot detection is insane: Browser fingerprinting, behavior tracking—they know when you're not a real person
  • Everything needs login: Can't see much without being authenticated, which makes automation even harder
  • Rate limits everywhere: Make too many requests and you're blocked. Sometimes permanently.
  • GraphQL headaches: All the content loads through complex API calls that change constantly

15 Instagram Endpoints That Actually Work

Alright, enough doom and gloom. Here are 15 endpoints that handle all this nonsense for you—profiles, posts, reels, comments, search, the whole deal. I'll show you how each one works with actual examples you can run.

1. Get User Profile by Username

This is probably the one you'll use most. Just throw in a username and you get back everything—follower count, bio, profile pic, the works.

# Get user profile by username
curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/user/by_username",
    "params": {
      "username": "instagram"
    }
  }'

User Profile Data

  • Basic info: Username, full name, biography, profile picture
  • Stats: Follower count, following count, total posts
  • Verification: Verified badge, business account status
  • Contact: Email, website, phone number (if public)
  • Category: Account category/type for business accounts

2. Get User's Posts

Want to grab all the posts from someone's profile? This endpoint's got you. Great for tracking what people are posting or analyzing content patterns.

# Get user's posts by user ID
curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/medias/by_user_id",
    "params": {
      "user_id": "25025320",
      "max_id": ""
    }
  }'

That max_id thing handles pagination. Leave it empty for the first request, then use whatever next_max_id comes back to grab the next batch.

3. Get User's Reels

If you specifically need reels (Instagram's TikTok competitor), this pulls just those. Same idea as regular posts, but filtered to short videos.

# Get user's reels
curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/reels/by_user_id",
    "params": {
      "user_id": "25025320"
    }
  }'

4. Get Post by URL or Shortcode

Got a link to an Instagram post? Drop it in here and you'll get the full details—images, videos, captions, likes, comments, all of it.

# Get post by URL
curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/media/by_url",
    "params": {
      "url": "https://www.instagram.com/p/ABC123xyz/"
    }
  }'

# Or get by shortcode directly
curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/media/by_shortcode",
    "params": {
      "shortcode": "ABC123xyz"
    }
  }'

Post Data Structure

  • Content: Caption, hashtags, mentions
  • Media: Photo URLs, video URLs (HD)
  • Engagement: Like count, comment count, view count
  • Location: Tagged location if available
  • Timestamp: When the post was created
  • Carousel: Multiple images/videos if it's a carousel post

5. Get Post Comments

Need to see what people are saying? This grabs all the comments on a post. Perfect if you're doing sentiment analysis or just want to see the engagement.

# Get post comments
curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/comments/media_comments_by_id",
    "params": {
      "media_id": "2834567890123456789"
    }
  }'

6. Search Users

Looking for influencers or specific accounts? Search by keyword and find users who match.

# Search for users
curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/search/users_by_keyword",
    "params": {
      "keyword": "photography"
    }
  }'

7. Search Hashtags

Want to see how popular a hashtag is or find trending ones? This endpoint's your friend.

# Search hashtags
curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/search/hashtags_by_keyword",
    "params": {
      "keyword": "fitness"
    }
  }'

8. Search Places/Locations

Need posts from a specific location? Search for places and get all the content tagged there.

# Search places
curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint": "/search/places_by_keyword",
    "params": {
      "keyword": "New York"
    }
  }'

What Can You Actually Build With This?

Influencer Analytics Dashboard

Here's a quick example of tracking influencer stats. You grab their profile, pull their recent posts, and calculate engagement rate:

// JavaScript example - Track influencers
async function analyzeInfluencer(username) {
  // Get profile info
  const profileRes = await fetch('https://scrapingbot.io/api/v1/instagram', {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      endpoint: '/user/by_username',
      params: { username }
    })
  });
  
  const profile = await profileRes.json();
  
  // Get their posts
  const postsRes = await fetch('https://scrapingbot.io/api/v1/instagram', {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      endpoint: '/medias/by_user_id',
      params: { user_id: profile.data.id }
    })
  });
  
  const posts = await postsRes.json();
  
  // Calculate engagement rate
  const totalLikes = posts.data.items.reduce((sum, p) => sum + p.like_count, 0);
  const avgLikes = totalLikes / posts.data.items.length;
  const engagementRate = (avgLikes / profile.data.follower_count) * 100;
  
  return {
    username,
    followers: profile.data.follower_count,
    avgLikes,
    engagementRate: engagementRate.toFixed(2) + '%'
  };
}

Brand Monitoring

Want to know when people are talking about your brand? Here's how to track hashtag mentions:

# Python example - Monitor brand hashtags
import requests

def monitor_brand_hashtag(brand_hashtag):
    response = requests.post(
        'https://scrapingbot.io/api/v1/instagram',
        headers={'x-api-key': 'YOUR_API_KEY'},
        json={
            'endpoint': '/search/hashtags_by_keyword',
            'params': {'keyword': brand_hashtag}
        }
    )
    
    data = response.json()
    
    if data['success']:
        hashtag_data = data['data']
        print(f"#{brand_hashtag} Statistics:")
        print(f"  - Total posts: {hashtag_data['media_count']:,}")
        print(f"  - Trending: {'Yes' if hashtag_data.get('is_trending') else 'No'}")
        
        # Get recent posts with this hashtag
        # (would require additional API calls)
        
    return data

monitor_brand_hashtag('mybrand')

Instagram Downloader

Building a tool to download Instagram photos/videos? It's actually pretty simple:

// Download Instagram post
async function downloadInstagramPost(postUrl) {
  const response = await fetch('https://scrapingbot.io/api/v1/instagram', {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      endpoint: '/media/by_url',
      params: { url: postUrl }
    })
  });
  
  const data = await response.json();
  
  if (data.success) {
    const media = data.data;
    
    if (media.video_url) {
      // Download video
      console.log('Video URL:', media.video_url);
      window.open(media.video_url, '_blank');
    } else if (media.image_url) {
      // Download image
      console.log('Image URL:', media.image_url);
      window.open(media.image_url, '_blank');
    }
    
    // For carousel posts, media.carousel_media contains all items
    if (media.carousel_media) {
      media.carousel_media.forEach((item, i) => {
        console.log(`Item ${i + 1}:`, item.image_url || item.video_url);
      });
    }
  }
}

Tips So You Don't Waste Your Time (or Credits)

✅ Smart Moves

  • Cache profiles: People don't change their bio every hour. Cache it and save some credits.
  • Don't grab everything: If you only need the last 10 posts, don't fetch all 1,000. Use pagination smartly.
  • Check if accounts are private: You can't get posts from private accounts anyway, so check that first.
  • Watch your credits: Each API call costs 5 credits. Don't go crazy with unnecessary requests.

⚠️ Mistakes I've Seen (And Made)

  • Adding @ to usernames: Don't. Just use "username", not "@username". The @ will break it.
  • Mixing up IDs and usernames: Some endpoints need the numeric user_id, not the username. Check the docs.
  • Forgetting about private accounts: You can't just scrape someone's private account. The API will return nothing.
  • Not handling errors: Posts get deleted. Accounts get banned. Always check if the response is actually successful.

How to Get Started

Alright, ready to try this out? Here's the 2-minute setup:

🚀 Quick Start

  1. 1
    Sign up — You get 1,000 free credits to test with (that's 20 Instagram API calls)
  2. 2
    Grab your API key — It's sitting in your dashboard the moment you sign up
  3. 3
    Copy one of the examples above — Seriously, just copy-paste and swap in your API key
  4. 4
    Build whatever you want — Analytics tools, downloaders, monitoring systems, you name it

That's It

Look, Instagram scraping doesn't have to be a nightmare. You don't need to deal with login systems, fight with rate limits, or constantly update your code when Instagram changes their API (again).

Whether you're building analytics tools, monitoring your brand, or just need to download some content, these 15 endpoints handle everything. The data comes back clean and consistent. No surprises.

P.S. Got questions or stuck on something? Check the docs or hit up support. I promise they actually respond.

Ready to Start Scraping Instagram?

Skip the complexity and get started in minutes. ScrapingBot handles all Instagram endpoints with a simple API. Get 1,000 free credits—no credit card required.