unsplash

package
v0.0.0-...-3bbfe4c Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const APIBaseURL = "https://api.unsplash.com"

APIBaseURL represents the base URL for requests to Unsplash's API.

Variables

This section is empty.

Functions

func DownloadPhoto

func DownloadPhoto(w http.ResponseWriter, r *http.Request) error

DownloadPhoto is triggered each time a download is attempted.

func GetRandomPhoto

func GetRandomPhoto(w http.ResponseWriter, r *http.Request) error

GetRandomPhoto retrives a single random photo using the provided collection IDs to narrow the pool of photos from which a random one will be chosen. If no collection IDs are present, it defaults to 998309 which is the ID of the official Stellar Photos collection.

func SearchUnsplash

func SearchUnsplash(w http.ResponseWriter, r *http.Request) error

SearchUnsplash triggers a photo search and sends a single page of photo results for a query.

func TrackPhotoDownload

func TrackPhotoDownload(id string) ([]byte, error)

TrackPhotoDownload is used to increment the number of downloads for the specified photo.

func ValidateCollections

func ValidateCollections(w http.ResponseWriter, r *http.Request) error

ValidateCollections ensures that all the custom collection IDs that are added to the extension are valid.

Types

type Collection

type Collection struct {
	ID              string `json:"id"`
	Title           string `json:"title"`
	Description     string `json:"description"`
	PublishedAt     string `json:"published_at"`
	LastCollectedAt string `json:"last_collected_at"`
	UpdatedAt       string `json:"updated_at"`
	Curated         bool   `json:"curated"`
	Featured        bool   `json:"featured"`
	TotalPhotos     int    `json:"total_photos"`
	Private         bool   `json:"private"`
	ShareKey        string `json:"share_key"`
	Links           struct {
		Self    string `json:"self"`
		HTML    string `json:"html"`
		Photos  string `json:"photos"`
		Related string `json:"related"`
	} `json:"links"`
	Meta struct {
		Title       interface{} `json:"title"`
		Description interface{} `json:"description"`
		Index       bool        `json:"index"`
	} `json:"meta"`
}

Collection respresents a single Unsplash collection.

type Photo

type Photo struct {
	ID             string `json:"id"`
	CreatedAt      string `json:"created_at"`
	UpdatedAt      string `json:"updated_at"`
	PromotedAt     string `json:"promoted_at"`
	Width          int    `json:"width"`
	Height         int    `json:"height"`
	Color          string `json:"color"`
	BlurHash       string `json:"blur_hash"`
	Description    string `json:"description"`
	AltDescription string `json:"alt_description"`
	Urls           struct {
		Raw     string `json:"raw"`
		Full    string `json:"full"`
		Regular string `json:"regular"`
		Small   string `json:"small"`
		Thumb   string `json:"thumb"`
		Custom  string `json:"custom"`
	} `json:"urls"`
	Links struct {
		Self             string `json:"self"`
		HTML             string `json:"html"`
		Download         string `json:"download"`
		DownloadLocation string `json:"download_location"`
	} `json:"links"`
	Categories             []interface{} `json:"categories"`
	Likes                  int           `json:"likes"`
	LikedByUser            bool          `json:"liked_by_user"`
	CurrentUserCollections []interface{} `json:"current_user_collections"`
	User                   struct {
		ID              string      `json:"id"`
		UpdatedAt       string      `json:"updated_at"`
		Username        string      `json:"username"`
		Name            string      `json:"name"`
		FirstName       string      `json:"first_name"`
		LastName        string      `json:"last_name"`
		TwitterUsername interface{} `json:"twitter_username"`
		PortfolioURL    string      `json:"portfolio_url"`
		Bio             string      `json:"bio"`
		Location        interface{} `json:"location"`
		Links           struct {
			Self      string `json:"self"`
			HTML      string `json:"html"`
			Photos    string `json:"photos"`
			Likes     string `json:"likes"`
			Portfolio string `json:"portfolio"`
			Following string `json:"following"`
			Followers string `json:"followers"`
		} `json:"links"`
		ProfileImage struct {
			Small  string `json:"small"`
			Medium string `json:"medium"`
			Large  string `json:"large"`
		} `json:"profile_image"`
		InstagramUsername string `json:"instagram_username"`
		TotalCollections  int    `json:"total_collections"`
		TotalLikes        int    `json:"total_likes"`
		TotalPhotos       int    `json:"total_photos"`
		AcceptedTos       bool   `json:"accepted_tos"`
	} `json:"user"`
	Exif struct {
		Make         string `json:"make"`
		Model        string `json:"model"`
		ExposureTime string `json:"exposure_time"`
		Aperture     string `json:"aperture"`
		FocalLength  string `json:"focal_length"`
		Iso          int    `json:"iso"`
	} `json:"exif"`
	Location struct {
		Title    string `json:"title"`
		Name     string `json:"name"`
		City     string `json:"city"`
		Country  string `json:"country"`
		Position struct {
			Latitude  float64 `json:"latitude"`
			Longitude float64 `json:"longitude"`
		} `json:"position"`
	} `json:"location"`
	Views     int `json:"views"`
	Downloads int `json:"downloads"`
}

Photo represents a single photo on Unsplash.

Jump to

Keyboard shortcuts

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