This is the Express.js + TypeScript backend for the Instagram Analytics dashboard.
It exposes REST endpoints for:
- Logging in via Instagram credentials
- Fetching followers (
/api/followers
) - Fetching following (
/api/following
) - Identifying non-followers (
/api/non-followers
) - Aggregating top likers (
/api/top-likers
)
-
Clone this repo and install dependencies:
git clone git@github.com:Instagram-Analysis/instagram-analytics-BE.git cd instagram-analytics-BE npm install
-
Create a
.env
file in the project root with:PORT=4000 FRONTEND_URL=http://localhost:3000 SESSION_SECRET=your-session-secret # For future Graph API use: INSTAGRAM_GRAPH_TOKEN=your-long-lived-token
-
Run in development:
npm run dev
The server listens on http://localhost:4000.
npm run dev
— start withts-node-dev
and hot-reloadnpm run build
— compile TypeScript todist/
npm start
— run the compiled code
Historical note: We initially used the unofficial
instagram-private-api
to log in with raw credentials, but ran into persistent two-factor and checkpoint challenges that were difficult to automate.Current direction: Migrating to the official Instagram Graph API. In the upcoming version:
- Users will authenticate via OAuth (no raw passwords or 2FA handling in our code).
- We’ll exchange the OAuth code for a long‐lived access token.
- Followers, following, and media metrics will be fetched via:
GET https://graph.instagram.com/me/followers?access_token=…
GET https://graph.instagram.com/me/following?access_token=…
GET https://graph.instagram.com/me/media?fields=id,like_count&access_token=…
Until the migration is complete, the existing private-API login (with 2FA challenge) remains active. Expect an update soon!
MIT