Mastodon API client for Go (golang); fork of https://github.com/mattn/go-mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dtluna 957d11cc88 Accept scope as a string in GetAuthorizeURL 1 month ago
testdata add missing file 2 years ago
.gitignore add .gitignore 2 years ago
LICENSE add LICENSE 2 years ago
README.md Merge branch 'buckket/push' of dtluna/go-mastodon into master 2 months ago
accounts.go Add support for /api/v1/push/subscription 5 months ago
accounts_test.go Simplify code 3 months ago
apps.go Add convenience function to authenticate using OAuth2. 11 months ago
apps_test.go add test 1 year ago
compat.go Add support for /api/v1/push/subscription 5 months ago
example_test.go Remove all mentions of github 2 months ago
go.mod Remove msdtn and change go.mod to git.dtluna.net/dtluna/go-mastodon 2 months ago
go.sum Remove msdtn and change go.mod to git.dtluna.net/dtluna/go-mastodon 2 months ago
go.test.sh Temporary disable test with -race 4 months ago
helper.go Fix to parse API error 2 years ago
helper_test.go Fix ineffectual assignments 3 months ago
instance.go Updated entities and json structs for API v2.6.0 11 months ago
instance_test.go add tests for instance 1 year ago
lists.go Add list API support. 6 months ago
lists_test.go Fix ineffectual assignments 3 months ago
mastodon.go Make Client.Config public 2 months ago
mastodon_test.go Fixed pagination parsing for non-numeric IDs 5 months ago
notification.go Add support for /api/v1/push/subscription 5 months ago
notification_test.go Modify test fixture to increse test coverage 5 months ago
oauth.go Accept scope as a string in GetAuthorizeURL 1 month ago
report.go fix IDs 2 years ago
report_test.go fix IDs 2 years ago
scrobble.go Fix imports 1 month ago
status.go Add direct 4 months ago
status_test.go Fix ineffectual assignments 3 months ago
streaming.go Make Client.Config public 2 months ago
streaming_test.go Added tests for list API calls 6 months ago
streaming_ws.go Make Client.Config public 2 months ago
streaming_ws_test.go Fix ineffectual assignments 3 months ago
unixtime.go Add GetInstanceActivity and GetInstancePeers 1 year ago

README.md

go-mastodon

GoDoc

Usage

Application

package main

import (
	"context"
	"fmt"
	"log"

	"git.dtluna.net/dtluna/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://git.dtluna.net/dtluna/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"

	"git.dtluna.net/dtluna/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
  • POST /api/v1/push/subscription
  • GET /api/v1/push/subscription
  • PUT /api/v1/push/subscription
  • DELETE /api/v1/push/subscription
  • 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 git.dtluna.net/dtluna/go-mastodon

License

MIT

Authors

  • Yasuhiro Matsumoto (a.k.a. mattn)
  • dtluna