Support needed? Reach out! 📧

How to Scrape Instagram User Posts And Media

This tutorial shows how to use Instagram User Posts And Media API to scrape and crawl structured Instagram data in real-time.
Extract full Instagram post feeds for any public account including captions, media URLs, like counts, and comment totals, useful for content benchmarking and competitive research.

Access Instagram Data in 3 Steps

Start crawling Instagram user posts data. Follow these steps to extract social media data in minutes.

1

Create Your Account

Go to our registration page and make an account. It's free, no credit card, and you get credits right away to play around with.

2

Verify Your Email Address

You'll get a verification email, click the link in it. Once that's done, you can grab your API token from the dashboard.

3

Make Your First API Call

Copy the code snippet below, swap in your API key, and run it. You'll get Instagram data back as JSON within a few seconds.

Code Sample

Here's a JavaScript example to get you going. Swap out the token and you're good, works the same way in any language that can make HTTP requests. Start collecting user posts data via our REST API!

javascript-logo JavaScript
Instagram User Posts
1 const root = 'https://ensembledata.com/apis'
2 const endpoint = '/instagram/user/posts'
3 const params = {
4   "user_id"18428658,
5   "depth"1,
6   "oldest_timestamp"1666262030,
7   "chunk_size"10,
8   "start_cursor""",
9   "alternative_method": false,
10   "token""YOUR-TOKEN-HERE"
11 }
12  
13 const queryString = new URLSearchParams(params).toString();
14 const url = `${root}${endpoint}?${queryString}`;
15  
16 await fetch(url)
17   .then(response => response.json())
18   .then(data => console.log(data))
19   .catch(error => console.error(error));
20  

Parameters

user_id (integer) ID of the user. REQUIRED
depth (integer) Abstraction of the API pagination. Depth 1 returns X results, depth N returns N * X results. Note that the exact number of results per depth (X) may differ per endpoint. Please refer to the specific endpoint description for more information. REQUIRED
oldest_timestamp (integer) This parameter is used as a stopping condition for fetching posts. If a post older than the provided `oldest_timestamp` is found, the system will stop fetching posts and return the results. For instance, if depth is 10, the system will aim to send 10 requests. However, if an `oldest_timestamp` is set, and we find a post which is older than the `oldest_timestamp`, the system will not send any more requests and return the results. Note: we do not filter out posts older than the provided `oldest_timestamp` before returning the results. Please do this filtering in your own integration if required.
chunk_size (integer) The number of posts to fetch per depth. If alternative_method=False, the maximum allowed chunk_size is 20. If alternative_method=True, the maximum chunk_size is 12.
start_cursor (string) Parameter to manually handle pagination. Each response contains a `last_cursor` which can be used to retrieve the next page of results by sending it as the next `start_cursor`. If the `last_cursor` is not present in the response, it means that there are no more results to retrieve.
alternative_method (boolean) If true, use a different method to fetch the user posts from the ID (this method returns at least 1 non pinned post when `start_cursor` is an empty string). The response JSON will be differ from the default method.
token (string) Private token assigned to each client to access the APIs. REQUIRED

Example Response

Explore the fields returned by this endpoint. Click a row to expand nested objects and arrays, hover a value to copy it, or use "Expand all" to see everything at once.

JSON
Instagram User Posts
dataobject3 fields
countnumber6255
postsarray1 item · schema from #0 1 item
nodeobject39 fields
__typenamestring"GraphSidecar"
idstring"3439159241662512720"
gating_infonullnull
fact_check_overall_ratingnullnull
fact_check_informationnullnull
media_overlay_infonullnull
sensitivity_friction_infonullnull
sharing_friction_infoobject2 fields
should_have_sharing_frictionbooleanfalse
bloks_app_urlnullnull
dimensionsobject2 fields
heightnumber1346
widthnumber1080
display_urlstring"https://instagram.fcai2-1.fna.fbcdn.net/v/t51.29350-15/456322559_53133…"
display_resourcesarray3 items · schema from #0 3 items
srcstring"https://instagram.fcai2-1.fna.fbcdn.net/v/t51.29350-15/456322559_53133…"
config_widthnumber640
config_heightnumber797
is_videobooleanfalse
media_previewnullnull
tracking_tokenstring"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLC…"
has_upcoming_eventbooleanfalse
edge_media_to_tagged_userobject1 field
edgesarray0 items
empty
accessibility_captionnullnull
edge_media_to_captionobject1 field
edgesarray1 item · schema from #0 1 item
nodeobject1 field
textstring"🧁"
shortcodestring"C-6WRvdS75Q"
edge_media_to_commentobject2 fields
countnumber4653
page_infoobject2 fields
has_next_pagebooleantrue
end_cursorstring""
edge_media_to_sponsor_userobject1 field
edgesarray0 items
empty
is_affiliatebooleanfalse
is_paid_partnershipbooleanfalse
comments_disabledbooleanfalse
taken_at_timestampnumber1724199751
edge_media_preview_likeobject2 fields
countnumber642848
edgesarray0 items
empty
ownerobject2 fields
idstring"18428658"
usernamestring"kimkardashian"
locationnullnull
nft_asset_infonullnull
viewer_has_likedbooleanfalse
viewer_has_savedbooleanfalse
viewer_has_saved_to_collectionbooleanfalse
viewer_in_photo_of_youbooleanfalse
viewer_can_resharebooleantrue
thumbnail_srcstring"https://instagram.fcai2-1.fna.fbcdn.net/v/t51.29350-15/456322559_53133…"
thumbnail_resourcesarray5 items · schema from #0 5 items
srcstring"https://instagram.fcai2-1.fna.fbcdn.net/v/t51.29350-15/456322559_53133…"
config_widthnumber150
config_heightnumber150
coauthor_producersarray0 items
empty
pinned_for_usersarray0 items
empty
edge_sidecar_to_childrenobject1 field
edgesarray6 items · schema from #0 6 items
nodeobject17 fields
__typenamestring"GraphImage"
idstring"3439159231763742324"
gating_infonullnull
fact_check_overall_ratingnullnull
fact_check_informationnullnull
media_overlay_infonullnull
sensitivity_friction_infonullnull
sharing_friction_infoobject2 fields
should_have_sharing_frictionbooleanfalse
bloks_app_urlnullnull
dimensionsobject2 fields
heightnumber1346
widthnumber1080
display_urlstring"https://instagram.fcai2-1.fna.fbcdn.net/v/t51.29350-15/456322559_53133…"
display_resourcesarray3 items · schema from #0 3 items
srcstring"https://instagram.fcai2-1.fna.fbcdn.net/v/t51.29350-15/456322559_53133…"
config_widthnumber640
config_heightnumber797
is_videobooleanfalse
media_previewstring"ACIqwC9Co0mdoLY5OBTWG0kHse3StvSoD5bP13YGO/Gf60thpXMKlAJ6VPPEY5GQ9if8f5…"
tracking_tokenstring"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLC…"
has_upcoming_eventbooleanfalse
edge_media_to_tagged_userobject1 field
edgesarray0 items
empty
accessibility_captionnullnull
last_cursorstring"QVFDbnZzcllvOW56YTZtUExNd2JuVV9nZXNyLTdoOVl1cTFSQmtkbzFRdXY5R0p1bXFvdE…"

Response Codes

Status codes this endpoint can return, so you can handle errors before they surprise you in production.

200SuccessSuccessful Response
422Client ErrorValidation Error
471Client ErrorUser restricted
472Client ErrorPrivate user
473Client ErrorUser not found
474Client ErrorProfile not available in region
491Client ErrorToken not found
492Client ErrorEmail not verified
493Client ErrorSubscription expired
495Client ErrorAll daily units used
500Server ErrorSomething went wrong

API Pricing

#returned_posts units Cost per successful call to this endpoint.
Example Cases
1
User does not exist Result: 0 posts
1 unit
2
User is private Result: 0 posts
1 unit
3
User exists and does not have posts Result: 0 posts
1 unit
4
User exists, depth 5, chunk_size 10 Result: 50 posts
50 units
5
User exists, depth 5, chunk_size 10 and has only 15 posts Result: 15 posts
15 units
6
User exists, depth 5, chunk_size 10 and has only 5 posts more recent than timestamp Result: 5 posts
5 units

Fetch Instagram Data at Scale

Collect Instagram posts in bulk for trend analysis, content benchmarking, or building datasets for academic or industry research.

deco-icon

Full Post History

Paginate through a creator's entire public Instagram feed history.

deco-icon

Captions & Media

Get captions and direct media URLs returned for every post.

deco-icon

Engagement Stats

Pull like and comment counts for each post automatically.