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)],
)
- Index
- Getting Started
- Usage Guide
- Interactions
Media
- Publication (also called post): Photo, Video, Album, IGTV and ReelsResource
- Part of Media (for albums)MediaOembed
- Short version of MediaAccount
- Full private info for your account (e.g. email, phone_number)User
- Full public user dataUserShort
- Short public user data (used in Usertag, Comment, Media, Direct Message)Usertag
- Tag user in Media (coordinates + UserShort)Location
- GEO location (GEO coordinates, name, address)Hashtag
- Hashtag object (id, name, picture)Collection
- Collection of medias (name, picture and list of medias)Comment
- Comments to MediaStory
- StoryStoryLink
- Link (Swipe up)StoryLocation
- Tag Location in Story (as sticker)StoryMention
- Mention users in Story (user, coordinates and dimensions)StoryHashtag
- Hashtag for story (as sticker)StorySticker
- Tag sticker to story (for example from giphy)StoryBuild
- StoryBuilder return path to photo/video and mention co-ordinatesDirectThread
- Thread (topic) with messages in Direct MessageDirectMessage
- Message in Direct MessageInsight
- Insights for a post
- Development Guide
- Handle Exceptions
- Challenge Resolver
- Exceptions