Instagram Posts Scraper API: Extract Post Data at Scale
Need to analyze Instagram content? This guide shows you how to extract posts, captions, engagement metrics, and media from any public Instagram profile.
What Post Data Can You Extract?
| Field | Description |
|---|---|
| Post ID | Unique identifier |
| Shortcode | URL-friendly ID |
| Caption | Full post text |
| Hashtags | Used hashtags |
| Likes | Like count |
| Comments | Comment count |
| Type | Photo, Video, Carousel |
| Media URL | Image/video URLs |
| Timestamp | When posted |
| Location | Tagged location |
| Tagged Users | Mentioned accounts |
Using the Posts Scraper API
const response = await fetch('https://api.sociavault.com/instagram/posts', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
handle: 'natgeo'
})
});
const posts = await response.json();
Sample Response
{
"posts": [
{
"id": "3123456789012345678",
"shortcode": "ABC123xyz",
"caption": "Stunning sunset over the African savanna 🌅 #nature #photography",
"hashtags": ["nature", "photography"],
"likes": 1250000,
"comments": 8500,
"type": "photo",
"mediaUrl": "https://...",
"timestamp": "2026-01-08T18:30:00Z",
"location": {
"name": "Serengeti National Park",
"id": "123456789"
},
"taggedUsers": ["photographer_name"]
}
],
"hasMore": true,
"cursor": "next_page_cursor"
}
Use Cases
Content Performance Analysis
Identify what content performs best:
const posts = await getInstagramPosts('competitor');
// Calculate average engagement
const avgLikes = posts.reduce((sum, p) => sum + p.likes, 0) / posts.length;
const avgComments = posts.reduce((sum, p) => sum + p.comments, 0) / posts.length;
// Find top performers
const topPosts = posts
.sort((a, b) => b.likes - a.likes)
.slice(0, 10);
console.log('Top performing content:', topPosts.map(p => p.shortcode));
Hashtag Analysis
Extract most-used hashtags from a profile:
const hashtagCounts = {};
posts.forEach(post => {
post.hashtags.forEach(tag => {
hashtagCounts[tag] = (hashtagCounts[tag] || 0) + 1;
});
});
const topHashtags = Object.entries(hashtagCounts)
.sort((a, b) => b[1] - a[1])
.slice(0, 20);
Posting Schedule Analysis
Discover optimal posting times:
const postsByHour = {};
posts.forEach(post => {
const hour = new Date(post.timestamp).getHours();
postsByHour[hour] = (postsByHour[hour] || 0) + 1;
});
// Find most common posting hour
const peakHour = Object.entries(postsByHour)
.sort((a, b) => b[1] - a[1])[0][0];
console.log(`Most common posting hour: ${peakHour}:00`);
Content Type Distribution
Analyze the mix of content types:
const typeCount = posts.reduce((acc, post) => {
acc[post.type] = (acc[post.type] || 0) + 1;
return acc;
}, {});
console.log('Content mix:', typeCount);
// { photo: 45, video: 30, carousel: 25 }
Pagination for All Posts
Get a profile's complete post history:
async function getAllPosts(handle) {
let allPosts = [];
let cursor = null;
do {
const response = await fetch('https://api.sociavault.com/instagram/posts', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ handle, cursor })
});
const data = await response.json();
allPosts = [...allPosts, ...data.posts];
cursor = data.hasMore ? data.cursor : null;
} while (cursor);
return allPosts;
}
Related Endpoints
- Instagram Profile Scraper - Profile data
- Instagram Reels API - Reels-specific content
- Instagram Post Info - Single post details
- Instagram Comments - Post comments
Frequently Asked Questions
How many posts can I retrieve per request?
Each request returns up to 12 posts by default. Use pagination to get more posts.
Can I get posts from private accounts?
No, only public profiles are accessible. Private accounts restrict content to approved followers.
Do I get the actual image/video files?
The API returns URLs to media files. You can download these URLs if needed for your use case.
How far back can I get posts?
You can access a profile's entire public post history, going back to their first post.
Are Instagram Stories included?
No, Stories are ephemeral and not included in posts. Use the Highlights endpoint for saved story content.
Get Started
Create your account and start extracting Instagram posts.
API documentation: /docs/api-reference/instagram/posts
Found this helpful?
Share it with others who might benefit
Ready to Try SociaVault?
Start extracting social media data with our powerful API. No credit card required.