A local React app that runs the Apify Instagram Scraper actor and displays results in the browser.
-
Copy the environment file and add your Apify API token:
cp .env.example .env
Edit
.envand setAPIFY_TOKEN=your_token_here. -
Install dependencies and start dev servers (API + Vite):
npm install npm run dev
-
Open the URL shown by Vite (usually
http://localhost:5173).
- URLs mode: paste one or more Instagram URLs (profile, post
/p/, reel, etc.) and choose what to scrape (posts, profile details, comments, etc.). - Search mode: enter a hashtag, profile, or place search query with a search type and limits.
- Connections mode (Instagram connected): export your following or followers list, including private accounts your session can see.
Instagram does not offer an official OAuth scope for follower/following lists or other users’ private profiles. This app uses your browser session cookies after you log in:
- Click Login with Instagram and sign in on instagram.com.
- Export cookies for
instagram.comwith Cookie-Editor (JSON format). - Paste the JSON and click Connect account.
Cookies are kept in sessionStorage in your browser and sent to your API only when you scrape. With a connected account:
- Connections tab: export following/followers (yours or another username you can view).
- Direct URLs + content type details: read private profile metadata your account can access.
Public scrapes without a connected account still use the Apify Actor as before.
Results appear after the run finishes. Use Download JSON to export items.
| Command | Description |
|---|---|
npm run dev |
Start API server and Vite dev server |
npm run dev:server |
API only (port 3001) |
npm run dev:client |
Vite only |
npm run build |
Production frontend build |
npm start |
Run production server (API + built UI) |
npm run start:server |
Same as npm start |
- Push the repo to GitHub and import it in Vercel.
- Vercel reads
vercel.jsonautomatically:- Build:
npm run build→ static files indist/ - API:
api/index.js(Express) handles/api/*
- Build:
- In the Vercel project → Settings → Environment Variables, add:
APIFY_TOKEN= your Apify token (all environments you use)
- Deploy.
Or from the CLI:
npm i -g vercel
vercel
vercel env add APIFY_TOKEN
vercel --prodCheck: open https://<your-project>.vercel.app/api/health — expect {"ok":true,"hasToken":true}.
Timeouts: Scraping waits for the Apify Actor to finish. That can take minutes. vercel.json sets maxDuration: 300 (5 minutes), which needs a Vercel Pro plan. On the Hobby plan the limit is 10 seconds, so long scrapes will fail with a timeout — use a VPS/Railway/Render with npm start instead, or upgrade Vercel.
Do not set a custom “Output Directory” in the Vercel UI if it conflicts with vercel.json; the repo config already points to dist.
This app needs one Node process that serves both the React UI and /api/*. Static-only hosting (GitHub Pages, S3 without a proxy) will return 404 on scrape requests because there is no API.
On the remote machine:
git clone <your-repo>
cd instagram-scraper
npm ci
npm run build
export APIFY_TOKEN=your_token_here
export PORT=3001 # optional; platform often sets PORT automatically
npm startSet APIFY_TOKEN in your host’s environment variables (not only in a local .env file unless you copy it to the server).
Platform settings (typical):
| Setting | Value |
|---|---|
| Build command | npm ci && npm run build |
| Start command | npm start |
| Port | Use the platform’s PORT (the server reads process.env.PORT) |
Health check: GET /api/health should return {"ok":true,"hasToken":true} when the token is set.
Reverse proxy (nginx): proxy all traffic to the Node port, e.g. proxy_pass http://127.0.0.1:3001;
Process manager (PM2):
npm run build
pm2 start server/index.js --name instagram-scraperThis Actor is paid per result. Keep resultsLimit low while testing. Scraping public Instagram data may be subject to Instagram’s terms and applicable privacy laws; use responsibly.