Unsplash provides freely licensed high-resolution photos that can be used for anything.
This repository is a Golang SDK developed based on the Unsplash API content and covers all current APIs.
go get github.com/Heyra-Joker/gosplash
Sign up on Unsplash and register as a developer. You can then create a new application and use the AppID and Secret for authentication.
package main
import (
"encoding/json"
"log"
"github.com/Heyra-Joker/gosplash"
)
func main() {
clientId := "<YOUR CLIENT ID>"
g := gosplash.Photo{Client: gosplash.NewClient(clientId)}
reply, response, err := g.Random(gosplash.PhotoRandomReq{})
if err != nil {
log.Fatal(err)
}
log.Println(response.OriginResponseBody)
log.Println(response.RateLimitLimit)
log.Println(response.RateLimitRemaining)
data, _ := json.Marshal(reply)
log.Println(string(data))
}
API | Example |
---|---|
Authorization | authorization_test.go |
Current User | current_user_test.go |
Users | users_test.go |
Photos | photo_test.go |
Search | search_test.go |
Collections | collection_test.go |
Topics | topics_test.go |
Stats | stats_test.go |
Sorry about this function, I have no permission to upload image, if you have the necessary permissions, you can submit an issue to fix this function.
This is because the project creates the Reply
based on actual request results, and the official SDK versions in other languages are really outdated.
However, rest assured that in most cases, the parsing content you need is already included in Reply
.
If you find that some request responses are not included in Reply
, please submit an issue
and I will update it as soon as possible.