Skip to content

06. Collections

David Brouwer edited this page Nov 13, 2021 · 1 revision

Collections

The Collections struct represents the saved post collections. By default, your account has one collection, the "All Posts" collection, which contains all saved posts, regardless of whether they have been saved to another collection or not. If you query your account collections, this will always be the first collection in the list. Fetching your list of collections, works just like paginating a media feed.

c := insta.Collections
for c.Next() {
    fmt.Printf("Fetched %d more collections", c.NumResults)
}
if err := c.Error(); err != goinsta.ErrNoMore {
    log.Fatal(err)
}

allSavedPosts := c.Items[0]

// Pick the first custom collection
myCol := c.Items[1]

// Fetch all posts in collection
for myCol.Next() {
    fmt.Printf("Fetched %d more collections", myCol.NumResults)
}
if err := c.Error(); err != goinsta.ErrNoMore {
    log.Fatal(err)
}

All collection methods:

func (c *Collection) AddCollaborators(colab ...User) error
func (c *Collection) ChangeCover(item Item) error
func (c *Collection) ChangeName(name string) error
func (c *Collection) Delete() error
func (c *Collection) Error() error
func (c *Collection) GetNextID() string
func (c *Collection) Next(params ...interface{}) bool
func (c *Collection) RemoveMedia(items ...Item) error
func (c *Collection) Sync() error

All Collections methods:

func (c *Collections) Create(name string, items ...Item) (*Collection, error)
func (c *Collections) Error() error
func (c *Collections) Latest() []Collection
func (c *Collections) Next() bool
Clone this wiki locally