API Reference

class instaLooter.InstaLooter[source]

A brutal Instagram looter that raids without API tokens.

__init__(directory=None, profile=None, hashtag=None, add_metadata=False, get_videos=False, videos_only=False, jobs=16, template='{id}', url_generator=<function default>, dump_json=False, dump_only=False, extended_dump=False)[source]

Create a new looter instance.

Keyword Arguments:
 
  • directory (str) – where downloaded medias will be stored [default: None]
  • profile (str) – a profile to download media from [default: None]
  • hashtag (str) – a hashtag to download media from [default: None]
  • add_metadata (bool) – Add date and comment metadata to the downloaded pictures. [default: False]
  • get_videos (bool) – Also get the videos from the given target [default: False]
  • videos_only (bool) – Only download videos (implies get_videos=True). [default: False]
  • jobs (bool) – the number of parallel threads to use to download media (12 or more is advised to have a true parallel download of media files) [default: 16]
  • template (str) – a filename format, in Python new-style-formatting format. See the the Template page of the documentation for available keys. **[default: {id}]
  • url_generator (Function definitions) – a callable that takes a media dictionary as argument and returs the URL it should download the picture from. The default tries to get the best available size. [default: `urlgen.default`]
  • dump_json (bool) – Save each resource metadata to a JSON file next to the actual image/video. [default: False]
  • dump_only (bool) – Only save metadata and discard the actual resource. [default: False]
  • extended_dump (bool) – Attempt to fetch as much metadata as possible, at the cost of more time. Set to True if, for instance, you always want the top comments to be downloaded in the dump. [default: False]
_init_workers()[source]

Initialize a pool of workers to download files.

_transform_hashtag_page(data)[source]

This function does a transformation of the entry_data from a hashtag page into the format expected by the rest of the application (due to IG changing the JSON format for hashtag pages)

Parameters:data (Dictionary displays) – a GraphQL style JSON dictionary holding hashtag data
Returns:
an old-style dictionary holding hashtag data, usable by the
looter instance.
Return type:Dictionary displays

Note

Implementation thanks to Geoff (@gffde3).

download(**kwargs)[source]

Download all the medias from provided target.

This method follwows the parameters given in the __init__ method (profile or hashtag, directory, get_videos, videos_only, add_metadata and dump_json).

Keyword Arguments:
 
  • media_count (int) – how many media to download before stopping [default: None]
  • with_pbar (bool) – display a progress bar [default: False]
  • timeframe (tuple) – a couple of datetime.date object specifying the date frame within which to yield medias (a None value can be given as well) [default: None] [format: (start, stop), stop older than start]
  • new_only (bool) – stop looking for new medias if old ones are found in the destination directory [default: False]
download_pictures(**kwargs)[source]

Download all the pictures from provided target.

Keyword Arguments:
 
  • media_count (int) – how many media to download before stopping [default: None]
  • with_pbar (bool) – display a progress bar [default: False]
  • timeframe (tuple) – a couple of datetime.date object specifying the date frame within which to yield medias (a None value can be given as well) [default: None] [format: (start, stop), stop older than start]
  • new_only (bool) – stop looking for new medias if old ones are found in the destination directory [default: False]
download_post(code)[source]

Download a single post referenced by its code.

Parameters:code (str) – the code of the post (can be found in the url: https://www.instagram.com/p/<code>/) when looking at a specific media.
download_videos(**kwargs)[source]

Download all the videos from provided target.

Keyword Arguments:
 
  • media_count (int) – how many media to download before stopping [default: None]
  • with_pbar (bool) – display a progress bar [default: False]
  • timeframe (tuple) – a couple of datetime.date object specifying the date frame within which to yield medias (a None value can be given as well) [default: None] [format: (start, stop), stop older than start]
  • new_only (bool) – stop looking for new medias if old ones are found in the destination directory [default: False]
get_owner_info(code)[source]

Get metadata about the owner of given post.

Parameters:code (str) – the code of the post (can be found in the url: https://www.instagram.com/p/<code>/) when looking at a specific media
Returns:the owner metadata deserialised from JSON
Return type:Dictionary displays
get_post_info(code)[source]

Get info about a single post referenced by its code

Parameters:code (str) – the code of the post (can be found in the url: https://www.instagram.com/p/<code>/) when looking at a specific media.
is_logged_in()[source]

Check if the current instance is logged in.

Returns:if the user is logged in or not
Return type:bool
login(username, password)[source]

Login with provided credentials.

Parameters:
  • username (str) – the username to log in with
  • password (str) – the password to log in with

Note

Code taken from LevPasha/instabot.py

logout()[source]

Log out from current session.

Note

Code taken from LevPasha/instabot.py

medias(media_count=None, with_pbar=False, timeframe=None)[source]

An iterator over the media nodes of a profile or hashtag.

Using InstaLooter.pages, extract media nodes from each page and yields them successively.

Parameters:
  • media_count (int) – how many media to show before stopping [default: None]
  • with_pbar (bool) – display a progress bar [default: False]
  • timeframe (tuple) – a couple of datetime.date object specifying the date frame within which to yield medias (a None value can be given as well) [default: None] [format: (start, stop), stop older than start]
pages(media_count=None, with_pbar=False)[source]

An iterator over the shared data of a profile or hashtag.

Create a connection to www.instagram.com and use successive GET requests to load all pages of a profile. Each page contains 12 media nodes, as well as metadata associated to the account.

Parameters:
  • media_count (int) – how many media to show before stopping [default: None]
  • with_pbar (bool) – display a progress bar. [default: False]
Yields:

Dictionary displays – the page content deserialised from JSON

__weakref__

list of weak references to the object (if defined)