instago

package module
v0.0.0-...-9da679e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: Unlicense Imports: 13 Imported by: 8

README

==================================================================================
Instagram Photo, Video, Story, Highlight, Postlive, Following, and Follower in Go_
==================================================================================

.. image:: https://img.shields.io/badge/Language-Go-blue.svg
   :target: https://golang.org/

.. image:: https://godoc.org/github.com/siongui/instago?status.svg
   :target: https://godoc.org/github.com/siongui/instago

.. image:: https://api.travis-ci.org/siongui/instago.svg?branch=master
   :target: https://travis-ci.org/siongui/instago

.. image:: https://goreportcard.com/badge/github.com/siongui/instago
   :target: https://goreportcard.com/report/github.com/siongui/instago

.. image:: https://img.shields.io/badge/license-Unlicense-blue.svg
   :target: https://raw.githubusercontent.com/siongui/instago/master/UNLICENSE

.. image:: https://img.shields.io/badge/Status-Beta-brightgreen.svg

.. image:: https://img.shields.io/twitter/url/https/github.com/siongui/instago.svg?style=social
   :target: https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D


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 <download>`_ directory
  helps you download media (photos/videos), stories, story highlights, or
  postlives.

Obtain Cookies
++++++++++++++

Use `Chrome extension in this repo <crx-cookies>`_ 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.


Terminology
+++++++++++

Given the URL of the post as follows:

::

  https://www.instagram.com/p/BfJzG64BZVY/

The *code* of the post is **BfJzG64BZVY**.


Usage
+++++

This package *instago* only access the Instagram public and private API and get
metadata from the API.

Install the package by ``go get``:

.. code-block:: bash

  $ go get -u github.com/siongui/instago

You can use the following methods without cookies

- `GetUserInfoNoLogin <https://godoc.org/github.com/siongui/instago#GetUserInfoNoLogin>`_
- `GetRecentPostCodeNoLogin <https://godoc.org/github.com/siongui/instago#GetRecentPostCodeNoLogin>`_
- `GetUserId <https://godoc.org/github.com/siongui/instago#GetUserId>`_
- `GetPostInfoNoLogin <https://godoc.org/github.com/siongui/instago#GetPostInfoNoLogin>`_
- `GetUserProfilePicUrlHd <https://godoc.org/github.com/siongui/instago#GetUserProfilePicUrlHd>`_
- `GetAllPostMediaNoLogin <https://godoc.org/github.com/siongui/instago#GetAllPostMediaNoLogin>`_

For the other methods which need cookies to access Instagram API, you must call
NewInstagramApiManager_ first:

.. code-block:: go

  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 <https://www.instagram.com/instagram/>`__ as follows:

.. code-block:: go

  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 <post_test.go>`_
- Get URLs of all posts of a specific user: See `getall_test.go <getall_test.go>`_
- Get id by username: See `userinfo_test.go <userinfo_test.go>`_
- Discover top live: See `toplive_test.go <toplive_test.go>`_
- Top searches of Instagram web: See `topsearch_test.go <topsearch_test.go>`_


Tricks
++++++

- 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+**

  From `replay.py`_ in `instagram_private_api_extensions`_

- Get all user's media:

  * `How can I get a user's media from Instagram without authenticating as a user? - Stack Overflow <https://stackoverflow.com/a/47243409>`_
  * `instagram_web_api.client — instagram_private_api 1.4.1 documentation <https://instagram-private-api.readthedocs.io/en/latest/_modules/instagram_web_api/client.html#Client.user_feed>`_
  * `instagram graphql api id - Google search <https://www.google.com/search?q=instagram+graphql+api+id>`_

- `Web scraping: instagram.com | Shiori <https://kaijento.github.io/2017/05/17/web-scraping-instagram.com/>`_

- | `query_hash on instagram graphql - Google search <https://www.google.com/search?q=query_hash+on+instagram+graphql>`_
  | `How to scrape pages with infinite scroll: extracting data from Instagram - Diggernaut <https://www.diggernaut.com/blog/how-to-scrape-pages-infinite-scroll-extracting-data-from-instagram/>`_
  | `colly instagram example <https://github.com/gocolly/colly/blob/master/_examples/instagram/instagram.go>`_

- 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 <https://github.com/ping/instagram_private_api>`_

- postlive URL issue: Google search "Bad URL timestamp". See `Instagram reports "Bad URL timestamp" <https://www.reddit.com/r/ifttt/comments/e79x24/instagram_reports_bad_url_timestamp/>`_. replacing &amp; with & in the access link.


Private API
+++++++++++

- `Get data from Instagram's private API — Alberto Moral <https://www.albertomoral.com/blog/get-data-from-instagrams-private-api>`_
- `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 <https://github.com/huttarichard/instagram-private-api/issues/42>`_
- `Search · go instagram · GitHub <https://github.com/search?q=go+instagram>`_
  then found `Update timeline API from Get to Post <https://github.com/hieven/go-instagram/commit/6800b3f7b9513fb0084024e405109d939572a961>`_
- `private API reference - github.com/ping/instagram_private_api <https://github.com/ping/instagram_private_api/blob/master/instagram_private_api/endpoints/feed.py>`_

UNLICENSE
+++++++++

Released in public domain. See UNLICENSE_.


References
++++++++++

.. [1] `GitHub - siongui/goiguserid: Get id of Instagram user in Go <https://github.com/siongui/goiguserid>`_
.. [2] `GitHub - siongui/goigstorylink: Get Links (URL) of Instagram Stories in Go <https://github.com/siongui/goigstorylink>`_
.. [3] `GitHub - siongui/goigfollow: Get Instagram following and followers in Go <https://github.com/siongui/goigfollow>`_
.. [4] `GitHub - siongui/goigstorydl: Download Instagram Stories in Go <https://github.com/siongui/goigstorydl>`_
.. [5] `GitHub - siongui/goigmedia: Get links of Instagram user media (photos and videos) in Go. <https://github.com/siongui/goigmedia>`_
.. [6] `JSON Formatter & Validator <https://jsonformatter.curiousconcept.com/>`_

.. _Go: https://golang.org/
.. _Instagram: https://www.instagram.com/
.. _Chrome Developer Tools: https://developer.chrome.com/devtools
.. _SO answer: https://stackoverflow.com/a/44773079
.. _Obtain cookies: https://github.com/hoschiCZ/instastories-backup#obtain-cookies
.. _instastories-backup: https://github.com/hoschiCZ/instastories-backup
.. _EditThisCookie: https://www.google.com/search?q=EditThisCookie
.. _cookie-txt-export: https://github.com/siongui/cookie-txt-export.go
.. _UNLICENSE: http://unlicense.org/
.. _replay.py: https://github.com/ping/instagram_private_api_extensions/blob/master/instagram_private_api_extensions/replay.py
.. _instagram_private_api_extensions: https://github.com/ping/instagram_private_api_extensions
.. _NewInstagramApiManager: https://godoc.org/github.com/siongui/instago#NewInstagramApiManager
.. _issue #2: https://github.com/siongui/instago/issues/2
.. _igdlcrx: https://github.com/siongui/igdlcrx
.. _Downloader for Instagram™ + Direct Message: https://chrome.google.com/webstore/detail/downloader-for-instagram/olkpikmlhoaojbbmmpejnimiglejmboe

Documentation

Overview

Package instago helps you access the private API of Instagram. For examle, get URLs of all posts of a specific Instagram user, media (photos and videos) links of posts, stories of a Instagram user, your following and followers.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIndexToFilename

func AppendIndexToFilename(filename string, index int) string

AppendIndexToFilename appends index to the filename. For example, filename "abcdef.jpg" with index "1" will return "abcdef-1.jpg", and filename "123456.mp4" with index "2" will return "123456-2.mp4". Only used for single post/item with several photos/videos of the same TakenAt time.

func AppendTaggedUsersToFilename

func AppendTaggedUsersToFilename(username, id, filename string, appendIdUsernames []IGTaggedUser) string

func BuildFilename

func BuildFilename(url, username, id, middle, last string, timestamp int64) string

func BuildStoryFilename

func BuildStoryFilename(url, username, id string, timestamp int64) string

func BuildStoryFilename2

func BuildStoryFilename2(url, username, id, timef, times string) string

func CodeToUrl

func CodeToUrl(code string) string

Given the code of the post, return url of the post.

func ExtractPostCodeFromFilename

func ExtractPostCodeFromFilename(filename string) (code string)

func ExtractUsernameIdFromFilename

func ExtractUsernameIdFromFilename(filename string) (username, id string)

func FormatTimestamp

func FormatTimestamp(timestamp int64) string

func GetHTTPResponseNoLogin

func GetHTTPResponseNoLogin(url, method string) (b []byte, err error)

Send HTTP request and get http response without login.

func GetPostFilename

func GetPostFilename(username, id, code, url string, timestamp int64, taggedusers []IGTaggedUser) (filename string)

func GetQueryHashNoLogin

func GetQueryHashNoLogin(b []byte) (qh string, err error)

Given the HTML source code of the user profile page without logged in, return query_hash for Instagram GraphQL API.

func GetRFC3339String

func GetRFC3339String(s string) string

GetRFC3339String returns RFC3339 time string, given the input string.

func GetRecentPostCodeNoLogin

func GetRecentPostCodeNoLogin(username string) (codes []string, err error)

GetRecentPostCodeNoLogin returns codes of recent posts (usually 12 posts) of the given user name without login status.

func GetStoryFilename

func GetStoryFilename(username, id, code, url string, timestamp int64, rms []ItemReelMention) (filename string)

GetStoryFilename is the same as getStoryFilePath, except adding usernames in reel_mentions

func GetUserAgent

func GetUserAgent() string

GetUserAgent returns current User-Agent header in HTTP requests.

func GetUserId

func GetUserId(username string) (id string, err error)

GetUserId returns id of the given user name.

Example
fmt.Println(GetUserId("instagram"))
Output:

25025320 <nil>

func GetUserProfilePicUrlHd

func GetUserProfilePicUrlHd(username string) (url string, err error)

GetUserProfilePicUrlHd returns the URL of profile hd pic of given user name.

Example
fmt.Println(GetUserProfilePicUrlHd("instagram"))
Output:

https://instagram.ftpe1-1.fna.fbcdn.net/v/t51.2885-19/s320x320/59381178_2348911458724961_5863612957363011584_n.jpg?_nc_ht=instagram.ftpe1-1.fna.fbcdn.net&oh=40b5f2e0329d70e72aa8adef38b17291&oe=5E8D1B25 <nil>

func IsWebPostUrl

func IsWebPostUrl(url string) bool

func IsWebRootUrl

func IsWebRootUrl(url string) bool

func IsWebSavedUrl

func IsWebSavedUrl(url string) bool

func IsWebStoryUrl

func IsWebStoryUrl(url string) bool
Example
is1 := IsWebStoryUrl("https://www.instagram.com/stories/highlights/17862445040107085/")
fmt.Println(is1)

is2 := IsWebStoryUrl("https://www.instagram.com/stories/instagram/")
fmt.Println(is2)

is3 := IsWebStoryUrl("https://www.instagram.com/story/instagram/")
fmt.Println(is3)
Output:

true
false
false

func IsWebTaggedUrl

func IsWebTaggedUrl(url string) bool

func IsWebUserUrl

func IsWebUserUrl(url string) bool

func PrintPostItem

func PrintPostItem(pi PostItem) (err error)

func PrintTaggedUsers

func PrintTaggedUsers(tu TaggedUsers)

func SaveRawJsonByte

func SaveRawJsonByte(prefix string, b []byte) (err error)

func SetSaveRawJsonByte

func SetSaveRawJsonByte(b bool)

If set to true, the JSON data returned by API endpoint will be saved. For development purpose. default is false.

func SetUserAgent

func SetUserAgent(s string)

SetUserAgent let you set User-Agent header in HTTP requests.

func StripQueryString

func StripQueryString(inputUrl string) (su string, err error)

StripQueryString removes query string in the URL

Types

type Collection

type Collection struct {
	CollectionId         string `json:"collection_id"`
	CollectionName       string `json:"collection_name"`
	CollectionType       string `json:"collection_type"`
	CollectionMediaCount int64  `json:"collection_media_count"`
}

type IGApiManager

type IGApiManager struct {
	// contains filtered or unexported fields
}

func NewApiManager

func NewApiManager(cookies, headers map[string]string) *IGApiManager

NewApiManager is a more low-level initialization function for API manager. The original goal of this method is used to create API manager used in Chrome extension.

func NewInstagramApiManager

func NewInstagramApiManager(authFilePath string) (*IGApiManager, error)

NewInstagramApiManager returns a API manager of a logged-in Instagram user, given the JSON file of cookies of a Instagram logged-in account.

The cookies, such as *ds_user_id*, *sessionid*, or *csrftoken* can be viewed in Chrome Developer Tools. See https://stackoverflow.com/a/44773079

You can get the JSON format cookies using chrome extension in crx-cookies/ directory.

func (*IGApiManager) GetAllPostCode

func (m *IGApiManager) GetAllPostCode(username string) (codes []string, err error)

Given user name, return codes of all posts of the user with logged in status.

func (*IGApiManager) GetAllPostMedia

func (m *IGApiManager) GetAllPostMedia(username string) (medias []IGMedia, err error)

Given user name, return IGMedia struct of all posts of the user with logged in status.

func (*IGApiManager) GetAllStoryHighlights

func (m *IGApiManager) GetAllStoryHighlights(userid string) (trays []IGStoryHighlightsTray, err error)

Given a user id, return all story highlights of the user.

func (*IGApiManager) GetFollowers

func (m *IGApiManager) GetFollowers(id string) (users []IGFollowUser, err error)

GetFollowers returns all followers of the given user id.

func (*IGApiManager) GetFollowing

func (m *IGApiManager) GetFollowing(id string) (users []IGFollowUser, err error)

GetFollowing returns all following users of the given user id.

func (*IGApiManager) GetGetWebFeedReelsTrayUrl

func (m *IGApiManager) GetGetWebFeedReelsTrayUrl() (url string, err error)

func (*IGApiManager) GetHighlightsReelsMedia

func (m *IGApiManager) GetHighlightsReelsMedia(id string) (tray IGStoryHighlightsTray, err error)

GetHighlightsReelsMedia returns the content of the highlight tray, which contains metadata of story highlights of a specific title.

func (*IGApiManager) GetIdFromWebStoryUrl

func (m *IGApiManager) GetIdFromWebStoryUrl(url string) (id string, err error)

func (*IGApiManager) GetInfoFromWebStoryUrl

func (m *IGApiManager) GetInfoFromWebStoryUrl(url string) (user WebStoryInfo, err error)

func (*IGApiManager) GetMediaInfo

func (m *IGApiManager) GetMediaInfo(id string) (item IGItem, err error)

GetMediaInfo returns information of post via API endpoint.

func (*IGApiManager) GetMultipleReelsMedia

func (m *IGApiManager) GetMultipleReelsMedia(userids []string) (trays []IGReelsMediaTray, err error)

func (*IGApiManager) GetPostInfo

func (m *IGApiManager) GetPostInfo(code string) (em IGMedia, err error)

Given code of post, return information of the post with login status.

func (*IGApiManager) GetRecentPostCode

func (m *IGApiManager) GetRecentPostCode(username string) (codes []string, err error)

GetRecentPostCode returns codes of recent posts (usually 12 posts) of the given user name with logged in status.

func (*IGApiManager) GetRecentPostMedia

func (m *IGApiManager) GetRecentPostMedia(username string) (medias []IGMedia, err error)

GetRecentPostMedia returns IGMedia struct of recent posts (usually 12 posts) of the given user name with logged in status.

func (*IGApiManager) GetReelsTray

func (m *IGApiManager) GetReelsTray() (r IGReelsTray, err error)

func (*IGApiManager) GetSavedCollection

func (m *IGApiManager) GetSavedCollection(id string) (items []IGItem, err error)

GetSavedCollection returns your saved collections.

func (*IGApiManager) GetSavedCollectionList

func (m *IGApiManager) GetSavedCollectionList() (c []Collection, err error)

GetSavedCollectionList returns your list of saved collections.

func (*IGApiManager) GetSavedPosts

func (m *IGApiManager) GetSavedPosts(numOfItem int) (items []IGItem, err error)

GetSavedPosts returns your saved posts. Pass -1 will get all saved posts.

func (*IGApiManager) GetSelfId

func (m *IGApiManager) GetSelfId() string

GetSelfId returns the id of a Instagram user of the API manager.

func (*IGApiManager) GetTimeline

func (m *IGApiManager) GetTimeline() (tl IGTimeline, err error)

Get only one page of timeline

func (*IGApiManager) GetTimelineUntilPageN

func (m *IGApiManager) GetTimelineUntilPageN(pageN int) (items []IGItem, err error)

Get N pages of timeline

func (*IGApiManager) GetUserInfo

func (m *IGApiManager) GetUserInfo(username string) (ui UserInfo, err error)

GetUserInfo returns information of the given user name with logged in status.

func (*IGApiManager) GetUserInfoEndPoint

func (m *IGApiManager) GetUserInfoEndPoint(userid string) (user UserInfoEndPoint, err error)

FIXME: do not return IGUser

func (*IGApiManager) GetUserReelMedia

func (m *IGApiManager) GetUserReelMedia(id string) (tray IGReelTray, err error)

GetUserReelMedia returns unexpired stories of the given user id. No postlives included.

func (*IGApiManager) GetUserStory

func (m *IGApiManager) GetUserStory(userid string) (ut UserTray, err error)

func (*IGApiManager) GetUserStoryByWebGraphql

func (m *IGApiManager) GetUserStoryByWebGraphql(id, storyQueryHash string) (rm IGReelMedia, err error)

func (*IGApiManager) GetUserStoryHighlights

func (m *IGApiManager) GetUserStoryHighlights(id string) (trays []IGStoryHighlightsTray, err error)

Return story highlight trays of a specific user. Sometimes items in a highlight tray are empty. Call *IGApiManager.GetHighlightsReelsMedia to get items of the tray. See *IGApiManager.GetAllStoryHighlights

func (*IGApiManager) GetWebFeedReelsTray

func (m *IGApiManager) GetWebFeedReelsTray(url string) (rms []IGReelMedia, err error)

func (*IGApiManager) GetWebGraphqlStoriesJson

func (m *IGApiManager) GetWebGraphqlStoriesJson(reelIds []string, storyQueryHash string) (b []byte, err error)

func (*IGApiManager) GetWebQueryHash

func (m *IGApiManager) GetWebQueryHash() (story, unknown1, unknown2 string, err error)

func (*IGApiManager) Toplive

func (m *IGApiManager) Toplive() (tr IGTopliveResp, err error)

Given a string, return the users that best matches the string. This is actually *topsearch* on Instagram web.

func (*IGApiManager) Topsearch

func (m *IGApiManager) Topsearch(str string) (tr IGTopsearchResp, err error)

Given a string, return the users that best matches the string. This is actually *topsearch* on Instagram web.

type IGBroadcast

type IGBroadcast struct {
	Id                            int64    `json:"id"`
	DashPlaybackUrl               string   `json:"dash_playback_url"`
	DashAbrPlaybackUrl            string   `json:"dash_abr_playback_url"`
	DashLivePredictivePlaybackUrl string   `json:"dash_live_predictive_playback_url"`
	BroadcastStatus               string   `json:"broadcast_status"`
	ViewerCount                   float64  `json:"viewer_count"`
	InternalOnly                  bool     `json:"internal_only"`
	Muted                         bool     `json:"muted"`
	RankedPosition                float64  `json:"ranked_position"`
	SeenRankedPosition            float64  `json:"seen_ranked_position"`
	DashManifest                  string   `json:"dash_manifest"`
	ExpireAt                      int64    `json:"expire_at"`
	EncodingTag                   string   `json:"encoding_tag"`
	NumberOfQualities             int64    `json:"number_of_qualities"`
	CoverFrameUrl                 string   `json:"cover_frame_url"`
	Cobroadcasters                []IGUser `json:"cobroadcasters"`
	IsPlayerLiveTraceEnabled      float64  `json:"is_player_live_trace_enabled"`
	IsGamingContent               bool     `json:"is_gaming_content"`
	BroadcastOwner                IGUser   `json:"broadcast_owner"`
	PublishedTime                 int64    `json:"published_time"`
	HideFromFeedUnit              bool     `json:"hide_from_feed_unit"`
	VideoDuration                 float64  `json:"video_duration"`
	MediaId                       string   `json:"media_id"`
	BroadcastMessage              string   `json:"broadcast_message"`
	OrganicTrackingToken          string   `json:"organic_tracking_token"`
}

func (*IGBroadcast) GetBaseUrls

func (b *IGBroadcast) GetBaseUrls() (urls []string, err error)

func (*IGBroadcast) GetDashManifest

func (b *IGBroadcast) GetDashManifest() string

func (*IGBroadcast) GetPublishedTime

func (b *IGBroadcast) GetPublishedTime() int64

type IGFollowUser

type IGFollowUser struct {
	Pk                         int64  `json:"pk"` // Pk is user id
	Username                   string `json:"username"`
	FullName                   string `json:"full_name"`
	IsPrivate                  bool   `json:"is_private"`
	ProfilePicUrl              string `json:"profile_pic_url"`
	ProfilePicId               string `json:"profile_pic_id"`
	IsVerified                 bool   `json:"is_verified"`
	HasAnonymousProfilePicture bool   `json:"has_anonymous_profile_picture"`
	//account_badges
	LatestReelMedia int64 `json:"latest_reel_media"`
	//story_reel_media_ids
	IsFavorite bool `json:"is_favorite"`
}

func (IGFollowUser) GetUserId

func (u IGFollowUser) GetUserId() string

func (IGFollowUser) GetUsername

func (u IGFollowUser) GetUsername() string

func (IGFollowUser) IsPublic

func (u IGFollowUser) IsPublic() bool

type IGItem

type IGItem struct {
	TakenAt         int64  `json:"taken_at"`
	Pk              int64  `json:"pk"`
	Id              string `json:"id"`
	DeviceTimestamp int64  `json:"device_timestamp"` // not reliable value
	MediaType       int64  `json:"media_type"`
	Code            string `json:"code"`
	ClientCacheKey  string `json:"client_cache_key"`
	FilterType      int64  `json:"filter_type"`

	// timeline and saved posts
	CarouselMedia []struct {
		Id                    string             `json:"id"`
		MediaType             int64              `json:"media_type"`
		ImageVersions2        ItemImageVersion2  `json:"image_versions2"`
		OriginalWidth         int64              `json:"original_width"`
		OriginalHeight        int64              `json:"original_height"`
		VideoVersions         []ItemVideoVersion `json:"video_versions"`
		Pk                    int64              `json:"pk"`
		CarouselParentId      string             `json:"carousel_parent_id"`
		CanSeeInsightsAsBrand bool               `json:"can_see_insights_as_brand"`
		Usertags              ItemUsertags       `json:"usertags"`
	} `json:"carousel_media"`

	// timeline only?
	Location struct {
		Pk               int64   `json:"pk"`
		Name             string  `json:"name"`
		Address          string  `json:"address"`
		City             string  `json:"city"`
		ShortName        string  `json:"short_name"`
		Lng              float64 `json:"lng"`
		Lat              float64 `json:"lat"`
		ExternalSource   string  `json:"external_source"`
		FacebookPlacesId int64   `json:"facebook_places_id"`
	} `json:"location"`

	// timeline only (You're All Caught Up)
	EndOfFeedDemarcator struct {
		Id       int64  `json:"id"`
		Title    string `json:"title"`
		SubTitle string `json"subtitle"`
	} `json:"end_of_feed_demarcator"`

	// timeline only (ads in timeline)
	Injected struct {
		Label   string `json:"label"`
		AdTitle string `json:"ad_title"`
	} `json:"injected"`

	// timeline only (suggested_user, "type": 2)
	Type             int64            `json:"type"`
	Suggestions      []ItemSuggestion `json:"suggestions"`
	RankingAlgorithm string           `json:"ranking_algorithm"`

	ImageVersions2  ItemImageVersion2 `json:"image_versions2"`
	OriginalWidth   int64             `json:"original_width"`
	OriginalHeight  int64             `json:"original_height"`
	CaptionPosition float64           `json:"caption_position"`
	IsReelMedia     bool              `json:"is_reel_media"`

	VideoVersions []ItemVideoVersion `json:"video_versions"`
	HasAudio      bool               `json:"has_audio"`
	VideoDuration float64            `json:"video_duration"`

	User IGUser `json:"user"`

	CaptionIsEdited      bool   `json:"caption_is_edited"`
	PhotoOfYou           bool   `json:"photo_of_you"`
	CanViewerSave        bool   `json:"can_viewer_save"`
	OrganicTrackingToken string `json:"organic_tracking_token"`
	ExpiringAt           int64  `json:"expiring_at"`

	IsDashEligible int64 `json:"is_dash_eligible"`

	ReelMentions []ItemReelMention `json:"reel_mentions"`

	// for items of saved posts
	SavedCollectionIds []string     `json:"saved_collection_ids"`
	Usertags           ItemUsertags `json:"usertags"`

	Audience              string `json:"audience"`
	CanReshare            bool   `json:"can_reshare"`
	CanReply              bool   `json:"can_reply"`
	SupportsReelReactions bool   `json:"supports_reel_reactions"`
}

func (*IGItem) GetMediaUrls

func (i *IGItem) GetMediaUrls() (urls []string, err error)

Return best resolution photo/video URL(s) in item

func (*IGItem) GetPostCode

func (i *IGItem) GetPostCode() string

func (*IGItem) GetPostUrl

func (i *IGItem) GetPostUrl() string

func (*IGItem) GetSelfType

func (i *IGItem) GetSelfType() string

Return self type name

func (*IGItem) GetTimestamp

func (i *IGItem) GetTimestamp() int64

func (*IGItem) GetUserId

func (i *IGItem) GetUserId() string

func (*IGItem) GetUsername

func (i *IGItem) GetUsername() string

func (*IGItem) IsRegularMedia

func (i *IGItem) IsRegularMedia() bool

media type:

0: ???
1: single photo
2: single video
8: multiple photos/videos

type IGMedia

type IGMedia struct {
	Typename   string `json:"__typename"`
	Id         string `json:"id"`
	Shortcode  string `json:"shortcode"`
	Dimensions struct {
		Height int64 `json:"height"`
		Width  int64 `json:"width"`
	} `json:"dimensions"`

	MediaPreview     string `json:"media_preview"`
	DisplayUrl       string `json:"display_url"`
	DisplayResources []struct {
		Src          string `json:"src"`
		ConfigWidth  int64  `json:"config_width"`
		ConfigHeight int64  `json:"config_height"`
	} `json:"display_resources"`

	DashInfo struct {
		IsDashEligible bool `json:"is_dash_eligible"`
		//"video_dash_manifest"
		NumberOfQualities int64 `json:"number_of_qualities"`
	} `json:"dash_info"`

	VideoUrl       string `json:"video_url"`
	VideoViewCount int64  `json:"video_view_count"`
	IsVideo        bool   `json:"is_video"`

	ShouldLogClientEvent bool   `json:"should_log_client_event"`
	TrackingToken        string `json:"tracking_token"`

	EdgeMediaToTaggedUser MediaUsertags `json:"edge_media_to_tagged_user"`

	EdgeMediaToCaption struct {
		Edges []struct {
			Node struct {
				Text string `json:"text"`
			} `json:"node"`
		} `json:"edges"`
	} `json:"edge_media_to_caption"`
	CaptionIsEdited bool `json:"caption_is_edited"`

	EdgeMediaToComment struct {
		Count    int64 `json:"count"`
		PageInfo struct {
			HasNextPage bool   `json:"has_next_page"`
			EndCursor   string `json:"end_cursor"`
		} `json:"page_info"`
		Edges []struct {
			Node struct {
				Id        string `json:"id"`
				Text      string `json:"text"`
				CreatedAt int64  `json:"created_at"`
				Owner     struct {
					Id            string `json:"id"`
					ProfilePicUrl string `json:"profile_pic_url"`
					Username      string `json:"username"`
				} `json:"owner"`
			} `json:"node"`
		} `json:"edges"`
	} `json:"edge_media_to_comment"`
	CommentsDisabled bool `json:"comments_disabled"`

	TakenAtTimestamp int64 `json:"taken_at_timestamp"`

	EdgeMediaPreviewLike struct {
		Count int64 `json:"count"`
		Edges []struct {
			Node struct {
				Id            string `json:"id"`
				ProfilePicUrl string `json:"profile_pic_url"`
				Username      string `json:"username"`
			} `json:"node"`
		} `json:"edges"`
	} `json:"edge_media_preview_like"`

	Location struct {
		Id            string `json:"id"`
		HasPublicPage bool   `json:"has_public_page"`
		Name          string `json:"name"`
		Slug          string `json:"slug"`
	} `json:"location"`

	ViewerHasLiked             bool `json:"viewer_has_liked"`
	ViewerHasSaved             bool `json:"viewer_has_saved"`
	ViewerHasSavedToCollection bool `json:"viewer_has_saved_to_collection"`

	Owner struct {
		Id                string `json:"id"`
		ProfilePicUrl     string `json:"profile_pic_url"`
		Username          string `json:"username"`
		BlockedByViewer   bool   `json:"blocked_by_viewer"`
		FollowedByViewer  bool   `json:"followed_by_viewer"`
		FullName          string `json:"full_name"`
		HasBlockedViewer  bool   `json:"has_blocked_viewer"`
		IsPrivate         bool   `json:"is_private"`
		IsUnpublished     bool   `json:"is_unpublished"`
		IsVerified        bool   `json:"is_verified"`
		RequestedByViewer bool   `json:"requested_by_viewer"`
	} `json:"owner"`

	IsAd bool `json:"is_ad"`

	EdgeSidecarToChildren struct {
		Edges []struct {
			Node IGMedia `json:"node"`
		} `json:"edges"`
	} `json:"edge_sidecar_to_children"`
}

Main data structure returned by https://www.instagram.com/p/{{CODE}}/?__a=1

func GetAllPostMediaNoLogin

func GetAllPostMediaNoLogin(username string) (medias []IGMedia, err error)

Given user name, return IGMedia struct of all posts of the user without login status. The user account must be public.

func GetPostInfoNoLogin

func GetPostInfoNoLogin(code string) (em IGMedia, err error)

Given code of post, return information of the post without login status.

func GetRecentPostMediaNoLogin

func GetRecentPostMediaNoLogin(username string) (medias []IGMedia, err error)

GetRecentPostMediaNoLogin returns IGMedia struct of recent posts (usually 12 posts if not private) of the given user name without login status.

func (*IGMedia) GetMediaUrls

func (em *IGMedia) GetMediaUrls() (urls []string, err error)

Get URLs of media (photos/videos) in the post

func (*IGMedia) GetPostCode

func (em *IGMedia) GetPostCode() string

Return code of post

func (*IGMedia) GetPostUrl

func (em *IGMedia) GetPostUrl() string

Get URL of the post

func (*IGMedia) GetSelfType

func (em *IGMedia) GetSelfType() string

Return self type name

func (*IGMedia) GetTimestamp

func (em *IGMedia) GetTimestamp() int64

Get timestamp of the post

func (*IGMedia) GetUserId

func (em *IGMedia) GetUserId() string

Get id of the post owner

func (*IGMedia) GetUsername

func (em *IGMedia) GetUsername() string

Get username of the post owner

type IGPostLive

type IGPostLive struct {
	PostLiveItems []IGPostLiveItem `json:"post_live_items"`
}

Live videos that users share to their stories

type IGPostLiveItem

type IGPostLiveItem struct {
	Pk                  string        `json:"pk"`
	User                IGUser        `json:"user"`
	Broadcasts          []IGBroadcast `json:"broadcasts"`
	LastSeenBroadcastTs float64       `json:"last_seen_broadcast_ts"`
	RankedPosition      int64         `json:"ranked_position"`
	SeenRankedPosition  int64         `json:"seen_ranked_position"`
	Muted               bool          `json:"muted"`
	CanReply            bool          `json:"can_reply"`
	CanReshare          bool          `json:"can_reshare"`
}

func (*IGPostLiveItem) GetBroadcasts

func (i *IGPostLiveItem) GetBroadcasts() []IGBroadcast

func (*IGPostLiveItem) GetUserId

func (i *IGPostLiveItem) GetUserId() string

func (*IGPostLiveItem) GetUsername

func (i *IGPostLiveItem) GetUsername() string

type IGReelMedia

type IGReelMedia struct {
	Typename        string            `json:"__typename"`
	Id              string            `json:"id"`
	LatestReelMedia int64             `json:"latest_reel_media"`
	CanReply        bool              `json:"can_reply"`
	Owner           IGReelMediaUser   `json:"owner"`
	CanReshare      bool              `json:"can_reshare"`
	ExpiringAt      int64             `json:"expiring_at"`
	HasBestiesMedia bool              `json:"has_besties_media"`
	HasPrideMedia   bool              `json:"has_pride_media"`
	Seen            int64             `json:"seen"`
	User            IGReelMediaUser   `json:"user"`
	Items           []IGReelMediaItem `json:"items"`
}

IGReelMedia represent story info of a user. web version of type IGReelTray This struct is returned from web GraphQL query.

type IGReelMediaItem

type IGReelMediaItem struct {
	Audience              string `json:"audience"`
	EdgeStoryMediaViewers struct {
		Count    int64 `json:"count"`
		PageInfo struct {
			HasNextPage bool `json:"has_next_page"`
		} `json:"page_info"`
	} `json:"edge_story_media_viewers"`
	Typename   string `json:"__typename"`
	Id         string `json:"id"`
	Dimensions struct {
		Height int64 `json:"height"`
		Width  int64 `json:"width"`
	} `json:"dimensions"`
	DisplayResources []struct {
		Src          string `json:"src"`
		ConfigWidth  int64  `json:"config_width"`
		ConfigHeight int64  `json:"config_height"`
	} `json:"display_resources"`
	DisplayUrl   string `json:"display_url"`
	MediaPreview string `json:"media_preview"`
	//gating_info
	//fact_check_overall_rating
	//fact_check_information
	//media_overlay_info
	//sensitivity_friction_info
	TakenAtTimestamp    int64 `json:"taken_at_timestamp"`
	ExpiringAtTimestamp int64 `json:"expiring_at_timestamp"`
	//story_cta_url
	//story_view_count
	IsVideo       bool            `json:"is_video"`
	Owner         IGReelMediaUser `json:"owner"`
	TrackingToken string          `json:"tracking_token"`

	HasAudio bool `json:"has_audio"`
	//overlay_image_resources
	VideoDuration  float64 `json:"video_duration"`
	VideoResources []struct {
		Src          string `json:"src"`
		ConfigWidth  int64  `json:"config_width"`
		ConfigHeight int64  `json:"config_height"`
		MimeType     string `json:"mime_type"`
		Profile      string `json:"profile"`
	} `json:"video_resources"`

	TappableObjects []struct {
		Typename string  `json:"__typename"`
		X        float64 `json:"x"`
		Y        float64 `json:"y"`
		Width    float64 `json:"width"`
		Height   float64 `json:"height"`
		Rotation float64 `json:"rotation"`
		//custom_title
		//attribution
		TappableType string `json:"tappable_type"`
		Username     string `json:"username"`
		FullName     string `json:"full_name"`
		IsPrivate    bool   `json:"is_private"`
	} `json:"tappable_objects"`
}

func (IGReelMediaItem) GetMediaUrl

func (i IGReelMediaItem) GetMediaUrl() string

func (IGReelMediaItem) GetStoryImageUrl

func (i IGReelMediaItem) GetStoryImageUrl() string

func (IGReelMediaItem) GetStoryVideoUrl

func (i IGReelMediaItem) GetStoryVideoUrl() string

func (IGReelMediaItem) GetTimestamp

func (i IGReelMediaItem) GetTimestamp() int64

func (IGReelMediaItem) GetUserId

func (i IGReelMediaItem) GetUserId() string

func (IGReelMediaItem) GetUsername

func (i IGReelMediaItem) GetUsername() string

type IGReelMediaUser

type IGReelMediaUser struct {
	Typename          string `json:"__typename"`
	Id                string `json:"id"`
	ProfilePicUrl     string `json:"profile_pic_url"`
	Username          string `json:"username"`
	FollowedByViewer  bool   `json:"followed_by_viewer"`
	RequestedByViewer bool   `json:"requested_by_viewer"`
}

type IGReelTray

type IGReelTray struct {
	Id                 int64   `json:"id"`
	LatestReelMedia    int64   `json:"latest_reel_media"`
	ExpiringAt         float64 `json:"expiring_at"`
	Seen               float64 `json:"seen"`
	CanReply           bool    `json:"can_reply"`
	CanReshare         bool    `json:"can_reshare"`
	ReelType           string  `json:"reel_type"`
	User               IGUser  `json:"user"`
	RankedPosition     int64   `json:"ranked_position"`
	SeenRankedPosition int64   `json:"seen_ranked_position"`
	Muted              bool    `json:"muted"`
	PrefetchCount      int64   `json:"prefetch_count"`

	// close friend
	HasBestiesMedia bool `json:"has_besties_media"`

	Items []IGItem `json:"items"`
}

func (*IGReelTray) GetItems

func (t *IGReelTray) GetItems() []IGItem

func (*IGReelTray) GetUsername

func (t *IGReelTray) GetUsername() string

type IGReelsMediaTray

type IGReelsMediaTray struct {
	Id              int64   `json:"id"`
	LatestReelMedia int64   `json:"latest_reel_media"`
	Seen            float64 `json:"seen"`
	CanReply        bool    `json:"can_reply"`
	CanReshare      bool    `json:"can_reshare"`
	ReelType        string  `json:"reel_type"`

	CoverMedia struct {
		CroppedImageVersion struct {
			Width  int64  `json:"width"`
			Height int64  `json:"height"`
			Url    string `json:"url"`
		} `json:"cropped_image_version"`
		MediaId  string    `json:"media_id"`
		CropRect []float64 `json:"crop_rect"`
	} `json:"cover_media"`

	User  IGUser   `json:"user"`
	Items []IGItem `json:"items"`

	RankedPosition     int64  `json:"ranked_position"`
	Title              string `json:"title"`
	SeenRankedPosition int64  `json:"seen_ranked_position"`
	PrefetchCount      int64  `json:"prefetch_count"`
}

Used to decode JSON returned by Instagram story API.

type IGReelsTray

type IGReelsTray struct {
	Trays             []IGReelTray  `json:"tray"`
	Broadcasts        []IGBroadcast `json:"broadcasts"`
	PostLive          IGPostLive    `json:"post_live"`
	StoryRankingToken string        `json:"story_ranking_token"`

	StickerVersion       int64  `json:"sticker_version"`
	FaceFilterNuxVersion int64  `json:"face_filter_nux_version"`
	HasNewNuxStory       bool   `json:"has_new_nux_story"`
	Status               string `json:"status"`
}

Used to decode JSON returned by Instagram reels tray feed API.

type IGStoryHighlightsTray

type IGStoryHighlightsTray struct {
	Id              string  `json:"id"`
	LatestReelMedia int64   `json:"latest_reel_media"`
	Seen            float64 `json:"seen"`
	CanReply        bool    `json:"can_reply"`
	CanReshare      bool    `json:"can_reshare"`
	ReelType        string  `json:"reel_type"`

	CoverMedia struct {
		CroppedImageVersion struct {
			Width  int64  `json:"width"`
			Height int64  `json:"height"`
			Url    string `json:"url"`
		} `json:"cropped_image_version"`
		MediaId  string    `json:"media_id"`
		CropRect []float64 `json:"crop_rect"`
	} `json:"cover_media"`

	User  IGUser   `json:"user"`
	Items []IGItem `json:"items"`

	RankedPosition     int64  `json:"ranked_position"`
	Title              string `json:"title"`
	SeenRankedPosition int64  `json:"seen_ranked_position"`
	PrefetchCount      int64  `json:"prefetch_count"`
}

Used to decode JSON returned by Instagram story API.

func (*IGStoryHighlightsTray) GetItems

func (t *IGStoryHighlightsTray) GetItems() []IGItem

func (*IGStoryHighlightsTray) GetTitle

func (t *IGStoryHighlightsTray) GetTitle() string

func (*IGStoryHighlightsTray) GetUsername

func (t *IGStoryHighlightsTray) GetUsername() string

type IGTaggedUser

type IGTaggedUser struct {
	Username string
	Id       string
}

type IGTimeline

type IGTimeline struct {
	Items               []IGItem `json:"items"`
	NumResults          int64    `json:"num_results"`
	MoreAvailable       bool     `json:"more_available"`
	AutoLoadMoreEnabled bool     `json:"auto_load_more_enabled"`
	IsDirectV2Enabled   bool     `json:"is_direct_v2_enabled"`
	NextMaxId           string   `json:"next_max_id"`
	Status              string   `json:"status"`
}

type IGTopliveResp

type IGTopliveResp struct {
	Broadcasts []struct {
		Id                   int64   `json:"id"`
		RtmpPlaybackUrl      string  `json:"rtmp_playback_url"`
		DashPlaybackUrl      string  `json:"dash_playback_url"`
		DashAbrPlaybackUrl   string  `json:"dash_abr_playback_url"`
		BroadcastStatus      string  `json:"broadcast_status"`
		ViewerCount          float64 `json:"viewer_count"`
		InternalOnly         bool    `json:"internal_only"`
		CoverFrameUrl        string  `json:"cover_frame_url"`
		BroadcastOwner       IGUser  `json:"broadcast_owner"`
		PublishedTime        int64   `json:"published_time"`
		MediaId              string  `json:"media_id"`
		BroadcastMessage     string  `json:"broadcast_message"`
		OrganicTrackingToken string  `json:"organic_tracking_token"`
	} `json:"broadcasts"`
	MoreAvailable       bool   `json:"more_available"`
	AutoLoadMoreEnabled bool   `json:"auto_load_more_enabled"`
	NextMaxId           int64  `json:"next_max_id"`
	Status              string `json:"status"`
}

Decode JSON data returned from Instagram top live API

type IGTopsearchResp

type IGTopsearchResp struct {
	Users []struct {
		Position int64 `json:"position"`
		// json: cannot unmarshal string into Go struct field IGUser.users.user.pk of type int64
		User struct {
			Pk                         string `json:"pk"`
			Username                   string `json:"username"`
			FullName                   string `json:"full_name"`
			IsPrivate                  bool   `json:"is_private"`
			ProfilePicUrl              string `json:"profile_pic_url"`
			ProfilePicId               string `json:"profile_pic_id"`
			IsVerified                 bool   `json:"is_verified"`
			HasAnonymousProfilePicture bool   `json:"has_anonymous_profile_picture"`
			MutualFollowersCount       int64  `json:"mutual_followers_count"`
			//account_badges
			SocialContext       string `json:"social_context"`
			SearchSocialContext string `json:"search_social_context"`
			UnseenCount         int64  `json:"unseen_count"`
			FriendshipStatus    struct {
				Following       bool `json:"following"`
				IsPrivate       bool `json:"is_private"`
				IncomingRequest bool `json:"incoming_request"`
				OutgoingRequest bool `json:"outgoing_request"`
				IsBestie        bool `json:"is_bestie"`
				IsRestricted    bool `json:"is_restricted"`
			} `json:"friendship_status"`
			LatestReelMedia int64 `json:"latest_reel_media"`
			Seen            int64 `json:"seen"`
		} `json:"user"`
	} `json:"users"`

	Places []struct {
		Position int64 `json:"position"`
		Place    struct {
			Location struct {
				Pk               string  `json:"pk"`
				Name             string  `json:"name"`
				Address          string  `json:"address"`
				City             string  `json:"city"`
				ShortName        string  `json:"short_name"`
				Lng              float64 `json:"lng"`
				Lat              float64 `json:"lat"`
				ExternalSource   string  `json:"external_source"`
				FacebookPlacesId int64   `json:"facebook_places_id"`
			} `json:"location"`
			Title    string `json:"title"`
			Subtitle string `json:"subtitle"`
			//media_bundles
			Slug string `json:"slug"`
		} `json:"place"`
	} `json:"places"`

	Hashtags []struct {
		Position int64 `json:"position"`
		Hashtag  struct {
			Name                 string `json:"name"`
			Id                   int64  `json:"id"`
			MediaCount           int64  `json:"media_count"`
			UseDefaultAvatar     bool   `json:"use_default_avatar"`
			SearchResultSubtitle string `json:"search_result_subtitle"`
		} `json:"hashtag"`
	} `json:"hashtags"`
	HasMore          bool   `json:"has_more"`
	RankToken        string `json:"rank_token"`
	ClearClientCache bool   `json:"clear_client_cache"`
	Status           string `json:"status"`
}

Decode JSON data returned from Instagram topsearch API

type IGUser

type IGUser struct {
	Pk               int64  `json:"pk"`
	Username         string `json:"username"`
	FullName         string `json:"full_name"`
	IsPrivate        bool   `json:"is_private"`
	IsVerified       bool   `json:"is_verified"`
	ProfilePicUrl    string `json:"profile_pic_url"`
	ProfilePicId     string `json:"profile_pic_id"`
	FriendshipStatus struct {
		Following       bool `json:"following"`
		FollowedBy      bool `json:"followed_by"`
		Blocking        bool `json:"blocking"`
		IsPrivate       bool `json:"is_private"`
		IncomingRequest bool `json:"incoming_request"`
		OutgoingRequest bool `json:"outgoing_request"`
		IsBestie        bool `json:"is_bestie"`
		IsRestricted    bool `json:"is_restricted"`
	} `json:"friendship_status"`
	HasAnonymousProfilePicture bool `json:"has_anonymous_profile_picture"`
	IsUnpublished              bool `json:"is_unpublished"`
	IsFavorite                 bool `json:"is_favorite"`

	// used in topsearch
	FollowerCount        int64   `json:"follower_count"`
	Byline               string  `json:"byline"`
	MutualFollowersCount float64 `json:"mutual_followers_count"`
	LatestReelMedia      int64   `json:"latest_reel_media"`
}

func (IGUser) GetUserId

func (u IGUser) GetUserId() string

func (IGUser) GetUsername

func (u IGUser) GetUsername() string

func (IGUser) IsPublic

func (u IGUser) IsPublic() bool

type ItemImageVersion2

type ItemImageVersion2 struct {
	Candidates []struct {
		Width  int64  `json:"width"`
		Height int64  `json:"height"`
		Url    string `json:"url"`
	} `json:"candidates"`
}

Used to decode JSON in item.

type ItemReelMention

type ItemReelMention struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	Z float64 `json:"z"`

	Width    float64 `json:"width"`
	Height   float64 `json:"height"`
	Rotation float64 `json:"rotation"`

	IsPinned float64 `json:"is_pinned"`
	IsHidden float64 `json:"is_hidden"`

	DisplayType string `json:"display_type"`

	IsSticker   float64 `json:"is_sticker"`
	IsFbSticker float64 `json:"is_fb_sticker"`

	User IGUser
}

users mentioned in items (stories, etc.)

func (ItemReelMention) GetUserId

func (i ItemReelMention) GetUserId() string

func (ItemReelMention) GetUsername

func (i ItemReelMention) GetUsername() string

func (ItemReelMention) IsPublic

func (i ItemReelMention) IsPublic() bool

type ItemSuggestion

type ItemSuggestion struct {
	//Cannot use IGUser because
	//json: cannot unmarshal string into Go struct field IGUser.items.suggestions.user.pk of type int64
	//User          IGUser `json:"user"`
	User struct {
		Pk       string `json:"pk"`
		Username string `json:"username"`
		FullName string `json:"full_name"`
	} `json:"user"`

	Algorithm     string `json:"algorithm"`
	SocialContext string `json:"social_context"`
}

suggested_user in items of timeline

type ItemUsertags

type ItemUsertags struct {
	In []struct {
		User     IGUser `json:"user"`
		Position []float64
	} `json:"in"`
}

user tags in items

func (ItemUsertags) GetIdUsernamePairs

func (i ItemUsertags) GetIdUsernamePairs() (pairs []IGTaggedUser)

func (ItemUsertags) GetTaggedUsernames

func (i ItemUsertags) GetTaggedUsernames() (usernames []string)

type ItemVideoVersion

type ItemVideoVersion struct {
	Type   int64  `json:"type"`
	Width  int64  `json:"width"`
	Height int64  `json:"height"`
	Url    string `json:"url"`
	Id     string `json:"id"`
}

Used to decode JSON in item.

type MediaUsertags

type MediaUsertags struct {
	Edges []struct {
		Node struct {
			User struct {
				FullName      string `json:"full_name"`
				Id            string `json:"id"`
				IsVerified    bool   `json:"is_verified"`
				ProfilePicUrl string `json:"profile_pic_url"`
				Username      string `json:"username"`
			} `json:"user"`
			X float64 `json:"x"`
			Y float64 `json:"y"`
		} `json:"node"`
	} `json:"edges"`
}

tagged users in post

func (MediaUsertags) GetIdUsernamePairs

func (m MediaUsertags) GetIdUsernamePairs() (pairs []IGTaggedUser)

func (MediaUsertags) GetTaggedUsernames

func (m MediaUsertags) GetTaggedUsernames() (usernames []string)

type PostItem

type PostItem interface {
	GetSelfType() string
	GetUsername() string
	GetUserId() string
	GetPostUrl() string
	GetPostCode() string
	GetTimestamp() int64
	GetMediaUrls() ([]string, error)
}

Common methods of IG posts for IGMedia and IGItem

type ReelsMedia

type ReelsMedia struct {
	Reels  map[string]IGReelsMediaTray `json:"reels"`
	Status string                      `json:"status"`
}

type SharedData

type SharedData struct {
	EntryData struct {
		ProfilePage []struct {
			GraphQL struct {
				User UserInfo `json:"user"`
			} `json:"graphql"`
		} `json:"ProfilePage"`
	} `json:"entry_data"`

	RhxGis string `json:"rhx_gis"`
}

used to decode the JSON data https://www.instagram.com/{{USERNAME}}/

func GetSharedDataNoLogin

func GetSharedDataNoLogin(username string) (sd SharedData, err error)

GetSharedDataNoLogin returns sharedData embedded in the HTML source code of the profile page of given user name.

func GetSharedDataQueryHashNoLogin

func GetSharedDataQueryHashNoLogin(username string) (sd SharedData, qh string, err error)

Given username, get:

  1. sharedData embedded in the HTML of user profile page.
  2. query_hash (for get all codes of posts without login)
Example
sd, qh, err := GetSharedDataQueryHashNoLogin("instagram")
if err != nil {
	fmt.Println(err)
	return
}

fmt.Println(sd.EntryData.ProfilePage[0].GraphQL.User.Id)
fmt.Println(qh)
Output:

25025320
e769aa130647d2354c40ea6a439bfc08

type TaggedUsers

type TaggedUsers interface {
	GetTaggedUsernames() []string
	GetIdUsernamePairs() []IGTaggedUser
}

type User

type User interface {
	GetUserId() string
	GetUsername() string
	IsPublic() bool
}

type UserInfo

type UserInfo struct {
	Biography              string `json:"biography"`
	BlockedByViewer        bool   `json:"blocked_by_viewer"`
	CountryBlock           bool   `json:"country_block"`
	ExternalUrl            string `json:"external_url"`
	ExternalUrlLinkshimmed string `json:"external_url_linkshimmed"`
	EdgeFollowedBy         struct {
		Count int64 `json:"count"`
	} `json:"edge_followed_by"`
	FollowedByViewer bool `json:"followed_by_viewer"`
	EdgeFollow       struct {
		Count int64 `json:"count"`
	} `json:"edge_followe"`
	FollowsViewer      bool   `json:"follows_viewer"`
	FullName           string `json:"full_name"`
	HasBlockedViewer   bool   `json:"has_blocked_viewer"`
	HasRequestedViewer bool   `json:"has_requested_viewer"`
	Id                 string `json:"id"`
	IsPrivate          bool   `json:"is_private"`
	IsVerified         bool   `json:"is_verified"`
	MutualFollowers    struct {
		AdditionalCount int64    `json:"additional_count"`
		Usernames       []string `json:"usernames"`
	} `json:"mutual_followers"`
	ProfilePicUrl            string `json:"profile_pic_url"`
	ProfilePicUrlHd          string `json:"profile_pic_url_hd"`
	RequestedByViewer        bool   `json:"requested_by_viewer"`
	Username                 string `json:"username"`
	ConnectedFbPage          string `json:"connected_fb_page"`
	EdgeOwnerToTimelineMedia struct {
		Count    int64 `json:"count"`
		PageInfo struct {
			HasNextPage bool   `json:"has_next_page"`
			EndCursor   string `json:"end_cursor"`
		} `json:"page_info"`
		Edges []struct {
			Node IGMedia `json:"node"`
		} `json:"edges"`
	} `json:"edge_owner_to_timeline_media"`
}

func GetUserInfoNoLogin

func GetUserInfoNoLogin(username string) (ui UserInfo, err error)

GetUserInfoNoLogin returns information of the given user name without login status.

Example
user, err := GetUserInfoNoLogin("instagram")
if err != nil {
	fmt.Println(err)
	return
}

fmt.Println(user.Id)
fmt.Println(user.Biography)
Output:

25025320
Bringing you closer to the people and things you love. ❤️

func (UserInfo) GetUserId

func (u UserInfo) GetUserId() string

func (UserInfo) GetUsername

func (u UserInfo) GetUsername() string

func (UserInfo) IsPublic

func (u UserInfo) IsPublic() bool

type UserInfoEndPoint

type UserInfoEndPoint struct {
	Pk                         int64  `json:"pk"`
	Username                   string `json:"username"`
	FullName                   string `json:"full_name"`
	IsPrivate                  bool   `json:"is_private"`
	ProfilePicUrl              string `json:"profile_pic_url"`
	ProfilePicId               string `json:"profile_pic_id"`
	IsVerified                 bool   `json:"is_verified"`
	HasAnonymousProfilePicture bool   `json:"has_anonymous_profile_picture"`
	MediaCount                 int64  `json:"media_count"`
	GeoMediaCount              int64  `json:"geo_media_count"`
	FollowerCount              int64  `json:"follower_count"`
	FollowingCount             int64  `json:"following_count"`
	FollowingTagCount          int64  `json"following_tag_count"`
	Biography                  string `json:"biography"`
	BiographyWithEntities      struct {
		RawText string `json:"raw_text"`
	} `json:"biography_with_entities"`
	ExternalUrl             string `json:"external_url"`
	TotalIgtvVideos         int64  `json:"total_igtv_videos"`
	TotalClipsCount         int64  `json:"total_clips_count"`
	TotalArEffects          int64  `json:"total_ar_effects"`
	UsertagsCount           int64  `json:"usertags_count"`
	IsFavorite              bool   `json:"is_favorite"`
	IsFavoriteForStories    bool   `json:"is_favorite_for_stories"`
	IsFavoriteForIgtv       bool   `json:"is_favorite_for_igtv"`
	IsFavoriteForHighlights bool   `json:"is_favorite_for_highlights"`
	LiveSubscriptionStatus  string `json:"live_subscription_status"`
	IsInterestAccount       bool   `json:"is_interest_account"`
	HasChaining             bool   `json:"has_chaining"`
	HdProfilePicVersions    []struct {
		Width  int64  `json:"width"`
		Height int64  `json:"height"`
		Url    string `json:"url"`
	} `json:"hd_profile_pic_versions"`
	HdProfilePicUrlInfo struct {
		Url    string `json:"url"`
		Width  int64  `json:"width"`
		Height int64  `json:"height"`
	} `json:"hd_profile_pic_url_info"`
	MutualFollowersCount           int64  `json:"mutual_followers_count"`
	ProfileContext                 string `json:"profile_context"`
	ProfileContextLinksWithUserIds []struct {
		Start    int64  `json:"start"`
		End      int64  `json:"end"`
		Username string `json:"username"`
	} `json:"profile_context_links_with_user_ids"`
	ProfileContextMutualFollowIds              []int64 `json:"profile_context_mutual_follow_ids"`
	HasHighlightReels                          bool    `json:"has_highlight_reels"`
	CanBeReportedAsFraud                       bool    `json:"can_be_reported_as_fraud"`
	IsBusiness                                 bool    `json:"is_business"`
	AccountType                                int64   `json:"account_type"`
	ProfessionalConversionSuggestedAccountType int64   `json:"professional_conversion_suggested_account_type"`
	//is_call_to_action_enabled
	//personal_account_ads_page_name
	//personal_account_ads_page_id
	IncludeDirectBlacklistStatus   bool `json:"include_direct_blacklist_status"`
	IsPotentialBusiness            bool `json:"is_potential_business"`
	ShowPostInsightsEntryPoint     bool `json:"show_post_insights_entry_point"`
	IsBestie                       bool `json:"is_bestie"`
	HasUnseenBestiesMedia          bool `json:"has_unseen_besties_media"`
	ShowAccountTransparencyDetails bool `json:"show_account_transparency_details"`
	ShowLeaveFeedback              bool `json:"show_leave_feedback"`
	//robi_feedback_source
	AutoExpandChaining              bool `json:"auto_expand_chaining"`
	HighlightReshareDisabled        bool `json:"highlight_reshare_disabled"`
	IsMemorialized                  bool `json:"is_memorialized"`
	OpenExternalUrlWithInAppBrowser bool `json:"open_external_url_with_in_app_browser"`
}

func (UserInfoEndPoint) GetUserId

func (u UserInfoEndPoint) GetUserId() string

func (UserInfoEndPoint) GetUsername

func (u UserInfoEndPoint) GetUsername() string

func (UserInfoEndPoint) IsPublic

func (u UserInfoEndPoint) IsPublic() bool

type UserTray

type UserTray struct {
	Reel         IGReelTray     `json:"reel"`
	PostLiveItem IGPostLiveItem `json:"post_live_item"`

	Status string `json:"status"`
}

type WebFeedReelsTrayResponse

type WebFeedReelsTrayResponse struct {
	Data struct {
		User struct {
			FeedReelsTray struct {
				EdgeReelsTrayToReel struct {
					Edges []struct {
						Node IGReelMedia `json:"node"`
					} `json:"edges"`
				} `json:"edge_reels_tray_to_reel"`
			} `json:"feed_reels_tray"`
		} `json:"user"`
	} `json:"data"`
	Status string `json:"status"`
}

type WebStoryInfo

type WebStoryInfo struct {
	User struct {
		Id            string `json:"id"`
		ProfilePicUrl string `json:"profile_pic_url"`
		Username      string `json:"username"`
	} `json:"user"`
	Highlight struct {
		Id    int64  `json:"id"`
		Title string `json:"title"`
	} `json:"highlight"`
}

type WebStoryQueryResponse

type WebStoryQueryResponse struct {
	Data struct {
		ReelsMedia []IGReelMedia `json:"reels_media"`
	} `json:"data"`
	Status string `json:"status"`
}

Directories

Path Synopsis
Package igdl helps you download posts, stories and story highlights of Instagram users.
Package igdl helps you download posts, stories and story highlights of Instagram users.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL