Skip to content
mastodon client for golang
Branch: master
Clone or download
Latest commit 26fcedc Jun 22, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/mstdn Add direct Jun 21, 2019
testdata
.gitignore add .gitignore Apr 14, 2017
.travis.yml Only tip Jun 21, 2019
LICENSE add LICENSE Apr 27, 2017
README.md Update badge Jun 21, 2019
accounts.go All parameters are now of pointer type and thus can be nil May 14, 2019
accounts_test.go
apps.go Add convenience function to authenticate using OAuth2. Nov 22, 2018
apps_test.go add test Nov 30, 2017
compat.go add missing file Oct 23, 2017
example_test.go also convert to string in attachments, pagenation Oct 25, 2017
go.mod Add go.mod May 14, 2019
go.sum Add go.mod May 14, 2019
go.test.sh Temporary disable test with -race Jun 21, 2019
helper.go Fix Pagination variable from *int64 to int64 May 6, 2017
helper_test.go Fix Pagination variable from *int64 to int64 May 6, 2017
instance.go Updated entities and json structs for API v2.6.0 Nov 25, 2018
instance_test.go add tests for instance Jan 29, 2018
lists.go Add list API support. May 12, 2019
lists_test.go Added tests for list API calls May 12, 2019
mastodon.go Set User-Agent Jun 21, 2019
mastodon_test.go Fixed pagination parsing for non-numeric IDs May 17, 2019
notification.go Add /api/v1/notifications/dismiss May 17, 2019
notification_test.go Add /api/v1/notifications/dismiss May 17, 2019
report.go fix IDs Oct 25, 2017
report_test.go fix IDs Oct 25, 2017
status.go Add direct Jun 21, 2019
status_test.go Add direct Jun 21, 2019
streaming.go Add streaming list support. May 12, 2019
streaming_test.go Added tests for list API calls May 12, 2019
streaming_ws.go Add streaming list support. May 12, 2019
streaming_ws_test.go fix IDs Oct 25, 2017
unixtime.go Add GetInstanceActivity and GetInstancePeers Jan 29, 2018

README.md

go-mastodon

Build Status CodeCov 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/dismiss
  • 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)

You can’t perform that action at this time.