Skip to content

🔥 The fastest and powerful Python library for Instagram Private API 2021

License

Notifications You must be signed in to change notification settings

farshadnobody/instagrapi

 
 

Repository files navigation

Package PyPI PyPI - Python Version Checked with mypy

Downloads Downloads Downloads

Donate

instagrapi - Unofficial Instagram API for Python

Fast and effective Instagram Private API wrapper (public+private requests and challenge resolver) without selenium. Use the most recent version of the API from Instagram, which was obtained using reverse-engineering with Charles Proxy and Proxyman.

Instagram API valid for 2 September 2021 (last reverse-engineering check)

Support Python >= 3.6

For any other languages (e.g. C++, C#, F#, D, Golang, Erlang, Elixir, Nim, Haskell, Lisp, Closure, Julia, R, Java, Kotlin, Scala, OCaml, JavaScript, Crystal, Ruby, Rust, Swift, Objective-C, Visual Basic, .NET, Pascal, Perl, Lua, PHP and others), I suggest using instagrapi-rest

Support Chat in Telegram and GitHub Discussions

Features

  1. Performs Public API (web, anonymous) or Private API (mobile app, authorized) requests depending on the situation (to avoid Instagram limits)
  2. Login by username and password, including 2FA and by sessionid (and uses Authorization header instead Cookies)
  3. Challenge Resolver have Email and SMS handlers
  4. Support upload a Photo, Video, IGTV, Reels, Albums and Stories
  5. Support work with User, Media, Comment, Insights, Collections, Location (Place), Hashtag and Direct Message objects
  6. Like, Follow, Edit account (Bio) and much more else
  7. Insights by account, posts and stories
  8. Build stories with custom background, font animation, swipe up link and mention users
  9. In the next release, account registration and captcha passing will appear

Example

Basic Usage

from instagrapi import Client

cl = Client()
cl.login(ACCOUNT_USERNAME, ACCOUNT_PASSWORD)

user_id = cl.user_id_from_username("adw0rd")
medias = cl.user_medias(user_id, 20)
The full example
from instagrapi import Client
from instagrapi.types import Location, StoryMention, StoryLocation, StoryLink, StoryHashtag

cl = Client()
cl.login(USERNAME, PASSWORD, verification_code="<2FA CODE HERE>")

media_path = cl.video_download(
    cl.media_pk_from_url('https://www.instagram.com/p/CGgDsi7JQdS/')
)
adw0rd = cl.user_info_by_username('adw0rd')
loc = cl.location_complete(Location(name='Test', lat=42.0, lng=42.0))
ht = cl.hashtag_info('dhbastards')

cl.video_upload_to_story(
    media_path,
    "Credits @adw0rd",
    mentions=[StoryMention(user=adw0rd, x=0.49892962, y=0.703125, width=0.8333333333333334, height=0.125)],
    locations=[StoryLocation(location=loc, x=0.33, y=0.22, width=0.4, height=0.7)],
    links=[StoryLink(webUri='https://github.com/adw0rd/instagrapi')],
    hashtags=[StoryHashtag(hashtag=ht, x=0.23, y=0.32, width=0.5, height=0.22)],
)

Documentation

About

🔥 The fastest and powerful Python library for Instagram Private API 2021

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.8%
  • Shell 1.1%
  • Dockerfile 0.1%