Skip to content

kosa3/pexels-go

Repository files navigation

Pexels API Client for Go

kosa3/pexels-go is Pexels API Client for Go. Pexels is the best free stock photos & videos shared by talented creators.

Install

$ go get -u github.com/kosa3/pexels-go

Examples

See example directory.

func main() {
	cli := pexels.NewClient(os.Args[1])
	ctx := context.Background()
	ps, err := cli.PhotoService.Search(ctx, &pexels.PhotoParams{
		Query: "people",
		Page: 2,
	})
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("Source Medium URL:", ps.Photos[0].Src.Medium)
}

Supported API

Photo

Endpoint HTTP Method
/v1/search GET
/v1/curated GET
/v1/photos/{id} GET

Video

Endpoint HTTP Method
/videos/search GET
/videos/popular GET
/videos/videos/{id} GET

Collection

Endpoint HTTP Method
/v1/collections/featured GET
/v1/collections GET
/v1/collections/{id} GET