Package: instagscrape
Instagram Private APIA Python wrapper for the Instagram private API with no 3rd party dependencies. Supports both the app and web APIs.OverviewI wrote this to access Instagram's API when they clamped down on developer access. Because this is meant to achieveparitywith theofficial public API, methods not available in the public API will generally have lower priority.Problems? Please check thedocsbefore submitting an issue.FeaturesSupports many functions that are only available through the official app, such as:Multiple feeds, such asuser feed,location feed,tag feed,popular feedPost aphotoorvideoto your feed or storiesLike/unlikepostsGetpost commentsPost/deletecommentsLike/unlikecommentsFollow/unfollowusersUserstoriesAndmore!The web api client supports a subset of functions that do not require login, such as:Get userinfoandfeedGetpost commentsAndmore!Compatible with functions available through the public API using the ClientCompatPatch (app/web) utility classBeta Python 3 supportAnextension moduleis available to help with common tasks like pagination, posting photos or videos.DocumentationDocumentation is available athttps://instagram-private-api.readthedocs.io/en/latest/InstallInstall with pip:pip install git+https://git@github.com/ping/instagram_private_api.git@1.6.0To update:pip install git+https://git@github.com/ping/instagram_private_api.git@1.6.0 --upgradeTo update with latest repo code:pip install git+https://git@github.com/ping/instagram_private_api.git --upgrade --force-reinstallTested on Python 2.7 and 3.5.UsageTheapp API clientemulates the official app and has a larger set of functions. Theweb API clienthas a smaller set but can be used without logging in.Your choice will depend on your use case.Theexamples/andtests/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 theofficial app's APIfrominstascrapeimportClient,ClientCompatPatchuser_name='YOUR_LOGIN_USER_NAME'password='YOUR_PASSWORD'api=Client(user_name,password)results=api.feed_timeline()items=[itemforiteminresults.get('feed_items',[])ifitem.get('media_or_ad')]foriteminitems:# Manually patch the entity to match the public api as closely as possible, optional# To automatically patch entities, initialise the Client with auto_patch=TrueClientCompatPatch.media(item['media_or_ad'])print(item['media_or_ad']['code'])Option 2: Use theofficial website's APIfrominstascrape.webimportClient,ClientCompatPatch,ClientError,ClientLoginError# Without any authenticationweb_api=Client(auto_patch=True,drop_incompat_keys=False)user_feed_info=web_api.user_feed('329452045',count=10)forpostinuser_feed_info:print('%sfrom%s'%(post['link'],post['user']['username']))# Some endpoints, e.g. user_following are available only after authenticationauthed_web_api=Client(auto_patch=True,authenticate=True,username='YOUR_USERNAME',password='YOUR_PASSWORD')following=authed_web_api.user_following('123456')foruserinfollowing: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-loginYou 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 to90 days.SupportMake sure to review thecontributing documentationbefore submitting an issue report or pull request.Donate to the original contributor here:@pingLegalDisclaimer: This is not affliated, endorsed or certified by Instagram. This is an independent and unofficial API. Strictlynot for spam. Use at your own risk.