A Python-based Instagram automation framework with a CLI interface, scheduling, and optional Telegram integration. Use this repository to build, test, and run automation workflows that interact with Instagram accounts (posting, monitoring, notifying). Use at your own risk — automating actions on third-party platforms may violate their Terms of Service.
- About
- Features
- Repository Structure
- Requirements
- Installation
- Configuration
- Usage
- Database & Persistence
- Development
- Troubleshooting
- Contributing
- Security & Responsible Use
- License
- Contact
This project provides tooling to automate common Instagram workflows using Python. It is organized as a CLI-driven application with modular components for interacting with Instagram, managing scheduled jobs, and persisting state. There are also helper modules for integration with Telegram to receive notifications or deliver content.
Use this repository as a starting-point for:
- Building a scheduled poster or monitor for Instagram accounts
- Creating bots that monitor public accounts for new content
- Sending notifications (e.g., via Telegram) when conditions are met
- Experimenting with automation workflows and building custom scripts
- Command-line interface for quick operations and configuration
- Scheduler for running time-based jobs
- Modular Instagram interaction layer
- Simple database/persistence layer for sessions, project lists, and schedules
- Optional Telegram integration for notifications and delivery
- Utility modules for common helpers and tooling
Instagram/
├─ bot.py # Main bot entrypoint (automation logic)
├─ cli.py # Command-line interface for the project
├─ scheduler.py # Scheduling / cron-like runner
├─ instagram/ # Instagram interaction modules
├─ db/ # Persistence layer (SQLite / DB helpers)
├─ tgram/ # Telegram integration helpers
├─ utils/ # Utility helpers (parsers, helpers)
├─ requirements.txt # Python dependencies (if present)
└─ README.md # This file
If your tree differs, adapt the commands below accordingly.
- Python 3.10+ (recommended)
- pip
- Virtualenv (recommended)
The project may require additional libraries such as requests, httpx, python-telegram-bot, or an Instagram automation library. A requirements.txt file should exist in the repo — install it using pip.
- Clone the repository:
git clone https://github.com/justaman045/Instagram.git
cd Instagram- Create and activate a virtual environment (Linux/macOS):
python3 -m venv .venv
source .venv/bin/activateWindows (PowerShell):
python -m venv .venv
.\.venv\Scripts\Activate.ps1- Install dependencies:
pip install -r requirements.txtCreate a .env file in the project root (or set environment variables) with the values your project expects. Common variables include:
# Instagram credentials / session details
IG_USERNAME=your_username
IG_PASSWORD=your_password
# Or path to session/cookies if used
IG_SESSION_FILE=./sessions/session.json
# Telegram (optional)
TG_BOT_TOKEN=123456:ABC-DEF...
TG_CHAT_ID=987654321
# DB path (if using SQLite)
DATABASE_URL=sqlite:///data/db.sqlite3Security: Do not commit sensitive credentials to Git. Add
.envto.gitignore.
The repository exposes a CLI to interact with projects, run jobs, and manage monitored accounts. Basic patterns:
# Show help
python cli.py --help
# Example: list projects (if supported)
python cli.py projects list
# Example: run a command for project index 1
python cli.py monitor --project 1Replace subcommands according to the actual
cli.py --helpoutput.
Run the main bot entrypoint to start the automation logic:
python bot.pyMonitor logs and output in the terminal. Use a process manager (systemd, pm2, supervisor) for production to keep the process alive.
If the repo includes a scheduler.py or similar, this is used to run periodic tasks (e.g., every hour). Example:
python scheduler.pyFor production scheduling, prefer GitHub Actions, systemd timers, or cron — or implement a recurring job via schedule, APScheduler, or a cloud scheduler.
If you configure TG_BOT_TOKEN and TG_CHAT_ID, the bot can send updates or deliver reels to your Telegram. Common flows:
- Send best-performing reels to the configured chat at scheduled times
- Receive interactive messages to download captions or copies
The db/ folder contains helpers for storing projects, monitored accounts, sessions, and run history. Common approaches:
- SQLite for single-user/local setups
- Postgres or Supabase for multi-user or cloud deployments
If the repo expects a specific migration or schema, run the provided migration script (if any), or check db/schema.sql for table definitions.
- Write unit tests for Instagram interaction code (network calls must be mocked)
- Keep credentials out of source control — use
.envfiles or secrets management - Use
pre-commithooks and linters (flake8 / isort / black) for consistent style
- Instagram blocks / 401/403/429 responses: Instagram is strict about automation. Handle rate limits, backoff, and rotate sessions/IPs.
- Session/auth failures: Verify your credentials and session file. Consider using a headless browser session for login if necessary.
- Telegram notifications missing: Check
TG_BOT_TOKENandTG_CHAT_IDand verify the bot has permission to send messages to the chat. - DB errors: Confirm
DATABASE_URLpoints to a writeable location and required tables exist.
Contributions are welcome. Suggested workflow:
- Fork the repository
- Create a feature branch (
git checkout -b feat/my-feature) - Add tests for your changes
- Open a pull request with a clear description
Please avoid committing secrets or private keys.
- Automating actions on Instagram may violate Instagram’s Terms of Service. This project is provided for educational purposes. The author is not responsible for any account bans or legal issues.
- Rate-limit your requests and implement exponential backoff to reduce the risk of being flagged.
Include a license file (e.g. LICENSE) in the repo. If you don’t have one yet, consider using MIT:
MIT License
Copyright (c) [YEAR] [OWNER]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...
If you have questions or want help improving the project, open an issue or reach out via GitHub profile: https://github.com/justaman045.
Happy hacking — and remember to use automation responsibly.