当前位置: 首页 > 工具软件 > instagrapi > 使用案例 >

python的instagrapi方法文档

许招
2023-12-01

boss上hr甩过来一个github链接,让我熟悉一下,但是面试定的是第二天……
时间不等人,赶紧配置一下环境,再想办法注册ins,跑跑代码验证是否安装成功
再看看文档,翻译一下,于是乎有了这份方法文档


泰裤啦,要会js逆向、要会浏览器嵌入、要会H5,还说什么多线程、代理池、抓包都是初级操作。
这么说工资很高喽?一问正式工资四千,上面都会才五千,有三四年经验就六千……
再看岗位名称,初级python工程师,再看需求,高级python全栈工程师,你礼貌吗?你礼貌吗!!
浪费我6块钱的地铁交通费,浪费我4块钱的打印费用,浪费我3个小时的时间。
这公司就是依托答辩。


未润色完毕,也可能缺少了几个方法

媒体

MethodReturnDescription描述
media_id(media_pk: int)strReturn media_id by media_pk (e.g. 2277033926878261772 -> 2277033926878261772_1903424587)按media_pk返回media_id(例如2277033926878261772->22770339268 78261772_1903424587)
media_pk(media_id: str)intReturn media_pk by media_id (e.g. 2277033926878261772_1903424587 -> 2277033926878261772)按media_id返回media_pk(例如2277033926878261772_1903424587->22770339268 78261772)
media_pk_from_code(code: str)intReturn media_pk返回媒体_pk
media_pk_from_url(url: str)intReturn media_pk返回媒体_pk
user_medias(user_id: int, amount: int = 20)List[Media]Get list of medias by user_id按user_id获取媒体列表
user_medias_paginated(user_id: int, amount: int = 0, end_cursor: str = “”)Tuple[List[Media], str]Get one page of medias by user_id通过user_id获取一页媒体
user_clips(user_id: int, amount: int = 50)List[Media]Get list of clips (reels) by user_id按user_id获取剪辑(卷轴)列表
usertag_medias(user_id: int, amount: int = 20)List[Media]Get medias where a user is tagged获取标记用户的媒体
media_info(media_pk: int)MediaReturn media info返回媒体信息
media_delete(media_pk: int)boolDelete media删除媒体
media_edit(media_pk: int, caption: str, title: str, usertags: List[Usertag], location: Location)dictChange caption for media更改媒体标题
media_user(media_pk: int)UserGet user info for media获取媒体的用户信息
media_oembed(url: str)MediaOembedReturn short media info by media URL按媒体URL返回短媒体信息
media_like(media_id: str)boolLike media喜欢媒体
media_unlike(media_id: str)boolUnlike media与媒体不同
media_seen(media_ids: List[str], skipped_media_ids: List[str])boolMark a media as seen将媒体标记为已看到
media_likers(media_id: str)List[UserShort]Return list of users who liked this post (due to Instagram limitations, this may not return a complete list)返回喜欢此帖子的用户列表(由于Instagram的限制,这可能不会返回完整的列表)
media_archive(media_id: str)boolArchive a media存档媒体
media_unarchive(media_id: str)boolUnarchive a media取消存档媒体
media_pin(media_id: str)boolPin a media to user profile将媒体固定到用户配置文件
media_unpin(media_id: str)boolUnpin a media to user profile取消固定媒体到用户配置文件

账户

MethodReturnDescription描述
account_info()AccountGet private info for your account (e.g. email, phone_number)获取您帐户的私人信息(例如电子邮件、电话号码)
account_edit(email: str, phone_number: str, username: str, full_name: str, biography: str, external_url: str)AccountChange profile data更改配置文件数据
account_change_picture(path: Path)UserShortChange Profile picture更改个人资料图片
send_confirm_email(email: str)dictSend confirmation code to new email address将确认码发送到新的电子邮件地址
send_confirm_phone_number(phone_number: str)dictSend confirmation code to new phone number向新电话号码发送确认码

用户

MethodReturnDescription描述
user_followers(user_id: int, amount: int = 0)Dict[int, UserShort]Get dict of followers users (amount=0 - fetch all followers)获取关注者用户的dict(数量=0-获取所有关注者)
user_following(user_id: int, amount: int = 0)Dict[int, UserShort]Get dict of following users (amount=0 - fetch all)获取以下用户的dict(数量=0-获取全部)
search_followers(user_id: int, query: str)List[UserShort]Search by followers按关注者搜索
search_following(user_id: int, query: str)List[UserShort]Search by following按以下内容搜索
user_info(user_id: int)UserGet user info获取用户信息
user_info_by_username(username: str)UserGet user info by username按用户名获取用户信息
user_follow(user_id: int)boolFollow user关注用户
user_unfollow(user_id: int)boolUnfollow user不允许用户
user_id_from_username(username: str)intGet user_id by username按用户名获取user_id
username_from_user_id(user_id: int)strGet username by user_id通过user_id获取用户名
user_remove_follower(user_id: int)boolRemove your follower移除你的追随者
mute_posts_from_follow(user_id: int)boolMute posts from following user将以下用户的帖子静音
unmute_posts_from_follow(user_id: int)boolUnmute posts from following user取消对以下用户的帖子的静音
mute_stories_from_follow(user_id: int)boolMute stories from following user将以下用户的故事静音
enable_posts_notifications(user_id: int)boolEnable post notifications of user启用用户的发布通知
disable_posts_notifications(user_id: int)boolDisable post notifications of user禁用用户的发布通知
enable_videos_notifications(user_id: int)boolEnable videos notifications of user启用用户的视频通知
disable_videos_notifications(user_id: int)boolDisable videos notifications of user禁用用户的视频通知
enable_reels_notifications(user_id: int)boolEnable reels notifications of user启用用户的卷轴通知
disable_reels_notifications(user_id: int)boolDisable reels notifications of user禁用用户的卷轴通知
enable_stories_notifications(user_id: int)boolEnable stories notifications of user启用用户的故事通知
disable_stories_notifications(user_id: int)boolDisable stories notifications of user禁用用户的故事通知
close_friend_add(user_id: int)boolAdd to Close Friends List添加到好友列表
close_friend_remove(user_id: int)boolRemove from Close Friends List从好友列表中删除

位置

MethodReturnDescription描述
location_search(lat: float, lng: float)List[Location]Search Location by GEO coordinates通过GEO坐标搜索位置
location_complete(location: Location)LocationComplete blank fields填写空白字段
location_build(location: Location)StringSerialized JSON序列化JSON
location_info(location_pk: int)LocationReturn Location info (pk, name, address, lng, lat, external_id, external_id_source)返回位置信息(pk、名称、地址、lng、lat、external_id、external_id_source)
location_medias_top(location_pk: int, amount: int = 9)List[Media]Return Top posts by Location按位置返回热点
location_medias_recent(location_pk: int, amount: int = 24)List[Media]Return Most recent posts by Location按位置返回最近的帖子
fbsearch_places(query: str, lat: float = 40.74, lng: float = -73.94)List[Location]>Search places via Facebook Search (40.74/-73.94 - New York, default GEO)>通过Facebook搜索搜索地点(40.74/73.94-纽约,默认GEO)

标签

MethodReturnDescription描述
hashtag_info(name: str)HashtagReturn Hashtag info (id, name, picture)返回哈希标签信息(id,name,picture)
hashtag_related_hashtags(name: str)List[Hashtag]Return list of related Hashtag返回相关Hashtag的列表
hashtag_medias_top(name: str, amount: int = 9)List[Media]Return Top posts by Hashtag按哈希标签返回热门帖子
hashtag_medias_recent(name: str, amount: int = 27)List[Media]Return Most recent posts by Hashtag按哈希标签返回最近的帖子

合集

MethodReturnDescription描述
collections()List[Collection]Get all account collections获取所有帐户集合
collection_pk_by_name(name: str)intGet collection_pk by name按名称获取collection_pk
collection_medias_by_name(name: str)List[Media]Get medias in collection by name按名称获取集合中的媒体
collection_medias(collection_pk: int, amount: int = 21, last_media_pk: int = 0)List[Media]Get medias in collection by collection_id; Use amount=0 to return all medias in collection; Use last_media_pk to return medias by cursor通过collection_id获取收藏中的媒体;使用amount=0返回集合中的所有媒体;使用last_media_pk通过光标返回媒体
liked_medias(amount: int = 21, last_media_pk: int = 0)List[Media]Get media you have liked获取您喜欢的媒体
media_save(media_id: str, collection_pk: int = None)boolSave media to collection将媒体保存到收藏
media_unsave(media_id: str, collection_pk: int = None)boolUnsave media from collection取消保存集合中的媒体

评论

MethodReturnDescription描述
media_comment(media_id: str, text: str, replied_to_comment_id: Optional[int] = None)CommentAdd new comment to media向媒体添加新评论
media_comments(media_id: str, amount: int = 0)List[Comment]Get a list comments for media (amount=0 - all comments)获取媒体的列表评论(数量=0-所有评论)
media_comments_chunk(media_id: str, max_amount: int, min_id: str = None)Tuple[List[Comment], str]Get chunk of comments on a media and end_cursor获取媒体和end_cursor上的大量评论
comment_like(comment_pk: int)boolLike a comment点赞评论
comment_unlike(comment_pk: int)boolUnlike a comment与评论不同
comment_pin(media_id: str,comment_pk: int)boolPin a comment固定评论
comment_unpin(media_id: str,comment_pk: int)boolUnpin a comment取消固定评论
comment_bulk_delete(media_id: str, comment_pks: List[int])boolDelete a comment删除评论

热点

MethodReturnDescription描述
highlight_pk_from_url(url: str)intGet Highlight PK from URL从URL获取突出显示PK
highlight_info(highlight_pk: int)HighlightGet Highlight by pk or id通过pk或id获取高亮显示
user_highlights(user_id: int, amount: int = 0)List[Highlight]Get a user’s highlights获取用户的精彩内容
highlight_create(title: str, story_ids: List[str], cover_story_id: str = “”, crop_rect: List[float] = [0.0, 0.21830457, 1.0, 0.78094524])HighlightCreate highlight创建高亮显示
highlight_change_title(highlight_pk: str, title: str)HighlightChange title for highlight更改突出显示的标题
highlight_change_cover(highlight_pk: str, cover_path: Path)HighlightChange cover for highlight更换突出显示的封面
highlight_add_stories(highlight_pk: str, added_media_ids: List[str])HighlightAdd stories to highlight添加要突出显示的故事
highlight_remove_stories(highlight_pk: str, removed_media_ids: List[str])HighlightRemove stories from highlight从突出显示中删除故事
highlight_delete(highlight_pk: str)boolDelete highlight删除突出显示

内容

MethodReturnDescription描述
user_stories(user_id: int, amount: int = None)List[Story]Get list of stories by user_id按user_id获取故事列表
story_info(story_pk: int, use_cache: bool = True)StoryReturn story info返回故事信息
story_delete(story_pk: int)boolDelete story删除报道
story_seen(story_pks: List[int], skipped_story_pks: List[int])boolMark a story as seen将故事标记为已看到
story_pk_from_url(url: str)intGet Story (media) PK from URL从URL获取故事(媒体)PK
story_download(story_pk: int, filename: str = “”, folder: Path = “”)PathDownload story media by media_type按媒体类型下载故事媒体
story_download_by_url(url: str, filename: str = “”, folder: Path = “”)PathDownload story media using URL to file (mp4 or jpg)使用URL下载故事媒体到文件(mp4或jpg)
story_viewers(story_pk: int, amount: int = 20)List[UserShort]List of story viewers (via Private API)故事观众列表(通过私有API)
story_like(story_id: str, revert: bool = False)boolLike a story就像一个故事
story_unlike(story_id: str)boolUnlike a story不像一个故事
photo_upload_to_story(path: Path, caption: str, upload_id: str, mentions: List[Usertag], locations: List[StoryLocation], links: List[StoryLink], hashtags: List[StoryHashtag], stickers: List[StorySticker], extra_data: Dict[str, str] = {})StoryUpload photo (Support JPG files)上传照片(支持JPG文件)
video_upload_to_story(path: Path, caption: str, thumbnail: Path, mentions: List[Usertag], locations: List[StoryLocation], links: List[StoryLink], hashtags: List[StoryHashtag], stickers: List[StorySticker], extra_data: Dict[str, str] = {})StoryUpload video (Support MP4 files)上传视频(支持MP4文件)
StoryBuilder.build_clip(clip: moviepy.Clip, max_duration: int = 0)StoryBuildBuild CompositeVideoClip with background and mentioned users. Return MP4 file and mentions with coordinates使用背景和提到的用户构建CompositeVideoClip。返回MP4文件并提及坐标
StoryBuilder.video(max_duration: int = 0)StoryBuildCall build_clip(VideoClip, max_duration)调用build_clip(视频剪辑,最大持续时间)
StoryBuilder.photo(max_duration: int = 0)StoryBuildCall build_clip(ImageClip, max_duration)调用build_clip(图像剪辑,最大持续时间)

消息

MethodReturnDescription描述
direct_threads(amount: int = 20, selected_filter: str = “”, thread_message_limit: Optional[int] = None)List[DirectThread]Get all threads from inbox从收件箱获取所有线程
Note: selected_filter = “”, “flagged” or “unread”从挂起的收件箱中获取所有线程
direct_pending_inbox(amount: int = 20)List[DirectThread]Get all threads from pending inbox获取包含消息的线程
direct_thread(thread_id: int, amount: int = 20)DirectThreadGet Thread with Messages仅获取线程中的消息
direct_messages(thread_id: int, amount: int = 20)List[DirectMessage]Get only Messages in Thread将消息添加到现有线程
direct_answer(thread_id: int, text: str)DirectMessageAdd Message to exist Thread向用户或线程发送消息
direct_send(text: str, user_ids: List[int] = [], thread_ids: List[int] = [])DirectMessageSend Message to Users or Threads搜索线程(例如,按用户名)
direct_search(query: str)List[DirectShortThread]Search threads (for example by username)按user_id获取线程
direct_thread_by_participants(user_ids: List[int])DirectThreadGet thread by user_id删除(称为“隐藏”)
direct_thread_hide(thread_id: int)boolDelete (called “hide”)与用户列表共享媒体
direct_media_share(media_id: str, user_ids: List[int])DirectMessageShare a media to list of users将故事分享给用户列表
direct_story_share(story_id: str, user_ids: List[int], thread_ids: List[int])DirectMessageShare a story to list of users与用户列表共享用户配置文件
direct_profile_share(user_id: str, user_ids: List[int], thread_ids: List[int])DirectMessageShare a user profile to list of users将线程标记为未读
direct_thread_mark_unread(thread_id: int)boolMark a thread as unread从线程中删除消息
direct_message_delete(thread_id: int, message_id: int)boolDelete a message from thread将线程静音
direct_thread_mute(thread_id: int, revert: bool = False)boolMute the thread取消线程静音
direct_thread_unmute(thread_id: int)boolUnmute the thread将线程的视频通话静音
direct_thread_mute_video_call(thread_id: int, revert: bool = False)boolMute video call for the thread取消对线程的视频调用的静音
direct_thread_unmute_video_call(thread_id: int)boolUnmute video call for the thread将直接照片发送到用户或线程列表
direct_send_photo(path: Path, user_ids: List[int], thread_ids: List[int])DirectMessageSend a direct photo to list of users or threads向用户或线程列表发送直接视频
direct_send_video(path: Path, user_ids: List[int], thread_ids: List[int])DirectMessageSend a direct video to list of users or threads将视频作为故事上传到直接线程并进行配置
video_upload_to_direct(path: Path, caption: str, thumbnail: Path, mentions: List[StoryMention], thread_ids: List[int] = [], extra_data: Dict[str, str] = {})DirectMessageUpload video to direct thread as a story and configure it将视频作为故事上传到直接线程并进行配置

统计数据

MethodReturnDescription描述
insights_media_feed_all(post_type: str = “ALL”, time_frame: str = “TWO_YEARS”, data_ordering: str = “REACH_COUNT”, count: int = 0, sleep: int = 2)List[Dict]Return medias with insights返回有见解的媒体
insights_account()DictGet statistics by your account按您的帐户获取统计信息
insights_media(media_pk: int)DictGet statistics by your media通过媒体获取统计数据

歌曲

MethodReturnDescription描述
track_info_by_canonical_id(music_canonical_id: str)TrackGet Track by music_canonical_id按music_canonical_id获取曲目
track_download_by_url(url: str, filename: str = “”, folder: Path = “”)PathDownload track by URL按URL下载曲目
search_music(query: str)List[Track]Return list of tracks返回曲目列表
 类似资料: