Categorygithub.com/blacheinc/goinsta
modulepackage
0.0.0
Repository: https://github.com/blacheinc/goinsta.git
Documentation: pkg.go.dev

# README

goinsta logo

GoDoc Go Report Card

Go Instagram Private API

Unofficial Instagram API for Golang

This repository is an extended fork of ahmdrz/goinsta.

Features

  • HTTP2 by default. Goinsta uses HTTP2 client enhancing performance.
  • Object independency. Can handle multiple instagram accounts.
  • Like Instagram mobile application. Goinsta is very similar to Instagram official application.
  • Simple. Goinsta is made by lazy programmers!
  • Backup methods. You can use Exportand Importfunctions.
  • Security. Your password is only required to login. After login your password is deleted.
  • No External Dependencies. GoInsta will not use any Go packages outside of the standard library. goinsta now uses chromedp as headless browser driver to solve challanges and checkpoints.

Package installation

go get -u github.com/blacheinc/goinsta

Delete a comment by its specified comment ID

package main

import (
	"fmt"

	"github.com/blacheinc/goinsta"
)

func main() {  
    // import cookie 
    insta, err := goinsta.ImportPathString("cookie")
    if err != nil {
		log.Fatal(err)
	}

    //retrieve postid from url
	postId, err := GetPostId(url)
	if err != nil {
		log.Fatal(err)
	}
	mediaId, err := goinsta.MediaIDFromShortID(postId)
	if err != nil {
		log.Fatal(err)
	}
	//fetch all media
	media, err := insta.GetMedia(mediaId)
	if err != nil {
		log.Fatal(err)
	}
	// set comment ID for the comment to be deleted
	var commentID  = "1567648935796"

    // load comment for a media item
    media.Items[0].Sync()

	// delete a comment by its ID
    comment := media.Items[0].Comments.DeleteByID(commentID)
	if err != nil {
		log.Fatal(err)
	}
	
}
	

Login and export/import cookie as string

package main

import (
	"fmt"

	"github.com/blacheinc/goinsta"
)

func main() {  
  insta := goinsta.New("USERNAME", "PASSWORD")

   // Only call Login the first time you login. Next time import your config
	err := insta.Login()
	if err != nil {
		log.Fatal(err)
	}


// Export your configuration as string
  // after exporting you can use ImportPathString function instead of New function.
  // insta, err := goinsta.ImportPathString("cookie")
  // it's useful when you want use goinsta repeatedly.
	cookie, err := insta.ExportAsString()
	if err != nil {
	   log.Fatal(err)
	}
  // cookie can be saved and encrypted in a database 
}

Get comments on a post

package main

import (
	"fmt"

	"github.com/blacheinc/goinsta"
)

func main() {  
  // import cookie 
  insta, err := goinsta.ImportPathString("cookie")
  if err != nil {
		log.Fatal(err)
	}

  //retrieve postid from url
	postId, err := GetPostId(url)
	if err != nil {
		log.Fatal(err)
	}
	mediaId, err := goinsta.MediaIDFromShortID(postId)
	if err != nil {
		log.Fatal(err)
	}
	//fetch all media
	media, err := insta.GetMedia(mediaId)
	if err != nil {
		log.Fatal(err)
	}
  // load comment 
  comment := media.Items[0].LoadComment()
	if err != nil {
		log.Fatal(err)
	}
  // paginate to populate the comment
  for comment.Next() {
    // loop through to get all commments in a post
		for _, comment := range comment.Comments {
        // Print all users comments 
				fmt.Println(comment.Text)
			}
		}
}
	

Example

package main

import (
	"fmt"

	"github.com/blacheinc/goinsta"
)

func main() {  
  insta := goinsta.New("USERNAME", "PASSWORD")
  
  // Only call Login the first time you login. Next time import your config
  if err := insta.Login(); err != nil {
          panic(err)
  }

  // Export your configuration
  // after exporting you can use Import function instead of New function.
  // insta, err := goinsta.Import("~/.goinsta")
  // it's useful when you want use goinsta repeatedly.
  // Export is deffered because every run insta should be exported at the end of the run
  //   as the header cookies change constantly.
  defer insta.Export("~/.goinsta")

  ...
}

For the full documentation, check the wiki, or run go doc -all.

Legal

This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Instagram or any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
EnvLoadAccs loads all the environment variables.
EnvLoadPlain will load all plain accounts stored in the env variables: INSTAGRAM_ACT_<name>="username:password" :param: path (OPTIONAL) -- .env file to load, default to ".env".
EnvProvision will check the environment variables for INSTAGRAM_ACT_ and create a base64 encoded config for the account, and write it to path.
EnvRandAcc will check the environment variables, and the .env file in the current working directory (unless another path has been provided), for either a base64 encoded goinsta config, or plain credentials.
EnvRandLogin fetches a random login from the env.
EnvReadAccs loads both all plain and base64 encoded accounts Set in a .env file or export to your environment variables: INSTAGRAM_ACT_<name>="user:pass" INSTAGRAM_BASE64_<name>="..." :param: p (OPTIONAL) -- env file path, ".env" by default.
EnvUpdateAccs will update the plain and encoded account variables stored in the .env file: INSTAGRAM_ACT_<name>="username:password" INSTAGRAM_BASE64_<name>="<base64 encoded config>" :param: string:path -- file path of the .env file, typically ".env" :param: []*EncAcc:newAccs -- list of updated versions of the accounts.
EnvUpdateEnc will update the encoded account variables stored in the .env file: INSTAGRAM_BASE64_<name>="<base64 encoded config>" :param: string:path -- file path of the .env file, typically ".env" :param: []*EnvEncAcc:newAccs -- list of updated encoded accounts.
EnvPlainAccs will update the plain account variables stored in the .env file: INSTAGRAM_ACT_<name>="username:password" :param: string:path -- file path of the .env file, typically ".env" :param: []*EnvPlainAcc:newAccs -- list of updated plain accounts.
GetBest returns url to best quality image or video.
Import imports instagram configuration This function does not set proxy automatically.
ImportConfig imports instagram configuration from a configuration object.
ImportFromBase64String imports instagram configuration from a base64 encoded string.
ImportFromBytes imports instagram configuration from an array of bytes.
ImportPathBytes imports instagram configuration from a byte path.
ImportPathString imports instagram configuration from a string path.
ImportReader imports instagram configuration from io.Reader This function does not set proxy automatically.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
New creates Instagram structure.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

so far unused.
No description provided by the author
Errors.
Errors.
No description provided by the author
Account & Login Errors.
Misc.
Errors.
Errors.
Errors.
Errors.
Errors.
Errors.
Headless.
Inbox.
IGTV.
Errors.
Errors.
Upload Errors.
Errors.
Feed Errors.
Errors.
Errors.
Errors.
Errors.
Errors.
Errors.
Users.
Errors.
Errors.
Errors.
Search Errors.
Errors.
Errors.
Errors.
Errors.
No description provided by the author
Default Device.
No description provided by the author
No description provided by the author
Errors.
No description provided by the author

# Structs

Account is personal account object See examples: examples/account/*.
Activity is the recent activity menu.
No description provided by the author
BlockedUser stores information about a used that has been blocked before.
Broadcast struct represents live video streams.
No description provided by the author
No description provided by the author
No description provided by the author
Candidate is something that I really have no idea what it is.
Caption is media caption.
Challenge is a status code 400 error, usually prompting the user to perform some action.
No description provided by the author
ChallengeError is error returned by HTTP 400 status code.
No description provided by the author
Checkpoint is just like challenge, a status code 400 error.
Collection represents a single collection.
Collections stores information about all your collection.
Comment is a type of Media retrieved by the Comments methods.
No description provided by the author
No description provided by the author
Comments allows user to interact with media (item) comments.
ConfigFile is a structure to store the session information so that can be exported or imported.
No description provided by the author
No description provided by the author
Conversation is the representation of an instagram already established conversation through direct messages.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EnvAcc represents the pair of plain and base64 encoded account pairs as stored in EnvPlainAcc and EnvEncAcc, with env variables: INSTAGRAM_ACT_<name>="username:password" INSTAGRAM_BASE64_<name>="<base64 encoded config>".
EnvEncAcc represents the encoded account details stored in the env variable: INSTAGRAM_BASE64_<name>="<base64 encoded config>".
EnvPlainAcc represents the plain account details stored in the env variable: INSTAGRAM_ACT_<name>="username:password".
No description provided by the author
Error400 is error returned by HTTP 400 status code.
Error503 is instagram API error.
ErrorN is general instagram error.
Feed is the object for all feed endpoints.
FeedLocation is the struct that fits the structure returned by instagram on LocationID search.
FeedMedia represent a set of media items Mainly used for user profile feeds.
FeedTag is the struct that fits the structure returned by instagram on TagSearch.
Friendship stores the details of the relationship between two users.
Hashtag is used for getting the media that matches a hashtag on instagram.
All items with interface{} I have only seen a null response.
IGTVChannel can represent a single user's collection of IGTV posts, or it can e.g.
IGTVItem is a media item that can be found inside the IGTV struct, from the IGTV Discover endpoint.
Images are different quality images.
Inbox is the direct message inbox.
InboxItem is any conversation message.
InboxItemLike is the heart sent during a conversation.
InboxItemMedia is inbox media item.
InstaComments allows user to interact with media (item) comments.
Instagram represent the main API handler Timeline: Represents instagram's main timeline.
Item represents media items All Item has Images or Videos objects which contains the url(s).
No description provided by the author
LiveItems are Live media items.
Location stores media location information.
No description provided by the author
LocationTag represents a post location tag.
MediaItem defines a item media for the SavedMedia struct.
Mentions is a user being mentioned on media.
Nametag is part of the account information.
No description provided by the author
No description provided by the author
PicURLInfo repre.
No description provided by the author
Profile represents an instagram user with their various properties, such as their account info, stored in Profile.User (a *User struct), feed, stories, Highlights, IGTV posts, and friendship status.
Profiles allows user function interactions.
No description provided by the author
Reel represents a single user's story collection.
No description provided by the author
SavedMedia stores information about ALL your saved posts, regardless of their collection.
School is void structure (yet).
No description provided by the author
Search is the object for all searches like Facebook, Location or Tag search.
No description provided by the author
SearchResult handles the data for the results given by each type of Search.
No description provided by the author
StoryCTA represent story cta.
StoryMedia is the struct that handles the information from the methods to get info about Stories.
StoryReelMention represent story reel mention.
SuggestedUsers stores the information about user suggestions.
No description provided by the author
Tag is the information of an user being tagged on any media.
Timeline is the object to represent the main feed on instagram, the first page that shows the latest feeds of my following contacts.
No description provided by the author
Two factor authentication seed, used to generte the one time passwords.
Tray is a set of story media received from timeline calls.
No description provided by the author
No description provided by the author
User is the representation of instagram's user profile.
Users is a struct that stores many user's returned by many different methods.
UserTag represents a user post tag.
Video are different quality videos.
used for raven_media type.
No description provided by the author
No description provided by the author

# Interfaces

Media interface defines methods for both StoryMedia and FeedMedia.
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author