Instagram Photo, Video, Story, Highlight, Postlive, Following, and Follower in Go
Get Instagram media (photos and videos), stories, story highlights, postlives, following and followers in Go.
This package only access Instagram private and public API:
- Based on this package, Chrome extension igdlcrx helps you download stories and posts, similiar to Downloader for Instagram™ + Direct Message
- Also based on this package, the package in download directory helps you download media (photos/videos), stories, story highlights, or postlives.
Use Chrome extension in this repo to get the cookies. Load the extension using Chrome extension developer mode. Log in to Instagram using Chrome. Click on the loaded extension button and save the content as auth.json. We will use it later to access Instagram API.
Given the URL of the post as follows:
https://www.instagram.com/p/BfJzG64BZVY/
The code of the post is BfJzG64BZVY.
This package instago only access the Instagram public and private API and get metadata from the API.
Install the package by go get
:
$ go get -u github.com/siongui/instago
You can use the following methods without cookies
- GetUserInfoNoLogin
- GetRecentPostCodeNoLogin
- GetUserId
- GetPostInfoNoLogin
- GetUserProfilePicUrlHd
- GetAllPostMediaNoLogin
For the other methods which need cookies to access Instagram API, you must call NewInstagramApiManager first:
import (
"github.com/siongui/instago"
)
mgr := instago.NewInstagramApiManager("auth.json")
Then you can use mgr to get metadata from Instagram API. For example, you can get all post codes of the user instagram as follows:
codes, err := mgr.GetAllPostCode("instagram")
if err != nil {
panic(err)
}
for _, code := range codes {
println("URL: https://www.instagram.com/p/%s/\n", code)
}
For complete examples, see test files (files ends with _test.go). The following are some examples you may be interested in:
- Get post information: See post_test.go
- Get URLs of all posts of a specific user: See getall_test.go
- Get id by username: See userinfo_test.go
- Discover top live: See toplive_test.go
- Top searches of Instagram web: See topsearch_test.go
Use the following User-Agent to get post-live field in reels tray feed.
Instagram 10.26.0 (iPhone8,1; iOS 10_2; en_US; en-US; scale=2.00; gamut=normal; 750x1334) AppleWebKit/420+
Get all user's media:
Do not remove query string in the URLs of photo/viedo/story/highlight. It may cause 403 Forbidden when downloading the URL. See issue #2 for more info.
Saved endpoint: see ping/instagram_private_api
postlive URL issue: Google search "Bad URL timestamp". See Instagram reports "Bad URL timestamp". replacing & with & in the access link.
- Get data from Instagram's private API — Alberto Moral
- What is the API Endpoints for the Feeds "People who liked my posts" and "Activities from my followings" · Issue #42 · huttarichard/instagram-private-api · GitHub
- Search · go instagram · GitHub then found Update timeline API from Get to Post
- private API reference - github.com/ping/instagram_private_api
Released in public domain. See UNLICENSE.
[1] | GitHub - siongui/goiguserid: Get id of Instagram user in Go |
[2] | GitHub - siongui/goigstorylink: Get Links (URL) of Instagram Stories in Go |
[3] | GitHub - siongui/goigfollow: Get Instagram following and followers in Go |
[4] | GitHub - siongui/goigstorydl: Download Instagram Stories in Go |
[5] | GitHub - siongui/goigmedia: Get links of Instagram user media (photos and videos) in Go. |
[6] | JSON Formatter & Validator |