Go to file
Christian Muehlhaeuser 4def10a243 Updated entities and json structs for API v2.6.0
Added missing fields to various structs and sorted them in the same order as
the original mastodon API documentation does. This should make it easier to
compare go-mastodon's structs with the original documentation.
2018-11-25 23:15:20 +09:00
cmd/mstdn add some fields for instance command 2018-01-29 14:09:10 +09:00
testdata add missing file 2017-04-17 14:03:40 +09:00
.gitignore add .gitignore 2017-04-14 23:47:04 +09:00
.travis.yml add .travis.yml 2017-04-14 17:14:55 +09:00
accounts_test.go Fix type of IDs. 2017-10-23 23:48:48 +09:00
accounts.go Updated entities and json structs for API v2.6.0 2018-11-25 23:15:20 +09:00
apps_test.go add test 2017-11-30 14:55:18 +09:00
apps.go Add convenience function to authenticate using OAuth2. 2018-11-22 21:37:40 +09:00
compat.go add missing file 2017-10-23 23:53:03 +09:00
example_test.go also convert to string in attachments, pagenation 2017-10-25 10:22:39 +09:00
helper_test.go Fix test want 2017-04-20 20:55:45 +09:00
helper.go Fix to parse API error 2017-04-19 14:32:53 +09:00
instance_test.go add tests for instance 2018-01-29 13:55:37 +09:00
instance.go Updated entities and json structs for API v2.6.0 2018-11-25 23:15:20 +09:00
LICENSE add LICENSE 2017-04-27 09:20:14 +09:00
mastodon_test.go also convert to string in attachments, pagenation 2017-10-25 10:22:39 +09:00
mastodon.go Updated entities and json structs for API v2.6.0 2018-11-25 23:15:20 +09:00
notification_test.go Fix: forgot to (*Client)GetNotification's parameter: int64 -> ID 2017-10-25 14:35:34 +09:00
notification.go Fix: forgot to (*Client)GetNotification's parameter: int64 -> ID 2017-10-25 14:35:34 +09:00
README.md add info about missing lists APIs in Readme 2018-11-14 18:14:05 +09:00
report_test.go fix IDs 2017-10-25 15:22:17 +09:00
report.go fix IDs 2017-10-25 15:22:17 +09:00
status_test.go Fixed tests for Go 1.11 2018-11-25 23:09:03 +09:00
status.go Updated entities and json structs for API v2.6.0 2018-11-25 23:15:20 +09:00
streaming_test.go fix IDs 2017-10-25 15:22:17 +09:00
streaming_ws_test.go fix IDs 2017-10-25 15:22:17 +09:00
streaming_ws.go handle float64/string both 2017-11-20 10:04:53 +09:00
streaming.go fix #66 2017-11-20 09:58:20 +09:00
unixtime.go Add GetInstanceActivity and GetInstancePeers 2018-01-29 12:33:17 +09:00

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

Installation

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

License

MIT

Author

Yasuhiro Matsumoto (a.k.a. mattn)