IG2TG is a Python package and CLI tool that automatically downloads Instagram stories from specified users and sends them to your Telegram chat.
It leverages Instaloader for Instagram scraping and python-telegram-bot for Telegram integration.
- Download Instagram stories from any public or followed private account.
- Automatically cleans up unnecessary files after download.
- Sends new stories to your Telegram chat via a bot.
- Easy configuration with environment variables.
- Python 3.7+
- Instagram account credentials or session cookies
- Telegram Bot Token
- Instagram accounts to download stories.
Install dependencies (for development or direct use):
pip install -r requirements.txtOr, if you want to install as a package (after building):
pip install .-
Clone the repository:
git clone https://github.com/brockar/ig2tg.git cd ig2tg -
Configure environment variables:
Copy the example environment file and fill in your credentials:
cp env.example .env
Edit
.envand set:IG_USERNAMEandIG_PASSWORD(orIGSESSIONIDandIGCSRFTOKENfor session login) (works with 2FAs)TELEGRAM_TOKEN(your Telegram bot token) andTG_USERto just send images to your telegram user.
How to get Instagram session cookies:
- Go to instagram.com and log in.
- Open Developer Tools (F12 or right-click → Inspect).
- Go to the "Application" tab, then "Cookies".
- Copy the values for
sessionid(set asIGSESSIONID) andcsrftoken(set asIGCSRFTOKEN).
-
Add Instagram usernames to monitor:
Create a file named
user_list.txtin the project root and add one Instagram username per line (no@):testuser1 testuser2Also can add comments with
#
After installing as a package, run:
ig2tgYou can also run the main script directly:
python -m ig2tg.mainThe tool will:
- Log in to Instagram using your credentials or session.
- Download stories for each user in
user_list.txt. - Clean up unnecessary files.
- Send new stories to your Telegram chat.
- Repeat the process every 24 hours.
-
Download the latest built package
Go to the Releases page and download either:
ig2tg-0.0.1-py3-none-any.whl(wheel)- or
ig2tg-0.0.1.tar.gz(source distribution)
-
Install the package
Replace
<filename>with the name of the file you downloaded:pip install <filename>
For example:
pip install ig2tg-0.0.1-py3-none-any.whl # or pip install ig2tg-0.0.1.tar.gz -
Run the tool
After installation, you can run the CLI:
ig2tg
Or as a Python module:
python -m ig2tg.main
- The Telegram bot will send all new stories to the chat where you first interact with it.
- Only the user specified in your
.envasTG_USERcan trigger the bot.
ig2tg/
__init__.py
main.py
stories.py
tg.py
utils.py
stories/
<downloaded stories organized by user>
user_list.txt
.env
README.md
pyproject.toml
LICENSE
This project is licensed under the GNU GPLv3.
Note:
Use this tool responsibly and respect Instagram's and Telegram's terms of service.