Open In App

How to Get Count of Instagram followers using Node.js ?

Last Updated : 23 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

To get the count of Instagram followers using Node.js, you can use several approaches. The most common methods involve using Instagram's unofficial APIs, scraping data from Instagram, or leveraging third-party APIs that provide access to Instagram data. Instagram's official API requires you to have proper authentication and permissions, which might not directly allow fetching follower counts unless you own the account or have the necessary permissions.

Approach

To get Instagram follower count using Node.js, install instagram-followers npm package, define a default route and a dynamic route that accepts a username, fetches the follower count, and returns it.

Steps to Setup Project to count Instagram followers

Step 1: Create a directory for our project and set it as our working directory.

mkdir node-app
cd node-app

Step 2: Use the npm init command to create a package.json file for our project.

npm init

Note: Keep pressing enter and enter “yes/no” accordingly at the terminus line.

Step 3: Install the necessary packages/libraries in your project using the following commands.

npm install express instagram-followers

Project Structure

The updated dependencies in package.json file will look like:

"dependencies": {
"express": "^4.19.2",
"instagram-followers": "^1.0.0"
}

Step 5: Creating a basic server. Write down the following code in the index.js file.

Node
// index.js

const express = require('express');
const app = express();
  
app.get('/' , (req , res)=>{
    res.send("GeeksforGeeks");
});
  
// Server setup
app.listen(4000 , ()=>{
    console.log("server is running on port 4000");
});

Output: We will get the following output on the browser screen.

GeeksforGeeks

Step 6: Now let's implement the functionality by which we get the Instagram follower's count.

Node
// index.js

const express = require('express');
const followers = require('instagram-followers');
const app = express();
  
app.get('/' , (req , res)=>{
    res.send("GeeksforGeeks");
});
  
app.get('/:username' , (req , res) => {
    followers(req.params.username).then((count) => {
        if(!count){
            res.send("Account Not Found");
            return;
        }
        res.send("Username " + req.params.username + 
            " have " + "<b>" +  count + "</b>" + " followers");

    });
});

// Server setup
app.listen(4000 , ()=>{
    console.log("server is running on port 4000");
});

Step 7: Run the server using the following command.

node index.js

Output:


Similar Reads