Instagram Posts Search Scraper
Pricing
from $8.00 / 1,000 results
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
Maintained by CommunityActor stats
0
Bookmarked
11
Total users
9
Monthly active users
2 days ago
Last modified
Categories
Features
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:
cookiesinput — a JSON cookie export from a logged-in browser (Cookie-Editor / EditThisCookie); thesessionidcookie carries the sessionIG_COOKIESsecret env var on the actor (same JSON, or aname=value; ...string)- the cached session from a previous automated login (persistent key-value store)
- automated login with
igUsername/igPassword(orIG_USERNAME/IG_PASSWORDenv 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 havematchedVia: "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"}}
numberOfPostsapplies 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 towardnumberOfPosts, 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/timeUntilare still accepted as aliases.scrapeAll: falsereturns only the first results page.debug: truesaves 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 installcat > storage/key_value_stores/default/INPUT.json <<'JSON'{ "query": "artificial intelligence", "numberOfPosts": 30,"cookies": [ ...exported from a logged-in browser... ],"proxyConfiguration": { "useApifyProxy": false } }JSONnpm start
Deploy with apify push.