instaloader icon indicating copy to clipboard operation
instaloader copied to clipboard

Can't Download Anything At All

Open tetrahydra opened this issue 6 months ago • 13 comments

Describe the bug Instaloader can't download anything at all. I tried to download posts, then only stories, however, it keeps giving this error.

To Reproduce Steps to reproduce the behavior: instaloader username --login username --password password --no-posts --stories --no-compress-json --no-video-thumbnails --filename-pattern="{date_utc:%Y-%m-%d %H-%M-%S UTC}"

Expected behavior Loaded session from C:\Users\Administrator\AppData\Local\Instaloader\session-username. JSON Query to graphql/query: 401 Unauthorized - "fail" status, message "Please wait a few minutes before you try again." when accessing https://www.instagram.com/graphql/query?query_hash=d6f4427fbe92d846298cf93df0b937d3&variables=%7B%7D [retrying; skip with ^C] JSON Query to graphql/query: 401 Unauthorized - "fail" status, message "Please wait a few minutes before you try again." when accessing https://www.instagram.com/graphql/query?query_hash=d6f4427fbe92d846298cf93df0b937d3&variables=%7B%7D [retrying; skip with ^C] Error when checking if logged in: JSON Query to graphql/query: 401 Unauthorized - "fail" status, message "Please wait a few minutes before you try again." when accessing https://www.instagram.com/graphql/query?query_hash=d6f4427fbe92d846298cf93df0b937d3&variables=%7B%7D Logged in as username. [1/1] Downloading profile username Unable to fetch high quality profile pic: 'hd_profile_pic_url_info' username\2021-11-07_18-23-53_UTC_profile_pic.jpg already exists Downloading stories Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\Scripts\instaloader.exe\__main__.py", line 7, in <module> File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\instaloader\__main__.py", line 584, in main exit_code = _main(loader, File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\instaloader\__main__.py", line 302, in _main instaloader.download_profiles( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\instaloader\instaloader.py", line 1553, in download_profiles self.download_stories(userids=list(profiles), fast_update=fast_update, filename_target=None, File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\instaloader\instaloader.py", line 81, in call return func(instaloader, *args, **kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\instaloader\instaloader.py", line 854, in download_stories for i, user_story in enumerate(self.get_stories(userids), start=1): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\instaloader\instaloader.py", line 819, in get_stories stories = self.context.graphql_query("303a4ae99711322310f25250d988f3b7", KeyError: 'data'

Error messages and tracebacks If applicable, add error messages and tracebacks to help explain your problem.

Instaloader version I:\Instagram>instaloader --version 4.14.1

tetrahydra avatar Jun 22 '25 05:06 tetrahydra

Yep, same issue here

swtb3 avatar Jun 22 '25 17:06 swtb3

Thirding, again.

Rich700000000000 avatar Jun 23 '25 07:06 Rich700000000000

Yep, me too

Using your command I got:

Session file does not exist yet - Logging in. Login: Checkpoint required. Point your browser to {very big url here} - follow the instructions, then retry.

When I click the {very big url} im redirected to

Image

vitorbborges avatar Jun 23 '25 09:06 vitorbborges

+1

snigbug avatar Jun 23 '25 14:06 snigbug

+1

aleare avatar Jun 23 '25 17:06 aleare

Check out this repo if you need a GUI for instaloader --》https://github.com/ukr-projects/instaloader-gui

It would be useful if instaloader worked. Otherwise, it is just a beautiful UI.

tetrahydra avatar Jun 27 '25 06:06 tetrahydra

+1

IgorArnaut avatar Jun 28 '25 16:06 IgorArnaut

+1

codingforpleasure avatar Jul 08 '25 11:07 codingforpleasure

+1

iamkdblue avatar Jul 12 '25 14:07 iamkdblue

How I fixed Instagram login failing in Instaloader Python API (use browser cookies instead of manual login)

If you’re banging your head because Instaloader’s login stopped working and you get errors like:

KeyError: 'data'
{'errors': [{'code': 1675002, 'description': 'The query provided was invalid.', ...}]}

it’s because Instagram changed their GraphQL queries and manual login no longer works properly. The usual username/password login looks like it succeeds (is_logged_in becomes true), but Instagram’s API rejects it behind the scenes.


Quick CLI fix (for users who just run instaloader from command line):

Use the --load-cookies flag to load your browser cookies:

pip install browser-cookie3
instaloader --load-cookies chrome

This tells Instaloader CLI to reuse the cookies from your Chrome browser session instead of doing a fresh login.


Python API fix (for people who use Instaloader as a library in their scripts):

You have to import your real Instagram cookies from your browser into Instaloader’s session. Here’s how I did it (This is the same logic that the --load-cookies flag uses):

import browser_cookie3
from instaloader import Instaloader, LoginException, InvalidArgumentException

def get_cookies_from_instagram(domain, browser):
    supported = {
        "brave": browser_cookie3.brave,
        "chrome": browser_cookie3.chrome,
        "chromium": browser_cookie3.chromium,
        "edge": browser_cookie3.edge,
        "firefox": browser_cookie3.firefox,
        "librewolf": browser_cookie3.librewolf,
        "opera": browser_cookie3.opera,
        "opera_gx": browser_cookie3.opera_gx,
        "safari": browser_cookie3.safari,
        "vivaldi": browser_cookie3.vivaldi,
    }

    if browser not in supported:
        raise InvalidArgumentException("Unsupported browser. Use one of: " + ", ".join(supported.keys()))

    cookies = {}
    for cookie in supported[browser]():
        if domain in cookie.domain:
            cookies[cookie.name] = cookie.value

    if not cookies:
        raise LoginException(f"No Instagram cookies found in {browser}. Are you logged in there?")
    return cookies

def login_with_cookies(instaloader, browser_name="chrome"):
    cookies = get_cookies_from_instagram("instagram", browser_name)
    instaloader.context.update_cookies(cookies)
    username = instaloader.test_login()
    if not username:
        raise LoginException("Login failed. Are you logged in on the browser and cookies valid?")
    instaloader.context.username = username
    print(f"Logged in as {username}")
    instaloader.save_session_to_file()

# Usage:
bot = Instaloader()
login_with_cookies(bot, "safari")  # or "chrome", etc.

# Later you can reload session:
# bot.load_session_from_file("your_username")

Notes:

  • This method uses your actual browser session cookies to authenticate.
  • Cookies expire, so repeat the process if login stops working.
  • Keep your cookies secure! Anyone with them can hijack your Instagram session.
  • Works for all supported browsers via browser_cookie3.

This is the only reliable way to keep using Instaloader Python API now that Instagram broke manual login.


Feel free to copy-paste this. It saved me a lot of headache.

Stupidoodle avatar Jul 13 '25 21:07 Stupidoodle

How I fixed Instagram login failing in Instaloader Python API (use browser cookies instead of manual login)

If you’re banging your head because Instaloader’s login stopped working and you get errors like:

KeyError: 'data'
{'errors': [{'code': 1675002, 'description': 'The query provided was invalid.', ...}]}

it’s because Instagram changed their GraphQL queries and manual login no longer works properly. The usual username/password login looks like it succeeds (is_logged_in becomes true), but Instagram’s API rejects it behind the scenes.

Quick CLI fix (for users who just run instaloader from command line):

Use the --load-cookies flag to load your browser cookies:

pip install browser-cookie3 instaloader --load-cookies chrome This tells Instaloader CLI to reuse the cookies from your Chrome browser session instead of doing a fresh login.

Python API fix (for people who use Instaloader as a library in their scripts):

You have to import your real Instagram cookies from your browser into Instaloader’s session. Here’s how I did it (This is the same logic that the --load-cookies flag uses):

import browser_cookie3 from instaloader import Instaloader, LoginException, InvalidArgumentException

def get_cookies_from_instagram(domain, browser): supported = { "brave": browser_cookie3.brave, "chrome": browser_cookie3.chrome, "chromium": browser_cookie3.chromium, "edge": browser_cookie3.edge, "firefox": browser_cookie3.firefox, "librewolf": browser_cookie3.librewolf, "opera": browser_cookie3.opera, "opera_gx": browser_cookie3.opera_gx, "safari": browser_cookie3.safari, "vivaldi": browser_cookie3.vivaldi, }

if browser not in supported:
    raise InvalidArgumentException("Unsupported browser. Use one of: " + ", ".join(supported.keys()))

cookies = {}
for cookie in supported[browser]():
    if domain in cookie.domain:
        cookies[cookie.name] = cookie.value

if not cookies:
    raise LoginException(f"No Instagram cookies found in {browser}. Are you logged in there?")
return cookies

def login_with_cookies(instaloader, browser_name="chrome"): cookies = get_cookies_from_instagram("instagram", browser_name) instaloader.context.update_cookies(cookies) username = instaloader.test_login() if not username: raise LoginException("Login failed. Are you logged in on the browser and cookies valid?") instaloader.context.username = username print(f"Logged in as {username}") instaloader.save_session_to_file()

Usage:

bot = Instaloader() login_with_cookies(bot, "safari") # or "chrome", etc.

Later you can reload session:

bot.load_session_from_file("your_username")

Notes:

  • This method uses your actual browser session cookies to authenticate.
  • Cookies expire, so repeat the process if login stops working.
  • Keep your cookies secure! Anyone with them can hijack your Instagram session.
  • Works for all supported browsers via browser_cookie3.

This is the only reliable way to keep using Instaloader Python API now that Instagram broke manual login.

Feel free to copy-paste this. It saved me a lot of headache.

I like this method. I was banging my head against the wall trying to get the login cookies to work automatically.

I found that Instaloader's low-level function login(user: str, passwd: str) works well for generating cookies, but it's missing the sessionid that the API needs to validate the request. This sessionid can be found in the browser's cookies; however, that's a manual task. It's a bit tedious when you got multiple account. I haven't found a way to automate this yet for multiple account.

anonymates avatar Jul 15 '25 12:07 anonymates

.

This worked.. thanks! And Yes, Chrome doesn't work so I used Firefox for session information.

bamit99 avatar Jul 23 '25 18:07 bamit99

This fix worked for me. Thank you so much.

jack442269 avatar Jul 24 '25 02:07 jack442269