Posts API

Instagram Posts API

Retrieve Instagram posts, captions, and engagement metrics programmatically. Get a user's media feed with likes, comments, and post metadata in structured JSON.

Get Free API Key →

Get Instagram Posts via API

Pass a public Instagram username and get its media feed as JSON. The documented username endpoint handles the profile lookup and media request for you.

Code Examples

# Get recent posts for a public Instagram username
curl -H 'Authorization: Bearer gs_your_api_key' \
  'https://gramscraper.com/api/instagram/v1/user/medias/by/username?username=instagram'
import requests

url = "https://gramscraper.com/api/instagram/v1/user/medias/by/username"
headers = {"Authorization": "Bearer gs_your_api_key"}
params = {"username": "instagram"}

response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
print(response.json())
const response = await fetch(
  'https://gramscraper.com/api/instagram/v1/user/medias/by/username?username=instagram',
  { headers: { 'Authorization': 'Bearer gs_your_api_key' } }
);

if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());

Common Media Fields

A media item can include fields like these. The enclosing response and available fields depend on the post type and current API schema.

{
  "id": "...",
  "media_type": 1,
  "code": "...",
  "caption_text": "Example caption",
  "like_count": 123,
  "comment_count": 12,
  "taken_at": "2026-08-16T12:00:00Z",
  "thumbnail_url": "https://..."
}

Post Fields Returned

id

Unique post identifier

media_type

1 = image, 2 = video, 8 = carousel

code

Post shortcode (for URL)

caption_text

Full post caption

like_count

Number of likes

comment_count

Number of comments

taken_at

Post timestamp

thumbnail_url

Thumbnail URL when supplied

video_url

Video URL when supplied

user

Post author details

resources

Child resources for multi-item media

product_type

Instagram media product type

Use Cases

Simple, Credit-Based Pricing

API usage is charged in credits, and endpoint costs are listed in the API docs. Credits never expire.

Free
100 credits
$29
15,400 credits
$300
320,000 credits

Frequently Asked Questions

How do I get Instagram posts via API?

Use GramScraper's /v1/user/medias/by/username endpoint. Pass a public Instagram username and receive that user's media feed as JSON.

What post data does the API return?

The API returns post captions, like counts, comment counts, media type (image, video, or carousel), media URLs at multiple resolutions, timestamps, shortcodes, and author information.

Can I get posts from any Instagram user?

The API returns publicly available posts from public Instagram accounts. Posts from private accounts are not accessible via the API.

Get Instagram Posts Data Now

Start with 100 free credits. Standard adds 15,400 credits for $29.

Get Free API Key →