bloat/mastodon
r 08cc2a6ade Add emojis page 2019-12-22 18:10:42 +00:00
..
LICENSE Initial commit 2019-12-13 18:26:24 +00:00
README.md Initial commit 2019-12-13 18:26:24 +00:00
accounts.go Add user page and follow/unfollow calls 2019-12-20 18:30:20 +00:00
apps.go Initial commit 2019-12-13 18:26:24 +00:00
go.mod Fix go mod 2019-12-22 16:28:31 +00:00
go.sum Fix go mod 2019-12-22 16:28:31 +00:00
helper.go Initial commit 2019-12-13 18:26:24 +00:00
instance.go Add emojis page 2019-12-22 18:10:42 +00:00
lists.go Initial commit 2019-12-13 18:26:24 +00:00
mastodon.go Add attachments support 2019-12-14 20:19:02 +00:00
notification.go Add notification support 2019-12-15 17:37:58 +00:00
report.go Initial commit 2019-12-13 18:26:24 +00:00
status.go Add reply links on thread page 2019-12-18 22:14:02 +00:00
streaming.go Initial commit 2019-12-13 18:26:24 +00:00
streaming_ws.go Initial commit 2019-12-13 18:26:24 +00:00
unixtime.go Initial commit 2019-12-13 18:26:24 +00:00

README.md

go-mastodon

Build Status Coverage Status GoDoc Go Report Card

Usage

Application

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/mattn/go-mastodon"
)

func main() {
	app, err := mastodon.RegisterApp(context.Background(), &mastodon.AppConfig{
		Server:     "https://mstdn.jp",
		ClientName: "client-name",
		Scopes:     "read write follow",
		Website:    "https://github.com/mattn/go-mastodon",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("client-id    : %s\n", app.ClientID)
	fmt.Printf("client-secret: %s\n", app.ClientSecret)
}

Client

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/mattn/go-mastodon"
)

func main() {
	c := mastodon.NewClient(&mastodon.Config{
		Server:       "https://mstdn.jp",
		ClientID:     "client-id",
		ClientSecret: "client-secret",
	})
	err := c.Authenticate(context.Background(), "your-email", "your-password")
	if err != nil {
		log.Fatal(err)
	}
	timeline, err := c.GetTimelineHome(context.Background(), nil)
	if err != nil {
		log.Fatal(err)
	}
	for i := len(timeline) - 1; i >= 0; i-- {
		fmt.Println(timeline[i])
	}
}

Status of implementations

  • GET /api/v1/accounts/:id
  • GET /api/v1/accounts/verify_credentials
  • PATCH /api/v1/accounts/update_credentials
  • GET /api/v1/accounts/:id/followers
  • GET /api/v1/accounts/:id/following
  • GET /api/v1/accounts/:id/statuses
  • POST /api/v1/accounts/:id/follow
  • POST /api/v1/accounts/:id/unfollow
  • GET /api/v1/accounts/:id/block
  • GET /api/v1/accounts/:id/unblock
  • GET /api/v1/accounts/:id/mute
  • GET /api/v1/accounts/:id/unmute
  • GET /api/v1/accounts/:id/lists
  • GET /api/v1/accounts/relationships
  • GET /api/v1/accounts/search
  • POST /api/v1/apps
  • GET /api/v1/blocks
  • GET /api/v1/favourites
  • GET /api/v1/follow_requests
  • POST /api/v1/follow_requests/:id/authorize
  • POST /api/v1/follow_requests/:id/reject
  • POST /api/v1/follows
  • GET /api/v1/instance
  • GET /api/v1/instance/activity
  • GET /api/v1/instance/peers
  • GET /api/v1/lists
  • GET /api/v1/lists/:id/accounts
  • GET /api/v1/lists/:id
  • POST /api/v1/lists
  • PUT /api/v1/lists/:id
  • DELETE /api/v1/lists/:id
  • POST /api/v1/lists/:id/accounts
  • DELETE /api/v1/lists/:id/accounts
  • POST /api/v1/media
  • GET /api/v1/mutes
  • GET /api/v1/notifications
  • GET /api/v1/notifications/:id
  • POST /api/v1/notifications/clear
  • GET /api/v1/reports
  • POST /api/v1/reports
  • GET /api/v1/search
  • GET /api/v1/statuses/:id
  • GET /api/v1/statuses/:id/context
  • GET /api/v1/statuses/:id/card
  • GET /api/v1/statuses/:id/reblogged_by
  • GET /api/v1/statuses/:id/favourited_by
  • POST /api/v1/statuses
  • DELETE /api/v1/statuses/:id
  • POST /api/v1/statuses/:id/reblog
  • POST /api/v1/statuses/:id/unreblog
  • POST /api/v1/statuses/:id/favourite
  • POST /api/v1/statuses/:id/unfavourite
  • GET /api/v1/timelines/home
  • GET /api/v1/timelines/public
  • GET /api/v1/timelines/tag/:hashtag
  • GET /api/v1/timelines/list/:id

Installation

$ go get github.com/mattn/go-mastodon

License

MIT

Author

Yasuhiro Matsumoto (a.k.a. mattn)