mastodon

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package mastodon is the library behind the mastodon command line: the HTTP client, request shaping, and the typed data models for mastodon.social.

All endpoints used here are public and require no authentication.

Index

Constants

View Source
const BaseURL = "https://" + Host + "/api/v1"

BaseURL is the root every v1 request is built from.

View Source
const Host = "mastodon.social"

Host is the Mastodon instance this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID          string `json:"id"`
	Username    string `json:"username"`
	DisplayName string `json:"display_name"`
	Note        string `json:"note"`
	URL         string `json:"url"`
	Followers   int    `json:"followers"`
	Following   int    `json:"following"`
	Statuses    int    `json:"statuses"`
	CreatedAt   string `json:"created_at"`
	Bot         bool   `json:"bot"`
}

Account is a Mastodon user profile.

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	Rate      time.Duration
	Retries   int
	// contains filtered or unexported fields
}

Client talks to mastodon.social over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func (*Client) Account

func (c *Client) Account(ctx context.Context, username string) (*Account, error)

Account fetches a user profile by username.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) ([]byte, error)

Get fetches a URL and returns the body bytes.

func (*Client) Instance

func (c *Client) Instance(ctx context.Context) (*Instance, error)

Instance fetches instance statistics.

func (c *Client) Links(ctx context.Context, limit int) ([]*Link, error)

Links fetches trending links/articles.

func (*Client) Posts

func (c *Client) Posts(ctx context.Context, limit int) ([]*Status, error)

Posts fetches trending statuses.

func (*Client) Timeline

func (c *Client) Timeline(ctx context.Context, hashtag string, limit int) ([]*Status, error)

Timeline fetches statuses tagged with a hashtag.

func (*Client) Trends

func (c *Client) Trends(ctx context.Context, limit int) ([]*Tag, error)

Trends fetches trending hashtags.

type Domain

type Domain struct{}

Domain is the mastodon driver for the kit framework.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme and identity for this domain.

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Instance

type Instance struct {
	URI         string `json:"uri"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Users       int    `json:"users"`
	Statuses    int    `json:"statuses"`
	Domains     int    `json:"domains"`
	Version     string `json:"version"`
}

Instance holds Mastodon instance statistics.

type Link struct {
	URL         string `json:"url"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Provider    string `json:"provider"`
	Accounts    int    `json:"accounts"`
	Uses        int    `json:"uses"`
}

Link is a trending article/link shared on Mastodon.

type Status

type Status struct {
	ID          string `json:"id"`
	CreatedAt   string `json:"created_at"`
	URL         string `json:"url"`
	Content     string `json:"content"`
	Author      string `json:"author"`
	DisplayName string `json:"display_name"`
	Reblogs     int    `json:"reblogs"`
	Favourites  int    `json:"favourites"`
	Replies     int    `json:"replies"`
	Language    string `json:"language"`
	Sensitive   bool   `json:"sensitive"`
}

Status is a Mastodon post/toot.

type Tag

type Tag struct {
	Name     string `json:"name"`
	URL      string `json:"url"`
	Accounts int    `json:"accounts"`
	Uses     int    `json:"uses"`
}

Tag is a trending hashtag.

Jump to

Keyboard shortcuts

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