Send Instagram DMs using session ID automation with Selenium
Project description
InstaPy-DM
InstaPy is a lightweight Python package that allows you to send Instagram DMs using session-based login and Selenium automation.
⚠️ This project is intended for educational and research purposes only. Use responsibly and in compliance with Instagram's terms of service.
🚀 Features
- 🔐 Login via Instagram session cookies (no password required)
- ✉️ Send direct messages to Instagram users
- 🧱 Modular design with FastAPI and Pydantic support
- 🧪 Ready for integration into larger automation pipelines
📦 Installation
pip install instapy-dm
🧠 Usage
1. Create a DMRequest and use send_dm
from instapy import send_dm, DMRequest
data = DMRequest(
username="your_instagram_username",
session_id="your_session_id",
target_username="target_user",
message="Hello from InstaPy!"
)
response = send_dm(data)
print(response)
📁 Project Structure
instapy/
├── __init__.py # Package exports
├── credentials.py # BaseModel for session credentials
├── login.py # Handles browser session login
└── dm.py # Function to send a DM using credentials
🛠️ Requirements
- Python 3.7+
- Google Chrome installed
- ChromeDriver matching your browser version
Optional ChromeDriver setup
You can download ChromeDriver manually from: 👉 https://chromedriver.chromium.org/downloads
Or install it via a manager like:
pip install webdriver-manager
💡 Example Use Cases
- Sending event invites to creators
- Networking outreach with verified session IDs
- Research in automation & bot development
⚠️ Important Notes
- This package uses session cookie-based authentication — you must extract a valid
sessionidandds_usercookie from an authenticated Instagram session. - Do not use on accounts that risk violating Instagram’s automation policy.
- Login is headless by default but can be configured for debugging.
🔗 Useful Links
📄 License
This project is licensed under the MIT License.
🤖 Disclaimer
This tool automates browser actions on Instagram. Use it only for educational or authorized purposes. Automation may violate Instagram's terms — use at your own risk.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instapytool-0.1.1.tar.gz.
File metadata
- Download URL: instapytool-0.1.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e20b293e98876abac2616771bd2472eefd2f5e9c81355e1a74920d9d8ccb0fcd
|
|
| MD5 |
8cf8f6b9f96561708e1c381d4bcda82e
|
|
| BLAKE2b-256 |
73d6a305538c385428a39e91f8043492649076745b914ab0e05e4004c6743de5
|
File details
Details for the file instapytool-0.1.1-py3-none-any.whl.
File metadata
- Download URL: instapytool-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e3b604e5ecd11328f77ef90baa1eca70bb55fb8b4d2cc19c89de5a34268a8db
|
|
| MD5 |
60f51325a0aa5295680c5461b25e709b
|
|
| BLAKE2b-256 |
d8fea1b58454a43f78c857e91c9027297002ecd6755518c16d1ae8a47a24469c
|