Examples
Runnable async examples live in the repository:
The examples read credentials and runtime options from environment variables instead of hard-coding secrets:
export IG_USERNAME="your_username"
export IG_PASSWORD="your_password"
export IG_SESSION_FILE="./ig_settings.json"
Common scripts:
| Script | Purpose |
|---|---|
public_lookup.py |
Public profile lookup with optional public_transport="curl". |
download_user_media.py |
Login, list recent media for a username, and download photos/videos/albums. |
upload_media.py |
Upload a feed photo, feed video, Reel, or Trial Reel. |
upload_story.py |
Upload a photo or video story, optionally with a link sticker. |
direct_message.py |
Send a Direct text message to user IDs or thread IDs. |
Examples:
python examples/public_lookup.py instagram
IG_PUBLIC_TRANSPORT=curl python examples/public_lookup.py instagram
python examples/download_user_media.py instagram --amount 5 --folder ./downloads
python examples/upload_media.py reel ./reel.mp4 --thumbnail ./thumb.jpg --caption "Reel"
python examples/upload_story.py photo ./story.jpg --caption "Story"
python examples/direct_message.py --user-ids 123456789 --text "Hello"
Video uploads in Android environments should pass --thumbnail or install the optional video dependencies, MoviePy 2.2.1, and executable ffmpeg. See Pydroid and ffmpeg and Termux.