package module
v0.0.0-...-66781f3 Latest Latest

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

Go to latest
Published: Aug 4, 2018 License: MIT Imports: 10 Imported by: 0


Instagram Open SDK

Go SDK for Instagram that uses same REST/GraphQL that web client does instead of official api.


Because I found Instagrams app preview process painful and needless.


SDK uses same api the official web client does so you will need instagram account to use this. Now instead of access token and client id this SDK authenticates in same way the web client does, by using cookies.


This project is still in WIP state so the api changes are inevitable.




View Source
const (
	BASE_URL = "https://www.instagram.com"
	LOGIN    = "/accounts/login/ajax/"
	EXPLORE  = "/explore"
	TAGS     = "/tags/"
	POSTS    = "/p/"
	QUERY    = "/query/"
	ENDING   = "/?__a=1"
	SEARCH   = "/web/search/topsearch/"


This section is empty.


This section is empty.


type Client

type Client struct {
	TagService  *TagService
	UserService *UserService
	PostService *PostService
	// contains filtered or unexported fields

func NewClient

func NewClient(username, password string) (*Client, error)

type CountWrapper

type CountWrapper struct {
	Count int `json:"count"`

type Dimensions

type Dimensions struct {
	Width  int `json:"width"`
	Height int `json:"height"`

type IdWrapper

type IdWrapper struct {
	ID string `json:"id"`

type LoginResponse

type LoginResponse struct {
	Status        string `json:"status"`
	Authenticated bool   `json:"authenticated"`
	User          bool   `json:"user"`
	UserID        string `json:"userId"`

type Node

type Node struct {
	Caption            string       `json:"caption"`
	ShortCode          string       `json:"shortcode"`
	Comments           CountWrapper `json:"edge_media_to_comment"`
	Date               int          `json:"taken_at_timestamp"`
	Dimensions         Dimensions   `json:"dimensions"`
	DisplaySrc         string       `json:"display_url"`
	ID                 string       `json:"id"`
	IsVideo            bool         `json:"is_video"`
	Likes              CountWrapper `json:"edge_media_preview_like"`
	Owner              IdWrapper    `json:"owner"`
	ThumbnailSrc       string       `json:"thumbnail_src"`
	EdgeMediaToCaption struct {
		Edges []struct {
			Node struct {
				Text string `json:"text"`
			} `json:"node"`
		} `json:"edges"`
	} `json:"edge_media_to_caption"`
	ThumbnailResources []struct {
		Src    string `json:"src"`
		Width  int    `json:"config_width"`
		Height int    `json:"config_height"`
	} `json:"thumbnail_resources"`
	// contains filtered or unexported fields

func (*Node) GetImage

func (n *Node) GetImage() (image.Image, error)

func (*Node) GetThumbnail

func (n *Node) GetThumbnail() (image.Image, error)

type NodeWrapper

type NodeWrapper struct {
	Node Node `json:"node"`

type PageInfo

type PageInfo struct {
	HasNextPage     bool   `json:"has_next_page"`
	EndCursor       string `json:"end_cursor"`
	StartCursor     string `json:"start_cursor"`
	HasPreviousPage bool   `json:"has_previous_page"`

type PostResponse

type PostResponse struct {
	ID                   string     `json:"id"`
	ShortCode            string     `json:"shortcode"`
	MediaPreview         string     `json:"media_preview"`
	DisplayURL           string     `json:"display_url"`
	ShouldLogClientEvent bool       `json:"should_log_client_event"`
	IsVideo              bool       `json:"is_video"`
	TrackingToken        string     `json:"tracking_token"`
	TakenAtTimestamp     int        `json:"taken_at_timestamp"`
	CaptionIsEdited      bool       `json:"caption_is_edited"`
	Dimensions           Dimensions `json:"dimensions"`
	User                 User       `json:"owner"`
	DisplayResources     []struct {
		Src          string `json:"src"`
		ConfigWidth  int    `json:"config_width"`
		ConfigHeight int    `json:"config_height"`
	} `json:"display_resources"`
	EdgeMediaToTaggedUser struct {
		Edges []struct {
			Node struct {
				User struct {
					// contains filtered or unexported fields
				} `json:"user"`
				X float64 `json:"x"`
				Y float64 `json:"y"`
			} `json:"node"`
		} `json:"edges"`
	} `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"`
	EdgeMediaPreviewLike struct {
		Count int `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"`
	EdgeMediaToComment struct {
		Count    int      `json:"count"`
		PageInfo PageInfo `json:"page_info"`
		Edges    []struct {
			Node struct {
				ID             string       `json:"id"`
				Text           string       `json:"text"`
				CreatedAt      int          `json:"created_at"`
				ViewerHasLiked bool         `json:"viewer_has_liked"`
				EdgeLikedBy    CountWrapper `json:"edge_liked_by"`
				User           User         `json:"owner"`
			} `json:"node"`
		} `json:"edges"`
	} `json:"edge_media_to_comment"`

type PostService

type PostService struct {
	// contains filtered or unexported fields

func (*PostService) Get

func (t *PostService) Get(shortCode string) (res *PostResponse, err error)

type TagResponse

type TagResponse struct {
	Name           string `json:"name"`
	IsTopMediaOnly bool   `json:"is_top_media_only"`
	ProfilePicURL  string `json:"profile_pic_url"`
	Medias         struct {
		Count int           `json:"count"`
		Nodes []NodeWrapper `json:"edges"`
	} `json:"edge_hashtag_to_media"`
	TopPosts struct {
		Nodes []NodeWrapper `json:"edges"`
	} `json:"edge_hashtag_to_top_posts"`

type TagService

type TagService struct {
	// contains filtered or unexported fields

func (*TagService) After

func (t *TagService) After(tagName, cursor string, amount uint) (res *TagResponse, err error)

func (*TagService) Recent

func (t *TagService) Recent(tagName string) (res *TagResponse, err error)

func (*TagService) Top

func (t *TagService) Top(tagName string) (res *TagResponse, err error)

type User

type User struct {
	ID            string `json:"id"`
	Username      string `json:"username"`
	FullName      string `json:"full_name"`
	ProfilePicURL string `json:"profile_pic_url"`

type UserService

type UserService struct {
	// contains filtered or unexported fields

Jump to

Keyboard shortcuts

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