Instagram Posts Search Scraper avatar

Instagram Posts Search Scraper

Pricing

from $8.00 / 1,000 results

Go to Apify Store
Instagram Posts Search Scraper

Instagram Posts Search Scraper

Search Instagram posts by keyword or hashtag (prefix with #). Multiple keywords, date-range filter, auto-pagination. Returns caption, author, likes, comments, views and media URLs. Requires a session (cookies or automated login) — Instagram login-walls all search.

Pricing

from $8.00 / 1,000 results

Rating

0.0

(0)

Developer

code craker

code craker

Maintained by Community

Actor stats

0

Bookmarked

11

Total users

9

Monthly active users

2 days ago

Last modified

Categories

Features

Limited permissions

Share

Apify actor that searches Instagram posts by keyword or hashtag and exports them as structured data.

A session is required. Instagram login-walls ALL search and hashtag pages (there is no anonymous access at all), so the actor authenticates like our Twitter/Facebook actors do — in priority order:

  1. cookies input — a JSON cookie export from a logged-in browser (Cookie-Editor / EditThisCookie); the sessionid cookie carries the session
  2. IG_COOKIES secret env var on the actor (same JSON, or a name=value; ... string)
  3. the cached session from a previous automated login (persistent key-value store)
  4. automated login with igUsername/igPassword (or IG_USERNAME/IG_PASSWORD env vars) — best-effort: Instagram aggressively challenges automated logins, so manually exported cookies are more reliable

Always use a throwaway account, keep the proxy country stable and matching the account's usual region, and expect the account to need an occasional manual login to clear checkpoints.

How it works

A real Chrome (Playwright) opens Instagram's search page (/explore/search/keyword/?q=..., or /explore/tags/... for #hashtag queries) with the session. The page fires Instagram's own search GraphQL query (PolarisKeywordSearchExplorePageRelayQuery); the actor then pages through the results by replaying the pagination query (...RelayPaginationQuery) with the after cursor, reusing the page's own request tokens. Post data is extracted by a generic walker that understands Instagram's media shapes, so it survives layout shuffles.

  • Keywords with no posts. For some broad keywords (e.g. zimbabwe, artificial intelligence) Instagram returns only an accounts/hashtags block and no posts — the web app itself shows "No results". The actor then automatically falls back to the keyword's hashtag (#zimbabwe, #artificialintelligence); those items have matchedVia: "hashtag".
  • Full details. Search results only carry basic fields, so by default (enrichDetails: true) each returned post's full info is fetched (/api/v1/media/{id}/info/) to add views, location, tagged users, coauthors, music, Reel/product type, reshares and alt text (~1–2 s per post).
  • Residential proxy exits are preflighted before the browser launches, and results are pushed after each keyword so an abort keeps partial data.

Input

{
"queries": ["econet", "#zimbabwe"],
"numberOfPosts": 100,
"start_date": "2026-01-01",
"end_date": "2026-06-30",
"enrichDetails": true,
"proxySessionId": "igacct1",
"proxyConfiguration": {
"useApifyProxy": true,
"apifyProxyGroups": ["RESIDENTIAL"],
"apifyProxyCountry": "US"
}
}
  • numberOfPosts applies per keyword.
  • start_date / end_date (yyyy-mm-dd, inclusive, UTC) are enforced actor-side from each post's timestamp — Instagram search has no date operators and ranks by relevance, not date. Only posts inside the range count toward numberOfPosts, so pagination continues past out-of-range posts (up to 60 pages per keyword). A narrow or old range can therefore return fewer posts than requested. timeSince / timeUntil are still accepted as aliases.
  • scrapeAll: false returns only the first results page.
  • debug: true saves every API/GraphQL response, a screenshot, the HTML and raw media samples to the run's key-value store.

Output

One dataset item per post:

{
"id": "3672339888759474360",
"code": "DK9xY2LMnPq",
"url": "https://www.instagram.com/reel/DK9xY2LMnPq/",
"text": "Full caption of the post... #harare @econet",
"hashtags": ["harare"],
"mentions": ["econet"],
"username": "some_user",
"fullName": "Some User",
"userId": "1234567890",
"profileUrl": "https://www.instagram.com/some_user/",
"profilePicUrl": "https://scontent.cdninstagram.com/...",
"isVerified": false,
"isPrivateAccount": false,
"likes": 42,
"likesHidden": false,
"comments": 7,
"commentsDisabled": false,
"views": 1250,
"reshares": 3,
"mediaType": "video",
"isVideo": true,
"productType": "clips",
"isReel": true,
"displayUrl": "https://scontent.cdninstagram.com/...",
"images": ["https://scontent.cdninstagram.com/..."],
"videoUrl": "https://scontent.cdninstagram.com/...",
"videoDuration": 16.37,
"hasAudio": true,
"width": 720,
"height": 1280,
"alt": null,
"carouselCount": null,
"childPosts": [],
"location": { "id": "213385402", "name": "Harare, Zimbabwe", "shortName": null, "address": null, "city": null, "lat": -17.8, "lng": 31.0 },
"taggedUsers": [{ "username": "friend", "fullName": "Friend", "userId": "5", "isVerified": false, "profilePicUrl": "..." }],
"coauthors": [],
"music": { "title": "Original audio", "artist": "some_user", "audioId": "123", "isOriginalAudio": true },
"isPaidPartnership": false,
"sponsors": [],
"created_at": "2026-07-01T09:30:12.000Z",
"createdUtc": 1782898212,
"searchQuery": "econet",
"matchedVia": "keyword"
}

mediaType is image, video or carousel; carousels list every slide in childPosts (type, image/video URL, size) and images. productType: "clips" marks Reels. Missing values are null / empty arrays.

Integration (scraping-tool)

Call it like the other outspoken_strategy/* search actors:

const res = await this.scrapingService.scrape({
url: `https://www.instagram.com/explore/search/keyword/?q=${encodeURIComponent(keyword)}`,
resultsLimit: requestCount,
actor: 'outspoken_strategy/instagram-post-search-scraper',
timeout,
additionalInput: {
query: keyword,
numberOfPosts: requestCount,
headless: true,
proxyConfiguration: { useApifyProxy: true, apifyProxyGroups: ['RESIDENTIAL'], apifyProxyCountry: 'US' }
},
scrapeType: 'instagram-keyword-search'
});

Set IG_COOKIES (or IG_USERNAME/IG_PASSWORD) as secret env vars on the actor — same pattern as TW_COOKIES/FB_COOKIES — and optionally IG_PROXY_SESSION to pin the account to one exit IP. Normalization hints: url and id are ready to use; text is the caption; likesCount ← likes, commentsCount ← comments, viewsCount ← views, createdTime ← created_at; author fields are username/fullName/userId/profileUrl.

Local development

npm install
cat > storage/key_value_stores/default/INPUT.json <<'JSON'
{ "query": "artificial intelligence", "numberOfPosts": 30,
"cookies": [ ...exported from a logged-in browser... ],
"proxyConfiguration": { "useApifyProxy": false } }
JSON
npm start

Deploy with apify push.