# Instagram Scraper: Profiles, Posts, Reels & Comments (`stratumics/instagram-scraper`) Actor

Scrape public Instagram profiles, posts, reels and comments without logging in: followers, bio, posts count, captions, likes, video views, media links, tags and music.

- **URL**: https://apify.com/stratumics/instagram-scraper.md
- **Developed by:** [Stratum ICS](https://apify.com/stratumics) (community)
- **Categories:** Social media, Lead generation, Automation
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 profiles

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### What does Instagram Scraper do?

**Instagram Scraper** extracts public **Instagram profiles, posts, reels and comments** without logging in: **followers, following and posts counts, bio, bio links, account type and category** for profiles, and **caption, hashtags, mentions, date, likes, comments count, video views, image and video links, carousel items, location, tagged users, collaborators and music** for every post and reel. Add each post's **comments** with their author, date, likes and reply count when you need them.

Give it usernames or profile links to get each profile's latest posts, page after page, or paste links to single [Instagram](https://www.instagram.com/) posts and reels. Use it from the Apify Console, through the **Apify API** as an Instagram API alternative, or from any AI agent connected to Apify.

### Why use this Instagram scraper?

- **No login, no cookies, no account at risk.** It reads Instagram the way a logged-out visitor's browser does, so there is no account to get banned and nothing to set up.
- **Keeps going when Instagram pushes back.** If Instagram rate-limits the connection, requests move to Apify Proxy datacenter IPs, and to residential IPs if those are refused too, without failing the run.
- **Profiles, posts, reels and comments in one run.** One row per profile, one per post or reel (with a `type` field), and one per comment, all in the same dataset with views to see each kind.
- **Every post, not just the first 12.** The scraper follows the profile grid page by page: a test run saved 110 posts from each of 5 profiles.
- **Video views and music for reels.** `videoViewCount`, `videoDuration`, the MP4 link, and the sound (licensed track with artist, or original audio).
- **All the comments you ask for.** Comments are read page by page, not only the handful shown under a post.
- **Follow accounts on a schedule.** With **Only new posts**, each run saves only posts earlier runs have not saved, so a daily schedule gives you a feed of new posts at the price of the new ones only.
- **Date limit.** Keep only posts newer than a date or a relative value such as "7 days"; reading stops at the first older posts.
- **Fast and cheap to run.** Plain HTTP requests, no browser: 5 profiles with 550 posts took under 3 minutes in our tests.

Typical uses: **influencer research** and vetting (followers, engagement per post, collaborators), **brand and competitor monitoring**, content and hashtag analysis, social listening on comments, collecting reels with their view counts, and building datasets of public posts for research.

### What data can you extract from Instagram?

| Field                                                                        | Example                                                     |
| ---------------------------------------------------------------------------- | ----------------------------------------------------------- |
| `username`, `fullName`, `id`, `url`                                          | natgeo · National Geographic · 787132 · profile link        |
| `followersCount`, `followingCount`, `postsCount`                             | 268,346,973 · 195 · 32,086                                  |
| `biography`, `externalUrl`, `externalUrls`                                   | bio text · every bio link with its title                    |
| `isVerified`, `isPrivate`, `isBusiness`, `accountType`                       | true · false · true · business, creator or personal         |
| `category`, `profilePicUrl`, `profilePicUrlHD`                               | Coffee shop · picture links                                 |
| `type`, `shortcode`, `url`, `mediaType`, `productType`                       | reel · DehZj9wggt0 · post link · video · clips              |
| `caption`, `hashtags`, `mentions`, `timestamp`                               | caption text · WolvesUpClose · bertiegregory · 2026-10-15   |
| `likesCount`, `commentsCount`, `videoViewCount`                              | 48,465 · 345 · 280,340                                      |
| `displayUrl`, `videoUrl`, `width`, `height`, `videoDuration`                 | image link · MP4 link · 1080 · 1920 · 30.0 s                |
| `childPosts`                                                                 | each carousel item with its image or video link and tags    |
| `location`, `taggedUsers`, `coauthors`                                       | New York with coordinates · tagged accounts · collaborators |
| `musicInfo`                                                                  | Rock Around The Clock · Bill Haley, or original audio       |
| `ownerUsername`, `ownerId`, `ownerFullName`                                  | natgeo · 787132 · National Geographic                       |
| Comments: `text`, `ownerUsername`, `timestamp`, `likesCount`, `repliesCount` | comment text · commenter · date · likes · replies           |

Private and missing profiles, and post links Instagram no longer shows, come back as **free rows** with a `status` of `private`, `notFound` or `restricted`, so you can see what happened to every input. Each run also saves a free **summary** per input in the `SUMMARY` record of its key-value store.

### How to scrape Instagram

1. Open the **Input** tab and enter one or more **usernames** (natgeo or @natgeo) or **profile links**. Or paste **post and reel links**.
2. Set **Posts per profile**. This caps what you pay; use 0 for profile rows only.
3. Optionally set **Only posts newer than**, leave out reels, or turn on **comments** with a limit per post.
4. Click **Start**. Rows appear in the **Output** tab as they are saved.
5. Download the results as **CSV, Excel, JSON or HTML**, or send them to Google Sheets, Zapier, Make or n8n.
6. To follow accounts, turn on **Only new posts** and add a **schedule** to the saved task.

### How much does it cost to scrape Instagram?

You pay per row saved:

| Event                                 | Price                     |
| ------------------------------------- | ------------------------- |
| Profile saved                         | $0.001 ($1.00 per 1,000)  |
| Post or reel saved                    | $0.001 ($1.00 per 1,000)  |
| Comment saved                         | $0.0005 ($0.50 per 1,000) |
| Private, missing or restricted inputs | Free                      |

**1,000 posts cost $1.00.** The latest 50 posts of 20 accounts, with their profiles, cost 20 x $0.001 + 1,000 x $0.001 = **$1.02**. Adding 100 comments to each of those 1,000 posts adds 100,000 x $0.0005 = **$50**, so set the comment limit to what you need. Apify's free plan includes $5 of monthly credit, enough for about 5,000 posts.

Larger Apify plans pay less automatically: profiles and posts cost $0.80 per 1,000 on Starter, $0.60 on Scale and $0.50 on Business, and comments $0.40, $0.30 and $0.25. Each run also has a start fee of $0.0005. Video views, carousel items, music and locations are included in the post price.

### Input

See the **Input** tab for every option. The latest 100 posts of two accounts from the last 30 days, with 20 comments each:

```json
{
    "profiles": ["natgeo", "https://www.instagram.com/nasa/"],
    "maxPostsPerProfile": 100,
    "newerThan": "30 days",
    "includeComments": true,
    "maxCommentsPerPost": 20
}
```

Single posts and reels:

```json
{
    "postUrls": ["https://www.instagram.com/p/DelZ5g8l8Pr/", "https://www.instagram.com/reel/DehZj9wggt0/"]
}
```

- **Profiles**: usernames, with or without @, or any profile link (instagram.com/natgeo, instagram.com/natgeo/reels/).
- **Posts per profile** counts the posts saved, newest first. Pinned posts come first, as on the profile grid.
- **Only posts newer than** takes a date (2026-10-01), a date-time in UTC, or a relative value ("7 days", "12 hours"). Pinned older posts are skipped without ending the scan.
- **Only new posts** remembers post ids in the key-value store `instagram-scraper-monitor` in your account, under a key made from your inputs or the **Monitor name** you give.

### Output

You can download the dataset in various formats such as JSON, HTML, CSV or Excel. A profile, a reel and a comment from real runs (media links shortened):

```json
[
    {
        "type": "profile",
        "status": "ok",
        "input": "natgeo",
        "username": "natgeo",
        "url": "https://www.instagram.com/natgeo/",
        "id": "787132",
        "fullName": "National Geographic",
        "biography": "Step into wonder and find your inner explorer with National Geographic 🌎",
        "externalUrl": "http://visitstore.bio/natgeo",
        "externalUrls": [
            { "url": "http://visitstore.bio/natgeo", "title": null },
            {
                "url": "https://ngmdomsubs.nationalgeographic.com/servlet/OrdersGateway?cds_mag_code=NGM&cds_page_id=283562&cds_response_key=I5FX10002",
                "title": "Subscribe Here!"
            }
        ],
        "followersCount": 268346973,
        "followingCount": 195,
        "postsCount": 32086,
        "isVerified": true,
        "isPrivate": false,
        "isBusiness": true,
        "accountType": "business",
        "category": null,
        "profilePicUrl": "https://scontent-iad3-1.cdninstagram.com/v/t51.82787-19/683576066_18653628823019133_9051036240972105113_n.jpg?...",
        "profilePicUrlHD": "https://scontent-iad3-1.cdninstagram.com/v/t51.82787-19/683576066_18653628823019133_9051036240972105113_n.jpg?...",
        "hasReels": true,
        "pronouns": [],
        "scrapedAt": "2026-10-18T05:50:42.468Z"
    },
    {
        "type": "reel",
        "status": "ok",
        "input": "natgeo",
        "id": "4008597565992995700",
        "shortcode": "DehZj9wggt0",
        "url": "https://www.instagram.com/reel/DehZj9wggt0/",
        "mediaType": "video",
        "productType": "clips",
        "caption": "Keeping up with a pack of hunting wolves is just another day at the office for @bertiegregory and his team.\n\n#WolvesUpClose with Bertie Gregory premieres Friday, November 6 at 8/7c on National Geographic. Streaming on @DisneyPlus and @hulu.",
        "hashtags": ["WolvesUpClose"],
        "mentions": ["bertiegregory", "disneyplus", "hulu"],
        "timestamp": "2026-10-15T19:00:02.000Z",
        "likesCount": 48465,
        "commentsCount": 345,
        "likesHidden": false,
        "videoViewCount": 280340,
        "videoDuration": 30.037,
        "displayUrl": "https://scontent-iad3-2.cdninstagram.com/v/t51.82787-15/849098148_18708313780019133_730867734770692515_n.jpg?...",
        "width": 1080,
        "height": 1920,
        "videoUrl": "https://scontent-iad3-1.cdninstagram.com/o1/v/t2/f2/m86/AQPmzWFyFbdQEUSTj3bdWcEdgJrx_FjybCJC5cI7WvE3uOZ2rh-VGb63KeYgGbUc5ovqd29n4IW7ZzvvAKPIhr9epNJVMFjcrAsy4GI.mp4?...",
        "hasAudio": true,
        "childPosts": [],
        "accessibilityCaption": "Video by National Geographic on October 15, 2026. May be an image of wolf, screen, poster and text.",
        "captionEdited": false,
        "location": null,
        "ownerUsername": "natgeo",
        "ownerId": "787132",
        "ownerFullName": "National Geographic",
        "ownerIsVerified": true,
        "coauthors": [
            { "id": "1284886006", "username": "bertiegregory", "fullName": "Bertie Gregory", "isVerified": true },
            {
                "id": "1029649300",
                "username": "natgeoanimals",
                "fullName": "National Geographic Animals",
                "isVerified": true
            }
        ],
        "taggedUsers": [
            {
                "id": "1029649300",
                "username": "natgeoanimals",
                "fullName": "National Geographic Animals",
                "isVerified": true
            },
            { "id": "1284886006", "username": "bertiegregory", "fullName": "Bertie Gregory", "isVerified": true }
        ],
        "musicInfo": {
            "title": "Original audio",
            "artist": "natgeo",
            "audioId": "28762088093432459",
            "isOriginalAudio": true,
            "isExplicit": false
        },
        "scrapedAt": "2026-10-18T05:50:43.871Z"
    },
    {
        "type": "comment",
        "id": "17989722186099677",
        "postId": "4008597565992995700",
        "postShortcode": "DehZj9wggt0",
        "postUrl": "https://www.instagram.com/reel/DehZj9wggt0/",
        "text": "When keeping pace with a hunting wolf pack counts as office work, the commute has officially become wild. 🐺",
        "ownerUsername": "croatia",
        "ownerId": "667579",
        "ownerIsVerified": true,
        "ownerProfilePicUrl": "https://scontent-iad3-1.cdninstagram.com/v/t51.2885-19/103543281_462207271290153_4482713887177207850_n.jpg?...",
        "timestamp": "2026-10-17T08:24:35.000Z",
        "likesCount": 0,
        "repliesCount": 0,
        "scrapedAt": "2026-10-18T05:57:13.267Z"
    }
]
```

### Tips for better results

- **Only posts, no profile rows**: turn off **Save profile rows**. Only profiles: set **Posts per profile** to 0.
- **Engagement rate**: divide `likesCount` plus `commentsCount` by the profile's `followersCount`. Collaboration posts appear on every collaborator's grid; `ownerUsername` is the account that published the post and `input` is the profile you asked for.
- **Download the media soon**: image and video links from Instagram are signed and stop working after a few days.
- **Monitoring**: save the input as a task with **Only new posts** on and schedule it daily. A run with nothing new reads only the first page of each profile and saves no posts.
- **Proxy**: the default connects directly, moves to Apify Proxy datacenter IPs on its own if Instagram rate-limits the connection, and to residential IPs only if the datacenter IPs are refused too. Embed pages, which carry view counts and posts counts, never go through residential IPs in this fallback: if Instagram refuses them directly and on datacenter IPs, posts are saved without view counts for a while (the log says so). The price per row is the same whichever connection is used. Picking a proxy group in the input sends every request through it, embed pages included.

### Integrations and API

- **API**: start runs and download results from any language. The **API** tab has ready code in Python, JavaScript and cURL.
- **Python**: `from apify_client import ApifyClient`, then `client.actor("stratumics/instagram-scraper").call(run_input={"profiles": ["natgeo"], "maxPostsPerProfile": 50})`.
- **JavaScript**: `import { ApifyClient } from 'apify-client'`, then `client.actor('stratumics/instagram-scraper').call({ profiles: ['natgeo'], maxPostsPerProfile: 50 })`.
- **No-code**: Zapier, Make, n8n, Google Sheets and Slack from the **Integrations** tab, for example to post each new reel of a competitor to a Slack channel.
- **AI agents**: connect any MCP-capable assistant to Apify's MCP server (`mcp.apify.com`) and it can call this scraper as a tool to look up profiles and posts.

### FAQ

#### Is it legal to scrape Instagram?

This scraper reads only what Instagram shows to every visitor without logging in, and it never logs in. In Meta v. Bright Data (2024), a US court found that Meta's terms did not bar collecting public data while logged out. Results can still contain personal data: names, usernames, bios and profile pictures of accounts, and commenters' usernames and pictures when you turn comments on. Personal data is protected by the GDPR in the European Union and by other laws around the world, so only collect it when you have a legitimate reason, and consult a lawyer if you are unsure.

#### Do I need an Instagram account or cookies?

No. There is no login, no session cookie and nothing to configure.

#### Can it scrape hashtags, search results, stories or followers?

No. Instagram shows hashtag pages, search, stories and follower lists only to logged-in users, and this scraper never logs in. Profiles, posts, reels and comments are all available logged out.

#### Which reels does it return?

The reels on a profile's grid, mixed with its photo and carousel posts in grid order. Reels an account did not share to its grid are not listed; paste their links to get them.

#### Why can the view count differ from the app?

`videoViewCount` is the view count Instagram's embed page shows for a video. The Instagram app may show a different figure (its own views or plays metric), which logged-out pages do not show. It is empty when Instagram refused the embed page during the run.

#### Why do counts differ slightly from the profile page?

Counts change by the minute on busy accounts. In our checks against Instagram in a logged-out browser, followers, posts, likes and comments matched within that drift, while `followingCount` ran up to about 4% below the number on the profile page, which Instagram updates on its own schedule.

#### What happens with private profiles?

They come back as a free row with `status` set to `private` and the public header (name, followers, following). Their posts are not visible logged out, so none are saved.

#### Found a problem or need a field?

Open an issue in the **Issues** tab with the input you used, and we will look at it.

### Other tools from Stratum ICS

- [Airbnb Scraper](https://apify.com/stratumics/airbnb-scraper): Get every Airbnb listing in a city or from listing links: price per night, rating, reviews, guests, bedrooms, host and Superhost status.
- [App Store Reviews Scraper](https://apify.com/stratumics/app-store-reviews-scraper): Get Apple App Store reviews with star ratings, titles, text, app versions, helpful votes and developer replies, well past Apple's 500-review limit, for any country, plus app ratings.
- [Bilibili Scraper](https://apify.com/stratumics/bilibili-scraper): Scrape Bilibili videos by search, link or uploader without logging in: views, likes, coins, tags, uploader profiles, comments with replies and danmaku, in clean rows.
- [Facebook Ads Library Scraper](https://apify.com/stratumics/facebook-ads-library-scraper): Get ads from the Meta (Facebook) Ad Library by keyword, advertiser page or library link: texts, images, videos, dates, platforms and versions, plus spend for political ads.
- [Facebook Posts Scraper](https://apify.com/stratumics/facebook-posts-scraper): Get posts from public Facebook pages: text, reactions by type, comments, shares, views and media, plus page details with followers, contacts, rating and creation date.
- [Google Ads Transparency Scraper](https://apify.com/stratumics/google-ads-transparency-scraper): Get the ads any advertiser runs on Google Search, YouTube, Shopping, Maps and Play, from the Ads Transparency Center: images, formats, dates, regions and EU reach.
- [Google Maps Reviews Scraper](https://apify.com/stratumics/google-maps-reviews-scraper): Get the Google Maps reviews of any place: rating, full text, exact date, photos, owner reply, reviewer details and food or service scores.
- [Google Maps Scraper](https://apify.com/stratumics/google-maps-scraper): Get the businesses on Google Maps for any search and area: name, address, phone, website, rating, review count, opening hours, plus emails and social profiles.
- [Google News Scraper](https://apify.com/stratumics/google-news-scraper): Get Google News articles with real publisher URLs (not Google redirects), source, date, image, author and optional full text.
- [Google Play Reviews Scraper](https://apify.com/stratumics/google-play-reviews-scraper): Get Google Play reviews with star ratings, text, app versions, thumbs-up counts, developer replies and feature ratings in any language, plus app details with installs and star histogram.
- [Google Trends Scraper](https://apify.com/stratumics/google-trends-scraper): Get Google Trends data as JSON, CSV or Excel: interest over time, interest by region and city, related queries, and trending searches by country.
- [LinkedIn Jobs Scraper](https://apify.com/stratumics/linkedin-jobs-scraper): Scrape LinkedIn jobs with full descriptions, salary ranges, seniority, job type and applicant counts.
- [Reddit Scraper](https://apify.com/stratumics/reddit-scraper): Get Reddit posts and full comment threads from subreddits, searches, user profiles and post links: titles, text, scores, flair, media and replies.
- [Telegram Channel Scraper](https://apify.com/stratumics/telegram-channel-scraper): Get messages from public Telegram channels with views, dates, media, reactions, polls and forwards, plus channel info with exact subscriber counts.
- [Threads Scraper](https://apify.com/stratumics/threads-scraper): Scrape Threads profiles, posts, replies and keyword search: followers, bio, post text, likes, replies, reposts, quotes, media and links.
- [TikTok Comments Scraper](https://apify.com/stratumics/tiktok-comments-scraper): Export TikTok comments and replies from any video or photo post: text, date, likes, reply count, commenter, pinned and creator-liked flags, plus video stats.
- [TikTok Scraper](https://apify.com/stratumics/tiktok-scraper): Scrape TikTok profiles and videos: followers, likes, bio, the latest 10 to 12 videos of each profile, and full stats for any video link.
- [Website Contact Scraper](https://apify.com/stratumics/website-contact-scraper): Turn a list of websites into one row per company with verified emails, formatted phone numbers, social profiles (LinkedIn, Facebook, Instagram, X), address and contact page.
- [YouTube Scraper](https://apify.com/stratumics/youtube-scraper): Get YouTube videos from searches, channels, playlists and links with exact views, likes, comment counts, dates and tags, plus channel profiles and comments.
- [YouTube Transcript Scraper](https://apify.com/stratumics/youtube-transcript-scraper): Get YouTube transcripts and captions as plain text, timed segments, SRT or WebVTT, from video links, whole channels or playlists, in any language YouTube offers.

# Actor input Schema

## `profiles` (type: `array`):

Instagram usernames (natgeo or @natgeo) or profile links (https://www.instagram.com/natgeo/). Each gives a profile row and its latest posts and reels.

## `postUrls` (type: `array`):

Links to single posts or reels, such as https://www.instagram.com/p/DelZ5g8l8Pr/ or https://www.instagram.com/reel/DehZj9wggt0/. Each gives one post row (and its comments when comments are on).

## `includeProfiles` (type: `boolean`):

Save one row per profile with its name, bio, links, follower, following and posts counts, account type and category. Turn off to save only posts.

## `maxPostsPerProfile` (type: `integer`):

How many of each profile's latest posts and reels to save, newest first (pinned posts come first, as on the profile grid). 0 saves only the profile row.

## `includeReels` (type: `boolean`):

Save the reels that appear on each profile's grid along with the photo and carousel posts. Turn off for photo and carousel posts only.

## `newerThan` (type: `string`):

Keep posts from profiles published on or after this date. Use a date (2026-10-01), an ISO date-time in UTC (2026-10-01T12:00:00Z), or a relative value such as "7 days" or "12 hours". Reading a profile stops once its posts get older, so you pay only for posts in the range. Leave empty for no limit.

## `includeComments` (type: `boolean`):

Save the comments of each post saved, one row per comment with its text, author, date, likes and reply count. Comments are charged per comment.

## `maxCommentsPerPost` (type: `integer`):

The most comments to save for each post, in the order Instagram shows them to logged-out visitors (most relevant first). Replies are counted in repliesCount but not saved.

## `onlyNewPosts` (type: `boolean`):

Save only posts that earlier runs with the same inputs have not saved. The Actor remembers post ids in the key-value store instagram-scraper-monitor in your account and stops reading a profile once it reaches posts it has seen. Pair it with a schedule to follow accounts.

## `monitorName` (type: `string`):

Optional. A name for the remembered list (letters, digits and hyphens), so different schedules keep separate histories even with the same inputs. Leave empty to derive it from the inputs.

## `proxyConfiguration` (type: `object`):

With Apify Proxy on (the default), the Actor connects directly, moves to Apify Proxy datacenter IPs if Instagram rate-limits it, and to residential IPs only if the datacenter IPs are refused too. Turn it off to never use a proxy, or pick proxy groups or your own proxy URLs to send every request through them.

## `startConnection` (type: `string`):

For testing the automatic fallback only: the step that API requests start on (direct, datacenter or residential). Embed pages always start direct and never use residential. Ignored when the proxy input picks a proxy or is off.

## Actor input object example

```json
{
  "profiles": [
    "natgeo"
  ],
  "postUrls": [],
  "includeProfiles": true,
  "maxPostsPerProfile": 12,
  "includeReels": true,
  "newerThan": "",
  "includeComments": false,
  "maxCommentsPerPost": 20,
  "onlyNewPosts": false,
  "monitorName": "",
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "startConnection": "direct"
}
```

# Actor output Schema

## `posts` (type: `string`):

No description

## `profiles` (type: `string`):

No description

## `comments` (type: `string`):

No description

## `allFields` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "profiles": [
        "natgeo"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("stratumics/instagram-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "profiles": ["natgeo"] }

# Run the Actor and wait for it to finish
run = client.actor("stratumics/instagram-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "profiles": [
    "natgeo"
  ]
}' |
apify call stratumics/instagram-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,stratumics/instagram-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/HkShlKFbKcW00hNEj/builds/ZMdZEfrt1GdBAvAzO/openapi.json
