LinuxCommandLibrary

instaloader

Download Instagram content, profiles, and hashtags

TLDR

Download a profile

$ instaloader [profile_name]
copy

Download highlights
$ instaloader --highlights [profile_name]
copy

Download posts with geotags (if available), suppressing any user interaction
$ instaloader [[-q|--quiet]] [[-G|--geotags]] [profile_name]
copy

Specify a user agent for HTTP requests
$ instaloader --user-agent [user_agent] [profile_name]
copy

Specify login info and download posts (useful for private profiles)
$ instaloader [[-l|--login]] [username] [[-p|--password]] [password] [profile_name]
copy

Skip a target if the first downloaded file has been found (useful for updating Instagram archives)
$ instaloader [[-F|--fast-update]] [profile_name]
copy

Download stories and IGTV videos (login required)
$ instaloader [[-l|--login]] [username] [[-p|--password]] [password] [[-s|--stories]] --igtv [profile_name]
copy

Download all types of posts (login required)
$ instaloader [[-l|--login]] [username] [[-p|--password]] [password] [[-s|--stories]] --igtv --highlights [profile_name]
copy

SYNOPSIS

instaloader [OPTIONS] [TARGETS...]

TARGETS can be:
  • PROFILE_NAME (e.g., username)
  • #HASHTAG (e.g., #photography)
  • :feed (downloads your personal feed)
  • POST_URL (e.g., https://www.instagram.com/p/abcdef12345/)
  • USER_ID (numeric user ID)

PARAMETERS

--login=USERNAME
    Logs in to Instagram with the specified username. If no password is provided, it will be requested interactively.

--fast-update
    Skips downloading files that already exist in the target directory, only fetching new content. Useful for resuming downloads.

--comments
    Downloads all comments associated with posts.

--no-posts
    Prevents downloading posts (photos and videos) from profiles.

--stories
    Explicitly downloads stories for the specified profiles or your own stories if logged in.

--highlights
    Explicitly downloads highlights for the specified profiles.

--igtv
    Explicitly downloads IGTV videos for the specified profiles.

--profile-pic-only
    Downloads only the profile picture of the specified profile.

--date=YYYY-MM-DD
    Downloads posts only published on or after the specified date.

--latest-posts=NUM
    Downloads only the NUM most recent posts from a profile.

--filename-pattern=PATTERN
    Customizes the naming pattern for downloaded files. Supports various placeholders like {id}, {shortcode}, {username}, etc.

--dirname-pattern=PATTERN
    Customizes the naming pattern for output directories. Similar to --filename-pattern.

--quiet
    Suppresses most of the console output, showing only critical messages.

--sessionfile=PATH
    Uses or stores the session cookies at the specified PATH instead of the default location.

DESCRIPTION

Instaloader is a powerful command-line program written in Python designed for downloading various types of content from Instagram. It's a versatile tool primarily used for archiving personal data, backing up public profiles, or collecting publicly available data for analysis, always with respect for privacy and terms of service.

It can fetch a wide range of content including user profiles (with profile pictures and metadata), individual posts (photos, videos, captions, geotags), IGTV videos, Reels, Stories, and Highlights. Instaloader supports logging in with an Instagram account, which is essential for accessing private profiles, downloading higher-quality content, and bypassing certain public access restrictions.

The tool intelligently handles Instagram's rate limiting to minimize temporary blocks and provides extensive options for filtering content based on date, type, or custom criteria. Users can also define custom filename and directory patterns for organizing downloaded content, making it an excellent utility for comprehensive Instagram data management and archival.

CAVEATS

Due to Instagram's dynamic nature, its API and website structure frequently change, which can sometimes cause Instaloader to temporarily break or require updates.

Aggressive downloading may lead to Instagram's rate limiting, resulting in temporary IP bans or account restrictions. It's crucial to use Instaloader responsibly and respect Instagram's Terms of Service and user privacy. Downloading content without permission, especially from private accounts, is unethical and potentially illegal.

For most advanced features like downloading private profiles or high-quality stories, a valid Instagram login is required. The tool relies on Python and its dependencies, which need to be correctly installed.

INSTALLATION

Instaloader is a Python package and can be easily installed using pip, the Python package installer:

pip install instaloader

It is recommended to use a Python virtual environment to manage dependencies.

SESSION MANAGEMENT

Upon successful login, Instaloader stores session cookies in a file (by default at ~/.config/instaloader/session-USERNAME). This allows subsequent runs to avoid re-authentication, provided the session remains valid. This file should be protected as it contains sensitive login information.

BASIC USAGE EXAMPLES

To download a public profile:
instaloader some_public_profile

To download a private profile (after logging in):
instaloader --login=your_username some_private_profile

To download only stories for a profile:
instaloader --stories some_profile

To download posts from a specific hashtag:
instaloader #somehashtag

HISTORY

Instaloader was initially developed by ThoKra (Thomas K.) as an open-source project on GitHub. It emerged from the need for a reliable command-line tool to archive and manage Instagram content, a feature Instagram itself does not natively provide. Its development is characterized by continuous adaptation to Instagram's evolving API and website changes, ensuring its functionality amidst frequent platform updates. It has grown into a popular tool within the developer and archival communities for its robustness and extensive feature set.

SEE ALSO

wget(1): A general-purpose non-interactive network downloader., curl(1): A command-line tool for transferring data with URLs, supporting various protocols., yt-dlp(1): A widely used command-line program to download videos from various websites, though not specifically tailored for Instagram's comprehensive archival features like profile data.

Copied to clipboard