A simple CLI tool + Streamlit viewer to track followers and following lists for one or more Instagram accounts.
-
CLI Tracker (
main.py
):- Logs in with Instaloader (supports 2FA, sessions, etc.).
- Fetches a user's current followers/following.
- Compares them to the most recent snapshot to detect who was gained or lost.
- Saves a new snapshot to
[username]/followers/*.txt
and[username]/following/*.txt
.
-
Streamlit Viewer (
viewer.py
):- Allows you to browse snapshots from your browser.
- Compare two snapshots to see who was gained or lost.
- Displays clickable links to
https://instagram.com/username
. - Collapsible sections to keep UI neat, with focus on differences.
-
Clone this repository:
git clone https://github.com/your-username/insta-tracker.git cd insta-tracker
-
Install dependencies:
pip install instaloader rich python-dotenv streamlit pandas
-
Optional: create a
.env
file to store your login:# .env INSTAGRAM_USERNAME=your_ig_username INSTAGRAM_PASSWORD=your_ig_password
This is optional; otherwise you'll be prompted during
main.py
to enter credentials (or load a session file).
Run the tracker once (or schedule it) to grab followers/following:
python main.py
- If it's your first time running:
- You can choose to load an existing session (if you have
SESSION-<USER>
files). - Or use
.env
credentials. - Or type in username/password directly (2FA is supported).
- You can choose to load an existing session (if you have
- The script will:
- Prompt for which user you want to track.
- Fetch followers/following.
- Compare to the last snapshot to see changes.
- Save a new snapshot under
[username]/followers/<timestamp>.txt
and[username]/following/<timestamp>.txt
.
Repeat this daily/weekly for consistent snapshots.
Launch the Streamlit viewer:
streamlit run viewer.py
- Open http://localhost:8501 in your browser.
- Pick a user (any directory that has
followers/
orfollowing/
subfolders). - Choose "followers" or "following."
- Single snapshot or Compare two snapshots.
- Differences appear at the top (lost/gained).
- Links are clickable to open each user's IG profile.
When you log in via Instaloader, it saves a file called SESSION-<INSTAGRAM_USERNAME>
which stores your session cookies. Next time you run main.py
, you can load that session to skip logging in again.
- If you change your Instagram password or the session expires, you'll need to log in again.
After several runs, your project might look like:
.
├─ main.py
├─ viewer.py
├─ tracker_config.json
├─ .env (optional)
├─ SESSION-<account> (example session file)
├─ <tracked-account>/
│ ├─ followers/
│ │ ├─ 2023-12-10_09-00-00.txt
│ │ └─ 2023-12-11_09-00-00.txt
│ └─ following/
│ ├─ 2023-12-10_09-00-00.txt
│ └─ 2023-12-11_09-00-00.txt
├─ ...
└─ ...
Please read the LICENSE file for full details. In short, you are free to use, modify, and distribute this code, provided you include the copyright notice.
- Please open an issue or PR if you’d like to enhance the script or viewer.
- This project is meant for personal usage. Please respect Instagram’s Terms of Service and do not abuse rate limits or violate user privacy.
Use at your own risk. Instagram can change its internal APIs or DOM structure at any time.
This code is not affiliated with or endorsed by Instagram, Meta, or any related entities.