Python Module instaloader

Instaloader exposes its internally used methods and structures as a Python module, making it a powerful and intuitive Python API for Instagram, allowing to further customize obtaining media and metadata.

Start with getting an instance of Instaloader:

import instaloader

# Get instance
L = instaloader.Instaloader()

# Optionally, login or load session
L.login(USER, PASSWORD)        # (login)
L.interactive_login(USER)      # (ask password on terminal)
L.load_session_from_file(USER) # (load session created w/
                               #  `instaloader -l USERNAME`)

instaloader provides the Post structure, which represents a picture, video or sidecar (set of multiple pictures/videos) posted in a user’s profile. Instaloader provides methods to iterate over Posts from a certain source:

for post in instaloader.Hashtag.from_name(L.context, 'cat').get_posts():
    # post is an instance of instaloader.Post
    L.download_post(post, target='#cat')

Post instances can be created with:

With the Profile class, Instaloader also makes it easy to access metadata of a Profile. Profile instances can be created with:

For a list of a few code examples that use the Instaloader module, see Advanced Instaloader Examples.

The reference of the classes and functions provided by the instaloader module is divided into the following subsections:

Next Section

Instaloader (Main Class)