instagram-archiver

Save Instagram content you have access to.

View on GitHub

instagram-archiver

Python versions PyPI - Version GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) CodeQL QA Tests Coverage Status Dependabot Documentation Status mypy uv pytest Ruff Downloads Stargazers pre-commit Prettier

@Tatsh Buy Me A Coffee Libera.Chat Mastodon Follow Patreon

Save Instagram content you have access to.

Installation

pip install instagram-archiver

Usage

Usage: instagram-archiver [OPTIONS] [USERNAME]

  Archive a profile (USERNAME) or your saved posts (--saved).

  Pass exactly one of: a USERNAME positional argument, or --saved/-s.

Options:
  -o, --output-dir DIRECTORY      Output directory. Defaults to the username
                                  (profile mode) or `.` (saved mode).
  -b, --browser [brave|chrome|chromium|edge|opera|vivaldi|firefox|safari]
                                  Browser to read cookies from.
  -p, --profile TEXT              Browser profile.
  -d, --debug                     Enable debug output.
  -q, --quiet                     Disable progress display updates.
  -S, --sleep-time INTEGER        Number of seconds yt-dlp waits between
                                  requests.
  --no-log                        Ignore log (re-fetch everything).
  -C, --include-comments          Also download all comments (extends download
                                  time significantly).
  -s, --saved                     Archive your saved posts instead of a
                                  profile (mutually exclusive with USERNAME).
  -u, --unsave                    Unsave posts after successful archive (only
                                  with --saved).
  -h, --help                      Show this message and exit.

Typical use:

instagram-archiver -o ~/instagram-backups/username username
instagram-archiver --saved -o ~/instagram-backups/saved

When neither --debug nor --quiet is passed, a Rich-based live progress display (provided by the archiver-stats library) is shown on stderr. Pass --quiet to disable it for non-interactive use, or --debug to see verbose log output instead.

Downloads run concurrently using niquests.AsyncSession and producer/consumer queues: one worker for media posts, one for comments (when -C is passed), and one for yt-dlp video downloads. Each worker handles at most one in-flight HTTP request at a time, which keeps Instagram rate-limiting at bay while still overlapping image downloads with yt-dlp.

The dedup log lives at <output_dir>/.log.db and is honoured across runs in both profile and --saved modes. Pass --no-log to bypass it and re-fetch everything.

Notes

The default output path is the username under the current working directory.

Videos are saved using yt-dlp and its respective configuration.