Skip to content

Heyra-Joker/gosplash

Repository files navigation

🚀 GoSplash 🚀

Apache2.o License

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.

Installation

  go get github.com/Heyra-Joker/gosplash

Documentation

Sign up on Unsplash and register as a developer. You can then create a new application and use the AppID and Secret for authentication.

Usage

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))
}

Examples

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

FAQ

1. About UnimplementedUpdate API

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.

2. Why is the API response Reply different from the official SDKs in other languages?

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.

License

Apache2.0 License