Help us shape the future of Go! Take the 2026 Go Developer Survey

gomif

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2018 License: MIT Imports: 7 Imported by: 0

README

gomif

GoDoc wercker status

GO Mastodon Instance information Fetcher

Examples

First you need to get a instances.social API token.

Use as CLI
$ go get -u github.com/m0t0k1ch1/gomif/cmd/gomif
$ GOMIF_TOKEN=<your token> gomif -i mastodon.m0t0k1ch1.com
Use in code
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"

	"github.com/m0t0k1ch1/gomif"
)

func main() {
	client := gomif.NewClient("your token")

	info, err := client.FetchInstanceInformation(
		context.Background(),
		"mastodon.m0t0k1ch1.com",
	)
	if err != nil {
		log.Fatal(err)
	}

	b, err := json.Marshal(info)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(string(b))
}

Documentation

Index

Constants

View Source
const (
	DefaultUri = "https://instances.social/api/1.0/instances/show"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string) *Client

func (*Client) FetchInstanceInformation added in v0.4.0

func (client *Client) FetchInstanceInformation(ctx context.Context, name string) (*InstanceInformation, error)

func (*Client) SetUri

func (client *Client) SetUri(uri string)

type Config

type Config struct {
	Uri   string
	Token string
}

type Error added in v0.4.0

type Error struct {
	Message string `json:"message"`
}

type ErrorResponse added in v0.4.0

type ErrorResponse struct {
	Error *Error `json:"error"`
}

type InstanceInformation added in v0.4.0

type InstanceInformation struct {
	Id                string    `json:"id"`
	Name              string    `json:"name"`
	AddedAt           time.Time `json:"added_at"`
	UpdatedAt         time.Time `json:"updated_at"`
	CheckedAt         time.Time `json:"checked_at"`
	Uptime            float64   `json:"uptime"`
	Up                bool      `json:"up"`
	Dead              bool      `json:"dead"`
	Version           string    `json:"version"`
	Ipv6              bool      `json:"ipv6"`
	HttpsScore        int       `json:"https_score"`
	HttpsRank         string    `json:"https_rank"`
	ObsScore          int       `json:"obs_score"`
	ObsRank           string    `json:"obs_rank"`
	Users             int       `json:"users"`
	Statuses          int       `json:"statuses"`
	Connections       int       `json:"connections"`
	OpenRegistrations bool      `json:"open_registrations"`
	Thumbnail         string    `json:"thumbnail"`
	ThumbnailProxy    string    `json:"thumbnail_proxy"`
	ActiveUsers       int       `json:"active_users"`
}

Directories

Path Synopsis
cmd
gomif command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL