unsplash

package module
v0.0.0-...-b3e5943 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2016 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Unsplash API for Golang

Live coded at a Golang Melb Hack night.

Implemented

  • Authentication via OAuth
  • GET /users/:username/photos

Example

Create a new Unsplash Developer Application and use the client id below, or for how to use OAuth, see cli/unsplash/oauth.go

c := unsplash.NewClient("client id from above goes here")
photos, err := c.GetUserPhotos("lox", func(p unsplash.Photo) error {
	log.Println(photo.Links.Download)
	return nil
})
if err != nil {
	log.Fatal(err)
}

Using the CLI

go get github.com/lox/unsplash-go/cli/unsplash
unsplash -user nasa -download ~/Documents/Wallpaper/Unsplash/NASA

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Client *http.Client
	// contains filtered or unexported fields
}

Client is a client for Unsplash.com's API

func NewClient

func NewClient(clientID string) *Client

NewClient creates a new Unsplash Client for unauthenticated public actions

func (*Client) GetCollection

func (c *Client) GetCollection(id string, orderBy string, f func(p Photo) (bool, error)) error

GetCollection gets all the photos from a collection

func (*Client) GetUserPhotos

func (c *Client) GetUserPhotos(username string, orderBy string, f func(p Photo) (bool, error)) error

GetUserPhotos gets all of a users photos

func (*Client) GetUsersLikes

func (c *Client) GetUsersLikes(username string, orderBy string, f func(p Photo) (bool, error)) error

GetUsersLikes gets all the photos a user has liked

type Photo

type Photo struct {
	ID          string `json:"id"`
	Width       int    `json:"width"`
	Height      int    `json:"height"`
	Color       string `json:"color"`
	Likes       int    `json:"likes"`
	LikedByUser bool   `json:"liked_by_user"`
	User        struct {
		ID           string `json:"id"`
		Username     string `json:"username"`
		Name         string `json:"name"`
		ProfileImage struct {
			Small  string `json:"small"`
			Medium string `json:"medium"`
			Large  string `json:"large"`
		} `json:"profile_image"`
		Links struct {
			Self   string `json:"self"`
			HTML   string `json:"html"`
			Photos string `json:"photos"`
			Likes  string `json:"likes"`
		} `json:"links"`
	} `json:"user"`
	CurrentUserCollections []interface{} `json:"current_user_collections"`
	Urls                   struct {
		Raw     string `json:"raw"`
		Full    string `json:"full"`
		Regular string `json:"regular"`
		Small   string `json:"small"`
		Thumb   string `json:"thumb"`
	} `json:"urls"`
	Categories []interface{} `json:"categories"`
	Links      struct {
		Self     string `json:"self"`
		HTML     string `json:"html"`
		Download string `json:"download"`
	} `json:"links"`
}

Photo is an Unsplash Photo

Directories

Path Synopsis
cli
unsplash command

Jump to

Keyboard shortcuts

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