go-mastodon/instance.go

59 lines
1.6 KiB
Go
Raw Permalink Normal View History

2017-04-14 16:59:43 +02:00
package mastodon
import (
"net/http"
)
2017-04-14 21:23:36 +02:00
2017-04-14 16:59:43 +02:00
type Instance struct {
URI string `json:"uri"`
Title string `json:"title"`
Description string `json:"description"`
EMail string `json:"email"`
Version string `json:"version,omitempty"`
Thumbnail string `json:"thumbnail,omitempty"`
URLs map[string]string `json:"urls,omitempty"`
Stats *InstanceStats `json:"stats,omitempty"`
Languages []string `json:"languages"`
2019-09-30 09:54:15 +02:00
ContactAccount *Account `json:"contact_account"`
2018-01-29 05:09:30 +01:00
}
type InstanceStats struct {
UserCount int64 `json:"user_count"`
StatusCount int64 `json:"status_count"`
DomainCount int64 `json:"domain_count"`
2017-04-14 16:59:43 +02:00
}
func GetInstance() (*Instance, error) {
2017-04-14 16:59:43 +02:00
var instance Instance
err := doAPI(http.MethodGet, "/api/v1/instance", nil, &instance, nil)
2017-04-14 16:59:43 +02:00
if err != nil {
return nil, err
}
return &instance, nil
}
type WeeklyActivity struct {
Week Unixtime `json:"week"`
Statuses int64 `json:"statuses,string"`
Logins int64 `json:"logins,string"`
Registrations int64 `json:"registrations,string"`
}
func GetInstanceActivity() ([]*WeeklyActivity, error) {
var activity []*WeeklyActivity
err := doAPI(http.MethodGet, "/api/v1/instance/activity", nil, &activity, nil)
if err != nil {
return nil, err
}
return activity, nil
}
func GetInstancePeers() ([]string, error) {
var peers []string
err := doAPI(http.MethodGet, "/api/v1/instance/peers", nil, &peers, nil)
if err != nil {
return nil, err
}
return peers, nil
}