Client for the pixeldrain API. Used by pixeldrain itself for tranferring data between the web UI and API server. And for rendering JSON responses
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
967 B

  1. package pixelapi
  2. import "fornaxian.tech/pixeldrain_server/api/restapi/apitype"
  3. // Recaptcha stores the reCaptcha site key
  4. type Recaptcha struct {
  5. SiteKey string `json:"site_key"`
  6. }
  7. // GetMiscRecaptcha gets the reCaptcha site key from the pixelapi server. If
  8. // reCaptcha is disabled the key will be empty
  9. func (p *PixelAPI) GetMiscRecaptcha() (resp Recaptcha, err error) {
  10. return resp, p.jsonRequest("GET", "misc/recaptcha", &resp)
  11. }
  12. // GetMiscViewToken requests a viewtoken from the server. The viewtoken is valid
  13. // for a limited amount of time and can be used to add views to a file.
  14. // Viewtokens can only be requested from localhost
  15. func (p *PixelAPI) GetMiscViewToken() (resp string, err error) {
  16. return resp, p.jsonRequest("GET", "misc/viewtoken", &resp)
  17. }
  18. // GetSiaPrice gets the price of one siacoin
  19. func (p *PixelAPI) GetSiaPrice() (resp float64, err error) {
  20. var sp apitype.SiaPrice
  21. return sp.Price, p.jsonRequest("GET", "misc/sia_price", &sp)
  22. }