A Python library to access Instagram's private API.

Overview

Instagram Private API

A Python wrapper for the Instagram private API with no 3rd party dependencies. Supports both the app and web APIs.

Python 2.7, 3.5 Release Docs Build

Build

Overview

I wrote this to access Instagram's API when they clamped down on developer access. Because this is meant to achieve parity with the official public API, methods not available in the public API will generally have lower priority.

Problems? Please check the docs before submitting an issue.

Features

An extension module is available to help with common tasks like pagination, posting photos or videos.

Documentation

Documentation is available at https://instagram-private-api.readthedocs.io/en/latest/

Install

Install with pip:

pip install git+https://[email protected]/ping/[email protected]

To update:

pip install git+https://[email protected]/ping/[email protected] --upgrade

To update with latest repo code:

pip install git+https://[email protected]/ping/instagram_private_api.git --upgrade --force-reinstall

Tested on Python 2.7 and 3.5.

Usage

The app API client emulates the official app and has a larger set of functions. The web API client has a smaller set but can be used without logging in.

Your choice will depend on your use case.

The examples/ and tests/ are a good source of detailed sample code on how to use the clients, including a simple way to save the auth cookie for reuse.

Option 1: Use the official app's API

from instagram_private_api import Client, ClientCompatPatch

user_name = 'YOUR_LOGIN_USER_NAME'
password = 'YOUR_PASSWORD'

api = Client(user_name, password)
results = api.feed_timeline()
items = [item for item in results.get('feed_items', [])
         if item.get('media_or_ad')]
for item in items:
    # Manually patch the entity to match the public api as closely as possible, optional
    # To automatically patch entities, initialise the Client with auto_patch=True
    ClientCompatPatch.media(item['media_or_ad'])
    print(item['media_or_ad']['code'])

Option 2: Use the official website's API

from instagram_web_api import Client, ClientCompatPatch, ClientError, ClientLoginError

# Without any authentication
web_api = Client(auto_patch=True, drop_incompat_keys=False)
user_feed_info = web_api.user_feed('329452045', count=10)
for post in user_feed_info:
    print('%s from %s' % (post['link'], post['user']['username']))

# Some endpoints, e.g. user_following are available only after authentication
authed_web_api = Client(
    auto_patch=True, authenticate=True,
    username='YOUR_USERNAME', password='YOUR_PASSWORD')

following = authed_web_api.user_following('123456')
for user in following:
    print(user['username'])

# Note: You can and should cache the cookie even for non-authenticated sessions.
# This saves the overhead of a single http request when the Client is initialised.

Avoiding Re-login

You are advised to persist/cache the auth cookie details to avoid logging in every time you make an api call. Excessive logins is a surefire way to get your account flagged for removal. It's also advisable to cache the client details such as user agent, etc together with the auth details.

The saved auth cookie can be reused for up to 90 days.

Donate

Want to keep this project going? Please donate generously https://www.buymeacoffee.com/ping

Build

Support

Make sure to review the contributing documentation before submitting an issue report or pull request.

Legal

Disclaimer: This is not affliated, endorsed or certified by Instagram. This is an independent and unofficial API. Strictly not for spam. Use at your own risk.

Comments
  • Forbidden

    Forbidden

    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.5.3
    • [X] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [ ] app (instagram_private_api/)
    • [x] web (instagram_web_api/)

    Purpose of your issue?

    • [x] Bug report (encountered problems/errors)
    • [ ] Feature request (request for a new functionality)
    • [ ] Question
    • [ ] Other

    Issue reproduction: I'm using the un-authorized access:

    web_api = Client(auto_patch=False, drop_incompat_keys=False)

    user_info = _get_user_info('haydar.aimon')


    For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

    Paste the output of python -V here:

    Code:

    Traceback (most recent call last):
      File "C:\Users\hayda\Google Drive\Websites\Webapp\New API\instagram_private_api-master\instagram_web_api\client.py", line 234, in _make_request
        res = self.opener.open(req, data=data, timeout=self.timeout)
      File "C:\Program Files\Python36\lib\urllib\request.py", line 532, in open
        response = meth(req, response)
      File "C:\Program Files\Python36\lib\urllib\request.py", line 642, in http_response
        'http', request, response, code, msg, hdrs)
      File "C:\Program Files\Python36\lib\urllib\request.py", line 570, in error
        return self._call_chain(*args)
      File "C:\Program Files\Python36\lib\urllib\request.py", line 504, in _call_chain
        result = func(*args)
      File "C:\Program Files\Python36\lib\urllib\request.py", line 650, in http_error_default
        raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 403: Forbidden
    

    Error/Debug Log:

    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "C:\Users\hayda\Google Drive\Websites\Webapp\New API\instagram_private_api-master\test.py", line 19, in <module>
        user_info = web_api.user_info2('haydar.aimon')
      File "C:\Users\hayda\Google Drive\Websites\Webapp\New API\instagram_private_api-master\instagram_web_api\client.py", line 314, in user_info2
        info = self._make_request(endpoint, query={'__a': '1'})
      File "C:\Users\hayda\Google Drive\Websites\Webapp\New API\instagram_private_api-master\instagram_web_api\client.py", line 244, in _make_request
        raise ClientError('HTTPError "{0!s}" while opening {1!s}'.format(e.reason, url), e.code)
    instagram_web_api.errors.ClientError: HTTPError "Forbidden" while opening https://www.instagram.com/haydar.aimon/?__a=1
    

    Describe your issue

    Thank you for this amazing web api, however I'm starting to get: urllib.error.HTTPError: HTTP Error 403: Forbidden on all of my requests. Did Instagram block access to this api? What can I do to resolve this issue?

    opened by abutizi 16
  • What is Constants EXPERIMENTS and LOGIN_EXPERIMENTS

    What is Constants EXPERIMENTS and LOGIN_EXPERIMENTS

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Rlease read them carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] no spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [X] Updated to the lastest version v1.6.0
    • [X] Read the README and docs
    • [X] Searched the bugtracker for similar issues including closed ones
    • [X] Reviewed the sample code in tests and examples

    Which client are you using?

    • [X] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Describe your Question/Issue:

    Hello,

    Someone know what is Constants EXPERIMENTS, LOGIN_EXPERIMENTS in the file constants.py ? I guess that identify something in the emulated device, so how to modify them from my personal Phone datas ?

    Thanks :)

    constants.py file : https://github.com/ping/instagram_private_api/blob/master/instagram_private_api/constants.py

    Paste the output of python -V here:

    Code:

    LOGIN_EXPERIMENTS = 'ig_growth_android_profile_pic_prefill_with_fb_pic_2,...' EXPERIMENTS = 'ig_camera_android_badge_face_effects_universe,...'

    out of scope 
    opened by yaniferhaoui 14
  • implement current follow requests in the web version

    implement current follow requests in the web version


    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.5.7
    • [x] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [ ] app (instagram_private_api/)
    • [x] web (instagram_web_api/)

    Describe your Feature Request:

    Is there any plan to implement Current follow requests feature which is available in the web version and gives a list of users that I requested to follow?

    wontfix 
    opened by javad94 14
  • [question]Is it safe to use upload.py ?

    [question]Is it safe to use upload.py ?

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Read the questions carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] no spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.6.0
    • [x] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [x] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Describe your Feature Request:

    The reason I am skeptic is instagram no longer relies on IP much but more on uniqueness of the mobile attributes(aka device fingerprints) to detect spam. This API doesn't spoof device attributes, so if anyone who is using this API to post for 100+ accounts can comment?

    no template 
    opened by ishandutta2007 13
  • Checkpoint Challenge Required on a Linux Server

    Checkpoint Challenge Required on a Linux Server

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Please read the questions carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] no spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.6.0
    • [x] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [x] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Describe your issue

    I currently use the API to automate Gameupdates/news by publishing automatically images.

    Some days ago I got the Checkpoint Challenge Required on my Debian 9 Server which prevent me to use the API. I already read issues which say that I need to manually login into Instagram on the Device.

    The Problem: I got a Linux KVM which I controll via SSH with no way to get a graphical interface/open Chrome.

    Is there a way to solve the "challenge" only via SSH access or another device?

    opened by Luc1412 12
  • video view

    video view

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Read the questions carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] no spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.6.0
    • [x] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [x] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Describe your Feature Request:

    Please make sure the description is worded well enough to be understood with as much context and examples as possible.

    hello ping :) would you please add video view feature to be able to view the video ? ex : api.video_view("media_id")

    no template 
    opened by ali101110 11
  • Transcode error: Video file does not contain duration

    Transcode error: Video file does not contain duration

    Which client are you using?

    • [x] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Purpose of your issue?

    • [x ] Bug report (encountered problems/errors)
    • [ ] Feature request (request for a new functionality)
    • [ ] Question
    • [ ] Other

    Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit ( Intel)] on win32

    
    from instagram_private_api import Client, ClientCompatPatch,MediaRatios
    from instagram_private_api_extensions import media
    
    user_name = 'xxx'
    password = 'xxx'
    
    api = Client(user_name, password)
    vid_data, vid_size, vid_duration, vid_thumbnail = media.prepare_video(
        'd:\\vid.mp4', aspect_ratios=MediaRatios.standard)
    
    api.post_video(vid_data, vid_size, vid_duration, vid_thumbnail)
    

    Error/Debug Log:

    Traceback (most recent call last):
      File "C:/Users/admin/PycharmProjects/untitled/3.py", line 17, in <module>
        api.post_video(vid_data, vid_size, vid_duration, vid_thumbnail)
      File "build\bdist.win32\egg\instagram_private_api\endpoints\upload.py", line 64
    3, in post_video
      File "build\bdist.win32\egg\instagram_private_api\endpoints\upload.py", line 22
    4, in configure_video
      File "build\bdist.win32\egg\instagram_private_api\endpoints\upload.py", line 46
    9, in post_photo
      File "build\bdist.win32\egg\instagram_private_api\endpoints\upload.py", line 19
    7, in configure
      File "build\bdist.win32\egg\instagram_private_api\client.py", line 483, in _cal
    l_api
    instagram_private_api.errors.ClientError: Bad Request: Transcode error: Video fil
    e does not contain duration
    

    I want ipload mp4 file to my ig account. I try use different mp4-files - same error.

    opened by Radzhab 10
  • How to send direct message?

    How to send direct message?

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Rlease read them carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] no spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.6.0
    • [x] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [x] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Describe your Question/Issue:

    How to Send Direct Message ?


    opened by payanthe 9
  • get number of followers/followees

    get number of followers/followees

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Rlease read them carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] no spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.5.7
    • [x] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [x] app (instagram_private_api/)
    • [] web (instagram_web_api/)

    Describe your Question/Issue:

    When using "user_followers()" method to get list of all followers of a sample account, only a limited number of them are returned (for example 200 in following example). Is there any way to get all of them?

    followers_list = temp_api.user_followers( '1713270648', rank_token = temp_api.generate_uuid() ) print( followers_list.keys() ) print( len( followers_list['users'] ) )

    opened by muh-bazm 9
  • Retreiving a List of Users Who Liked a Post

    Retreiving a List of Users Who Liked a Post

    Before submitting an issue, make sure you have:

    • [X] Updated to the lastest version v1.5.5
    • [X] Read the README and docs
    • [X] Searched the bugtracker for similar issues including closed ones
    • [X] Reviewed the sample code in tests and examples

    Which client are you using?

    • [ ] app (instagram_private_api/)
    • [X] web (instagram_web_api/)

    Purpose of your issue?

    • [ ] Bug report (encountered problems/errors)
    • [X] Feature request (request for a new functionality)
    • [X] Question
    • [ ] Other

    The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.

    Describe your issue

    Explanation of your issue goes here. Please make sure the description is worded well enough to be understood with as much context and examples as possible.

    I am trying to get a list of users who have liked a specific post. I can get the number of users, but I cannot literally get the users' IDs. This function I am looking for has been implemented in another library, here.

    opened by fivemoreminix 9
  • Video uploads failing

    Video uploads failing

    Have:

    Which client are you using?

    • [x] app (instagram_private_api/) + (instagram_private_api_extensions)
    • [ ] web (instagram_web_api/)

    Purpose of issue?

    • [x] Bug report (encountered problems/errors)
    • [ ] Feature request (request for a new functionality)
    • [ ] Question
    • [ ] Other

    Output of python -V :

    Python 2.7.10

    Example code that will produce the error reported :

    import json
    import codecs
    import datetime
    import os.path
    import logging
    import argparse
    import traceback
    
    try:
        import instagram_private_api as app_api
    except ImportError:
        import sys
        sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
        import instagram_private_api as app_api
    
    from instagram_private_api_extensions import media
    
    def to_json(python_object):
        if isinstance(python_object, bytes):
            return {'__class__': 'bytes',
                    '__value__': codecs.encode(python_object, 'base64').decode()}
        raise TypeError(repr(python_object) + ' is not JSON serializable')
    
    
    def from_json(json_object):
        if '__class__' in json_object:
            if json_object['__class__'] == 'bytes':
                return codecs.decode(json_object['__value__'].encode(), 'base64')
        return json_object
    
    
    def onlogin_callback(api, new_settings_file):
        cache_settings = api.settings
        with open(new_settings_file, 'w') as outfile:
            json.dump(cache_settings, outfile, default=to_json)
            print('SAVED: %s' % new_settings_file)
    
    
    if __name__ == '__main__':
    
        logging.basicConfig()
        logger = logging.getLogger('instagram_private_api')
        logger.setLevel(logging.WARNING)
    
        # Example command:
        # python examples/savesettings_logincallback.py -u "yyy" -p "zzz" -settings "test_credentials.json"
        parser = argparse.ArgumentParser(description='login callback and save settings demo')
        parser.add_argument('-settings', '--settings', dest='settings_file_path', type=str, required=True)
        parser.add_argument('-u', '--username', dest='username', type=str, required=True)
        parser.add_argument('-p', '--password', dest='password', type=str, required=True)
        parser.add_argument('-debug', '--debug', action='store_true')
    
        args = parser.parse_args()
        if args.debug:
            logger.setLevel(logging.DEBUG)
    
        print('Client version: %s' % app_api.__version__)
    
        try:
    
            settings_file = args.settings_file_path
            if not os.path.isfile(settings_file):
                # settings file does not exist
                print('Unable to find file: %s' % settings_file)
    
                # login new
                api = app_api.Client(
                    args.username, args.password,
                    on_login=lambda x: onlogin_callback(x, args.settings_file_path))
            else:
                with open(settings_file) as file_data:
                    cached_settings = json.load(file_data, object_hook=from_json)
                print('Reusing settings: %s' % settings_file)
    
                # reuse auth settings
                api = app_api.Client(
                    args.username, args.password,
                    settings=cached_settings)
    
        except (app_api.ClientCookieExpiredError, app_api.ClientLoginRequiredError) as e:
            print('ClientCookieExpiredError/ClientLoginRequiredError: %s' % e)
    
            # Login expired
            # Do relogin but use default ua, keys and such
            api = app_api.Client(
                args.username, args.password,
                on_login=lambda x: onlogin_callback(x, args.settings_file_path))
    
        except app_api.ClientLoginError as e:
            print('ClientLoginError %s' % e)
            exit(9)
        except app_api.ClientError as e:
            print('ClientError %s (Code: %d, Response: %s)' % (e.msg, e.code, e.error_response))
            exit(9)
        except Exception as e:
            print('Unexpected Exception: %s' % e)
            exit(99)
    
        # Show when login expires
        cookie_expiry = api.cookie_jar.expires_earliest
        print('Cookie Expiry: %s' % datetime.datetime.fromtimestamp(cookie_expiry).strftime('%Y-%m-%dT%H:%M:%SZ'))
    
        # Call the api
        results = api.tag_search('cats')
        assert len(results.get('results', [])) > 0
        print('All ok')
    	
        try :
            # post a video story
            vid_data, vid_size, vid_duration, vid_thumbnail = media.prepare_video('8.mp4', aspect_ratios=api.reel_ratios())
            api.post_video_story(vid_data, vid_size, vid_duration, vid_thumbnail)
        except :
            var = traceback.format_exc()
            with open('log.txt', 'w') as log:
                log.write(var)
    

    Error/Debug Log :

    Traceback (most recent call last):
      File "myUpload.py", line 116, in <module>
        api.post_video_story(vid_data, vid_size, vid_duration, vid_thumbnail)
      File "D:\insta\ping\instagram_private_api\instagram_private_api\endpoints\upload.py", line 592, in post_video_story
        thumbnail_data=thumbnail_data, to_reel=True)
      File "D:\insta\ping\instagram_private_api\instagram_private_api\endpoints\upload.py", line 567, in post_video
        return self.configure_video_to_reel(upload_id, size, duration, thumbnail_data)
      File "D:\insta\ping\instagram_private_api\instagram_private_api\endpoints\upload.py", line 298, in configure_video_to_reel
        res = self.post_photo(thumbnail_data, size, '', upload_id=upload_id, to_reel=True)
      File "D:\insta\ping\instagram_private_api\instagram_private_api\endpoints\upload.py", line 431, in post_photo
        return self.configure_to_reel(upload_id, size)
      File "D:\insta\ping\instagram_private_api\instagram_private_api\endpoints\upload.py", line 279, in configure_to_reel
        res = self._call_api(endpoint, params=params)
      File "D:\insta\ping\instagram_private_api\instagram_private_api\client.py", line 434, in _call_api
        raise ClientError(error_msg, e.code, error_response)
    ClientError: Bad Request: Transcode error: Video file does not contain duration
    

    Issue

    When above code ran with, python myUpload.py -u "username" -p "password" -settings "user.json" Video uploads fails , with Transcode error: Video file does not contain duration

    opened by BitJunky 9
  • top_search not working

    top_search not working

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Please read the questions carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] NO spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.6.0
    • [x] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [x] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Describe the Bug/Error:

    I'm trying to have a preview of top matching hashtags, users, locations of a certain word and I'm using the dedicated function "top_search". The function gets called properly but a ClientError arises. I've already checked that email and password are good because they work just fine with other functions like feed_tag. The code and the error message are pasted below.


    Code:

    # Example code that will produce the error reported
    from instagram_private_api import Client
    
    email, password = MYEMAIL, MYPSW
    api = Client(email, password)
    resp = api.top_search('farfa')
    resp
    

    Error/Debug Log:

    Error parsing error response: Expecting value: line 1 column 1 (char 0)
    ---------------------------------------------------------------------------
    HTTPError                                 Traceback (most recent call last)
    /usr/local/lib/python3.8/dist-packages/instagram_private_api/client.py in _call_api(self, endpoint, params, query, return_response, unsigned, version)
        522             self.logger.debug('DATA: {0!s}'.format(data))
    --> 523             response = self.opener.open(req, timeout=self.timeout)
        524         except compat_urllib_error.HTTPError as e:
    
    /usr/lib/python3.8/urllib/request.py in open(self, fullurl, data, timeout)
        530             meth = getattr(processor, meth_name)
    --> 531             response = meth(req, response)
        532 
    
    /usr/lib/python3.8/urllib/request.py in http_response(self, request, response)
        639         if not (200 <= code < 300):
    --> 640             response = self.parent.error(
        641                 'http', request, response, code, msg, hdrs)
    
    /usr/lib/python3.8/urllib/request.py in error(self, proto, *args)
        568             args = (dict, 'default', 'http_error_default') + orig_args
    --> 569             return self._call_chain(*args)
        570 
    
    /usr/lib/python3.8/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
        501             func = getattr(handler, meth_name)
    --> 502             result = func(*args)
        503             if result is not None:
    
    /usr/lib/python3.8/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
        648     def http_error_default(self, req, fp, code, msg, hdrs):
    --> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
        650 
    
    HTTPError: HTTP Error 404: Not Found
    
    During handling of the above exception, another exception occurred:
    
    ClientError                               Traceback (most recent call last)
    <ipython-input-8-6fd8388a332f> in <module>
          1 wordQuery = 'farfa'
          2 
    ----> 3 resp = api.top_search(wordQuery)
          4 resp
    
    /usr/local/lib/python3.8/dist-packages/instagram_private_api/endpoints/misc.py in top_search(self, query)
        136         :return:
        137         """
    --> 138         res = self._call_api(
        139             'fbsearch/topsearch/',
        140             query={'context': 'blended', 'ranked_token': self.rank_token, 'query': query})
    
    /usr/local/lib/python3.8/dist-packages/instagram_private_api/client.py in _call_api(self, endpoint, params, query, return_response, unsigned, version)
        525             error_response = self._read_response(e)
        526             self.logger.debug('RESPONSE: {0:d} {1!s}'.format(e.code, error_response))
    --> 527             ErrorHandler.process(e, error_response)
        528 
        529         except (SSLError, timeout, SocketError,
    
    /usr/local/lib/python3.8/dist-packages/instagram_private_api/errors.py in process(http_error, error_response)
        133             logger.warning('Error parsing error response: {}'.format(str(ve)))
        134 
    --> 135         raise ClientError(error_msg, http_error.code, error_response)
    
    ClientError: Not Found
    
    opened by elisamercanti 0
  • api for search recent hashtag posts is expire ?!

    api for search recent hashtag posts is expire ?!

    the recent hashtag posts not work correctly . this section return posts used hashtag in past before 3-4 month ago , and Instagram after a few results for continue need to challenge.

    "Instagram test removes ‘Recent’ tab from hashtag pages for some users" https://techcrunch.com/2022/04/19/instagram-removes-recent-tab-hashtag-pages/ instagram_private_api/endpoints/tags.py -> def tag_section(self, tag, tab='recent', **kwargs)

    opened by hamidwairless 0
  • Followers Pagination

    Followers Pagination

    Hi guys! im new to coding and I was reading documentation and build this script to get list of followers but I keep getting errors. Can some one please explain me what im doing wrong and why?

    from instagram_private_api import Client, ClientCompatPatch
    
    user_name = '***'
    password = '***'
    
    api = Client(user_name, password)
    
    
    
    from random import randint
    from time import sleep
    
    
    
    user_id = api.username_info('target')['user']['pk']
    
    # Create a list of followers' usernames
    usernames = []
    
    
    
    next_max_id = followers.get('next_max_id')
    
    while next_max_id:
        delay = randint(20,40)
        print("Sleep " + str(delay) + "s")
        sleep(delay)
        # Get a list of the user's followers
        followers = api.user_followers(user_id, rank_token=api.generate_uuid(),)
        next_max_id = followers.get('next_max_id')
    
        for follower in followers['users']:
            usernames.append(follower['username'])
        
    
    
    # Print the list of followers' usernames
    print(len(usernames))
    print(usernames)
    
    
    
    opened by 808arc 2
  • Location_info doesnt work anymore?

    Location_info doesnt work anymore?

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Please read the questions carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] NO spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.6.0
    • [x] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [x] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Describe the Bug/Error:

    Hello,

    Have been trying to fetch location_info from the instagram private api. It worked until friday, but was fetching too many requests and post that havent been able to log in as it requests location This was me, and never still doesn't store cookies. Can someone help me out? Need info urgently to convert location ID to lat/long, willing to pay. Contact me at : [email protected] Thanks, Eshan

    Code to replicate the error must be provided below.


    Paste the output of python -V here:

    Code:

    from instagram_private_api import Client
    USERNAME = 'xxx'
    PASSWORD = 'xxx'
    location_id = 794643567398395
    
    
    api = Client(USERNAME, PASSWORD)
    
    
    api.location_info(location_id)
    

    Error/Debug Log:

    ClientCheckpointRequiredError: checkpoint_challenge_required
    
    opened by chattyy 0
  •  this library is dead?

    this library is dead?

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Rlease read them carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] no spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [ ] Updated to the lastest version v1.6.0
    • [ ] Read the README and docs
    • [ ] Searched the bugtracker for similar issues including closed ones
    • [ ] Reviewed the sample code in tests and examples

    Which client are you using?

    • [ ] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Describe your Question/Issue:

    Please make sure the description is worded well enough to be understood with as much context and examples as possible.


    Paste the output of python -V here:

    Code:

    # Example code that will produce the error reported
    from instagram_web_api import Client
    
    web_api = Client()
    user_feed_info = web_api.user_feed('1234567890', count=10)
    

    Error/Debug Log:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ZeroDivisionError: integer division or modulo by zero
    
    opened by 347114839 4
  • How to approve user's follow request?

    How to approve user's follow request?

    Please follow the guide below

    • Issues submitted without this template format will be ignored.
    • Read the questions carefully and answer completely.
    • Do not post screenshots of error messages or code.
    • Put an x into all the boxes [ ] relevant to your issue (==> [x] no spaces).
    • Use the Preview tab to see how your issue will actually look like.
    • Issues about reverse engineering is out of scope and will be closed without response.
    • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

    Before submitting an issue, make sure you have:

    • [x] Updated to the lastest version v1.6.0
    • [x] Read the README and docs
    • [x] Searched the bugtracker for similar issues including closed ones
    • [x] Reviewed the sample code in tests and examples

    Which client are you using?

    • [x] app (instagram_private_api/)
    • [ ] web (instagram_web_api/)

    Describe your Feature Request:

    Well this is just ridiculous. In this library, there is a method to check incoming follow requests, but no way to approve it. In library with the same name but for javascript, there is a method to approve follow requests, but not to check list of them.

    telegram-cloud-document-5-6138909705222751918

    Please implement it! friendship_create just follows user, but does not approves its outgoing follow request. If such method exists, please add it to the documentation :)

    opened by VityaSchel 4
Releases(1.6.0)
  • 1.6.0(Feb 22, 2019)

    Coffee

    Change log:

    • Web API:
      • Add highlight_reels() and highlight_reel_media()
      • Add tagged_user_feed()
      • Add tag_story_feed() and location_story_feed()
      • Update query hashes
      • Fix for case sensitivity for tag feed
      • Add delete_media()
      • Add proxy_handler kwarg to support custom proxy handler such as socks
    • App API:
      • :fire: BREAKING CHANGE: Change in user agent format for the app version
      • :fire: BREAKING CHANGE: Change in argument list for search_users()
      • Add IGTV endpoints
      • Update media_n_comments(), search_users(), news()
      • feed_location() deprecated
      • Add kwargs to news() for paging support
      • Add tag_section() and location_section() endpoints
      • Add proxy_handler kwarg to support custom proxy handler such as socks
    Source code(tar.gz)
    Source code(zip)
  • 1.5.7(May 27, 2018)

  • 1.5.6(May 25, 2018)

    :fire: If upgrading from <=1.4.0, please refer to the breaking changes in 1.4.0 and 1.5.0.

    Change log:

    • Web API:
      • Add media_likers()
      • Fix user_info2()
      • Fix csrf token extraction
    • App API:
      • Fix client authentication expiry
      • Improve get cookie value
    Source code(tar.gz)
    Source code(zip)
  • 1.5.5(Apr 17, 2018)

    :fire: If upgrading from <=1.4.0, please refer to the breaking changes in 1.4.0 and 1.5.0.

    Change log:

    • Web API:
      • Fix for changes in the X-Instagram-GIS signed header
      • Reminder: Users should now also persist the rhx_gis and user_agent values along with the cookie string since the signing of requests depend on these values.
    Source code(tar.gz)
    Source code(zip)
  • 1.5.4(Apr 13, 2018)

    :fire: If upgrading from <=1.4.0, please refer to the breaking changes in 1.4.0 and 1.5.0.

    Change log:

    • Web API:
      • Fix for changes in the X-Instagram-GIS signed header
      • Fix user_info2() for both authenticated and unauthenticated clients
      • Reminder: Users should now also persist the rhx_gis and user_agent values along with the cookie string since the signing of requests depend on these values.
    Source code(tar.gz)
    Source code(zip)
  • 1.5.3(Apr 11, 2018)

    :fire: If upgrading from <=1.4.0, please refer to the breaking changes in 1.4.0 and 1.5.0.

    Change log:

    • Web API:
      • Users should now also persist the rhx_gis and user_agent values along with the cookie string since the signing of requests depend on these values.
    Source code(tar.gz)
    Source code(zip)
  • 1.5.2(Apr 10, 2018)

    :fire: If upgrading from <=1.4.0, please refer to the breaking changes in 1.4.0 and 1.5.0.

    Change log:

    • Web API:
      • Fix for new query_hash param and X-Instagram-GIS header requirement
      • Users should now also persist the rhx_gis value along with the cookie string.
    Source code(tar.gz)
    Source code(zip)
  • 1.5.1(Apr 8, 2018)

  • 1.5.0(Apr 4, 2018)

    :fire: If upgrading from <1.4.0, please refer to the breaking changes in 1.4.0.

    Change log:

    • App API:
      • :fire: BREAKING CHANGE: New arguments are needed for feed_tag(), tag_search(), user_following(), user_followers(), search_users(), location_fb_search()
      • New ClientReqHeadersTooLargeError error
    • Web API:
      • Fix user_info2()
    Source code(tar.gz)
    Source code(zip)
  • 1.4.1(Mar 3, 2018)

    :fire: If upgrading from <1.4.0, please refer to the breaking changes in 1.4.0.

    Change log:

    • App API:
      • Refactored error detection. New ClientCheckpointRequiredError, ClientChallengeRequiredError, ClientSentryBlockError
      • Add new highlights endpoints
      • New comment_inline_replies() endpoint
      • New story_viewers() endpoint
      • Updates for user feed and comments endpoints
      • Update set_reel_settings() with new arguments
    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Jan 31, 2018)

    Change log:

    • Common:
      • :fire: BREAKING CHANGE: New ClientConnectionError for network-related errors
    • App API:
      • Add comment replies endpoint
      • Add presence endpoints
      • Add tag following endpoints
      • Update user and tag search endpoints
      • Update app version to 26
    • Web API:
      • :fire: BREAKING CHANGE: Tag and Location feeds updated to use graphql endpoints.
      • Add timeline feed, reels tray, reels (stories) feed
    Source code(tar.gz)
    Source code(zip)
  • 1.3.6(Aug 11, 2017)

  • 1.3.5(Jul 6, 2017)

  • 1.3.4(Jun 22, 2017)

  • 1.3.3(Jun 13, 2017)

  • 1.3.2(Jun 9, 2017)

    Change log:

    • App API:
      • New endpoints: feed_only_me(), media_only_me(), media_undo_only_me(), enable_post_notifications(), disable_post_notifications()
      • Deprecated: user_map(), expose()
      • Removed device info, keys, etc from settings property.
    • Web API:
      • New endpoints: post_photo(), tag_feed(), location_feed()
      • Removed user-agent from settings property.
    Source code(tar.gz)
    Source code(zip)
  • 1.3.1(Jun 3, 2017)

    Change log:

    • App API:
      • Client.standard_ratios() and Client.reel_ratios() is deprecated and replaced with MediaRatios.standard and MediaRatios.reel respectively.
      • Deprecated and experimental endpoints now warned with ClientDeprecationWarning and ClientExperimentalWarning.
      • collection_feed(), feed_liked(), self_feed() have been updated to support pagination through the max_id kwarg.
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(May 21, 2017)

    1.3.0

    This update is recommended, especially for those using the web api.

    • Web API:
      • Important: The new graphql endpoint appears to be replacing the old query endpoint. The graphql endpoint is comparatively more limited and some attributes may no longer be available.
      • You should exercise caution when using functions relying on the old query endpoints such as user_info() and media_info()since IG no longer uses them.
      • user_feed() is now using the graphql endpoint and has compatibility-breaking changes. 9d7caef5ecdd0574739c3f608e1ac8d385a7228f
    • App API:
      • Fix regression with photo posting and profile image update. f7c093820586536ad155095f4350c80f58046020
      • Breaking Change: Removed is_video argument from reel_compatible_aspect_ratio() b9da4cfecc7cc8651d4e0e4f3b17628ba802ce00
    Source code(tar.gz)
    Source code(zip)
  • 1.2.8(May 16, 2017)

    Change log:

    • New app client endpoint: api.bulk_delete_comments() 365dadbb3dd4f6dfd3d33fb5c8ccad85e87b9112
    • Prevent uploading of very small chunks when posting video
    • Web API updates to use new graphql endpoints cc9ae226e474163750a4ba7dfd26999fe423da20
    Source code(tar.gz)
    Source code(zip)
  • 1.2.7(May 10, 2017)

    Change log:

    • New endpoints: api.friendships_unblock(), api.block_friend_reel(), api.unblock_friend_reel(), api.set_reel_block_status(), api.blocked_reels(), api.blocked_user_list(), api.user_reel_settings(), api.set_reel_settings()
    • Update api.media_seen()
    • Fix ClientCompatPatch.media() for carousel/album posts
    • Other minor fixes
    Source code(tar.gz)
    Source code(zip)
  • 1.2.6(Apr 30, 2017)

    Change log:

    • Change default user agent constants
    • Video:
      • implement chunks upload retry
      • remove configure delay
      • support using a file-like object instead of having the whole file in memory
    • Implement collections
    • Update app version to 10.16.0
    • Other minor fixes
    Source code(tar.gz)
    Source code(zip)
  • 1.2.5(Apr 7, 2017)

    Change log:

    • Update app version to 10.15.0
    • New ad_id property for login
    • Update friendships_create(), friendships_destroy(), post_comment(), post_like(), delete_like()
    Source code(tar.gz)
    Source code(zip)
  • 1.2.4(Apr 1, 2017)

  • 1.2.3(Mar 31, 2017)

  • 1.2.2(Mar 30, 2017)

  • 1.2.1(Mar 27, 2017)

  • 1.2.0(Mar 23, 2017)

    Change log:

    • Invalid parameters now consistently raise ValueError. Affected endpoints can be found in 146a84b.
    • New ClientThrottledError for 429 (too many requests) errors
    Source code(tar.gz)
    Source code(zip)
  • 1.1.5(Mar 20, 2017)

  • 1.1.4(Mar 15, 2017)

    Change log:

    • Update configure story endpoint and parameters
    • Validate video story duration
    • New utility class InstagramID for ID/shortcode conversions
    Source code(tar.gz)
    Source code(zip)
  • 1.1.3(Mar 14, 2017)

Owner
Buy me a coffee if you use my work
null
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
Integrating Amazon API Gateway private endpoints with on-premises networks

Integrating Amazon API Gateway private endpoints with on-premises networks Read the blog about this application: Integrating Amazon API Gateway privat

AWS Samples 12 Sep 9, 2022
A simple way to create a request to the coinpayment API with a valid HMAC using your private key and command

Coinpayments Verify TXID Created for Astral Discord bot A simple way to create a request to the coinpayment API with a valid HMAC using your private k

HellSec 1 Nov 7, 2022
A wrapper for The Movie Database API v3 and v4 that only uses the read access token (not api key).

fulltmdb A wrapper for The Movie Database API v3 and v4 that only uses the read access token (not api key). Installation Use the package manager pip t

Jacob Hale 2 Sep 26, 2021
Python script to replace BTC adresses in the clipboard with similar looking ones, whose private key can be retrieved by a netcat listener or similar.

BTCStealer Python script to replace BTC adresses in the clipboard with similar looking ones, whose private key can be retrieved by a netcat listener o

Some Person 6 Jun 7, 2022
Clash of Clans v6.253 private server written in python

cocps Clash of Clans v6.253 private server written in python how2play download server files download Patched APK run Main.py and play Authors Patched

null 5 Aug 28, 2022
A Python script to backup all repos (public or private) of a user.

GithubBackupAllRepos A Python script to backup all repos (public or private) of a user. Features Clone public and private repos Load specified SSH key

Podalirius 15 Jan 3, 2023
Unofficial instagram API, give you access to ALL instagram features (like, follow, upload photo and video and etc)! Write on python.

Instagram-API-python Unofficial Instagram API to give you access to ALL Instagram features (like, follow, upload photo and video, etc)! Written in Pyt

Vladimir Bezrukov 1 Nov 19, 2021
Send notification to your telegram group/channel/private whenever a new video is uploaded on a youtube channel!

YouTube Feeds Bot. Send notification to your telegram group/channel/private whenever a new video is uploaded on a youtube channel! Variables BOT_TOKEN

Aditya 30 Dec 7, 2022
Lazy airdrop based on private temporary ids

LobsterDAO This uses a modified MerkleDistributor, which allows to issue a lazy airdrop using temporary IDs. In this example it uses Telegram chat_id

null 41 Sep 10, 2022
Discord bot to display private leaderboards for Advent of Code.

Advent Of Code Discord Bot Discord bot for displaying Advent of Code private leardboards, as well as custom leaderboards where participants can set th

The Future Gadgets Lab 6 Nov 29, 2022
A simple Discord Bot created for basic functionality and fun chat commands for use in a private server.

LoveAndChaos-Bot v0.1.0 LoveAndChaos-Bot is a Discord Bot specifically designed for a private server; this bot is merely a test and a method to expose

Morgan Rose 1 Dec 12, 2021
Pancakeswap Sniper BOT - TORNADO CASH Proxy (MAC WINDOWS ANDROID LINUX) A fully decentralized protocol for private transactions

TORNADO CASH Proxy Pancakeswap Sniper BOT 2022-V1 (MAC WINDOWS ANDROID LINUX) ⭐️ A fully decentralized protocol for private transactions ⭐️ AUTO DOWNL

Crypto Trader 1 Jan 5, 2022
A fully decentralized protocol for private transactions FAST snipe BUY token on LUANCH after add LIQUIDITY

TORNADO CASH Pancakeswap Sniper BOT 2022-V1 (MAC WINDOWS ANDROID LINUX) ⭐️ A fully decentralized protocol for private and safe transactions ⭐️ AUTO DO

Crypto Trader 2 Jan 6, 2022
Customizable and open-sourced bot for a few private servers

MarlBot A private bot for controlling monkeys and turtles. Why does this bot exist? The bot exists as a general-purpose community bot for a select few

KR 1 Jan 18, 2022
LimitatiBot - A simple telegram bot to establish a conversation with a user without having to use private chats

?? LimitatiBot [0.2] LimitatiBot is a simple telegram bot to establish a convers

xMrPente 9 Dec 27, 2022
Frwdit-V1 - A Simple Bot can copy any media to a private channel provided

?? Auto Forward V2 A Simple Bot can copy any media to a private channel provided

FUCK OFF ANE 3 Dec 3, 2022
🔮 Uncover some followers of a private instagram account

Private Instagram Chaining ?? Uncover part of followers of an instagram private account I have this private instagram account julianakhao. I need to g

аэт 69 Dec 17, 2022