Have you ever wondered how many people you follow on GitHub but haven’t followed you back? Well, you can manually check, but that’s time-consuming. Instead, let's automate it with GitHub API and JavaScript!
This guide will help you build a GitHub Follow-Back Checker using JavaScript, which will:
✅ Fetch your followers and following lists.
✅ Identify users who haven't followed you back.
✅ Display both follow-back and not-following-back users.
✅ Run in Node.js or directly in the browser console.
Let's get started! 🚀
🔑 Step 1: Generate a GitHub Personal Access Token (PAT)
Since GitHub API requires authentication, we need a Personal Access Token (PAT).
- Go to GitHub Token Settings.
- Click "Generate new token".
- Select the scope "read:user".
- Copy and save the token (it will only be shown once!).
📥 Step 2: Clone the Repository
git clone https://github.com/vibhuthakur9911/github-followback-checker.git cd github-followback-checker
📌 Step 3: JavaScript Code (GitHub API)
Create a file github-follow-check.js
and add the following script:
const GITHUB_USERNAME = "your-username"; // 🔹 Replace with your GitHub username const GITHUB_TOKEN = "your-personal-access-token"; // 🔹 Replace with your GitHub token const API_URL = "https://api.github.com"; async function fetchGitHubData(endpoint) { let users = []; let page = 1; while (true) { const response = await fetch(`${API_URL}/users/${GITHUB_USERNAME}/${endpoint}?per_page=100&page=${page}`, { headers: { Authorization: `token ${GITHUB_TOKEN}` } }); if (!response.ok) { console.error(`Error fetching ${endpoint}:`, response.statusText); return []; } const data = await response.json(); if (data.length === 0) break; users = users.concat(data.map(user => user.login)); page++; } return users; } async function checkFollowBack() { const following = await fetchGitHubData("following"); const followers = await fetchGitHubData("followers"); const notFollowingBack = following.filter(user => !followers.includes(user)); const followingBack = following.filter(user => followers.includes(user)); console.log("\n✅ These users have followed you back:"); followingBack.forEach(user => console.log(`- ${user}`)); console.log("\n❌ These users haven't followed you back:"); if (notFollowingBack.length > 0) { notFollowingBack.forEach(user => console.log(`- ${user}`)); } else { console.log("🎉 Everyone you follow has followed you back!"); } } checkFollowBack();
🚀 Step 4: Running the Script
✅ Option 1: Run in Node.js
node github-follow-check.js
✅ Option 2: Run in Browser Console
- Open GitHub and log in.
- Press F12 to open the Developer Console.
- Copy-paste the script above.
- Press Enter to execute.
🎯 Expected Output
If some users haven't followed you back:
✅ These users have followed you back: - user1 - user2 - user3 ❌ These users haven't followed you back: - user4 - user5 - user6
If everyone has followed you back:
✅ These users have followed you back: - user1 - user2 - user3 - user4 🎉 Everyone you follow has followed you back!
🔥 Conclusion
This GitHub Follow-Back Checker automates the tedious task of checking who hasn’t followed you back. It's a great example of using GitHub API, JavaScript, and Node.js together.
📌 Want more features? You can extend this script to:
- Export data to CSV for easy tracking.
- Send alerts via email/notification when someone unfollows you.
- Build a web interface to visualize the data.
💡 Feel free to contribute to the project! Happy coding! 🚀
💬 Share Your Thoughts!
Did you find this tool helpful? Have suggestions for improvements? Drop a comment below or connect with me on GitHub! 😊
Top comments (0)