Giter Site home page Giter Site logo

go-misskey's Introduction

Go Report Card Coverage Status GoDoc Chat on Matrix

Misskey Go SDK

Misskey API Documentation: https://slippy.xyz/api-doc

Check the docs directory for more information.

For examples on given endpoints, please check the corresponding _test.go file, they have at least one ExampleService_XYZ function, examples:

Progress

Status Endpoint Group Implementation Issue Note
antennas #3
app #5
clips #8
drive #9
federation #4
following #10
groups #19
hashtags #12
meta
notes #6
notifications #15
reactions #14
⚠️ admin #21 In Progress (84%)
account
auth
channels
charts #7
list #20
messaging #13
pages #16
users #17

How to use

For detailed examples, check the example directory.

package main

import (
	"log"
	"os"

	"github.com/sirupsen/logrus"
	"github.com/yitsushi/go-misskey"
	"github.com/yitsushi/go-misskey/core"
	"github.com/yitsushi/go-misskey/services/meta"
)

func main() {
	client, err := misskey.NewClientWithOptions(
		misskey.WithAPIToken(os.Getenv("MISSKEY_TOKEN")),
		misskey.WithBaseURL("https", "slippy.xyz", ""),
		misskey.WithLogLevel(logrus.DebugLevel),
	)
	if err != nil {
		logrus.Error(err.Error())
	}

	stats, err := client.Meta().Stats()
	if err != nil {
		log.Printf("[Meta] Error happened: %s", err)
		return
	}

	log.Printf("[Stats] Instances:          %d", stats.Instances)
	log.Printf("[Stats] NotesCount:         %d", stats.NotesCount)
	log.Printf("[Stats] UsersCount:         %d", stats.UsersCount)
	log.Printf("[Stats] OriginalNotesCount: %d", stats.OriginalNotesCount)
	log.Printf("[Stats] OriginalUsersCount: %d", stats.OriginalUsersCount)
}

How can I get a Misskey Token?

Navigate to Settings > API and there you generate a new token.

How can I debug what's wrong?

There is a logging system, right now it's not very wide spread in the codebase, but if you turn it on, you will be able to see:

  • all request with method, endpoint and body
  • all responds with status code, from what endpoint told and the body

To enable debug mode, just change the LogLevel to DebugLevel:

client, _ := misskey.NewClientWithOptions(
	misskey.WithAPIToken(os.Getenv("MISSKEY_TOKEN")),
	misskey.WithBaseURL("https", "slippy.xyz", ""),
	misskey.WithLogLevel(logrus.DebugLevel),
)

The output should look like this:

DEBU[0000] POST https://slippy.xyz/api/antennas/show     _type=request
DEBU[0000] {"antennaId":"8dbpybhulw","i":"my misskey token"}  _type=request
DEBU[0000] {"id":"8dbpybhulw","createdAt":"2020-10-13T16:03:22.674Z","name":"Genshin Impact","keywords":[["genshin"]],"excludeKeywords":[[""]],"src":"all","userListId":null,"userGroupId":null,"users":[""],"caseSensitive":false,"notify":false,"withReplies":true,"withFile":false,"hasUnreadNote":false}  _type=response code=200 from="https://slippy.xyz/api/antennas/show"

go-misskey's People

Contributors

boitsov14 avatar creamlike1024 avatar dependabot[bot] avatar gitter-badger avatar ikasoba avatar massongit avatar niwaniwa avatar skarlso avatar twocs avatar yitsushi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-misskey's Issues

Add Travis test

Acceptance Criteria:

  • Travis is called on each Pull request / Commit
  • go test ./... called
  • golangci-lint run --enable-all called

Optional:

  • go test coverage reported to coveralls.

Implement Users

  • pinned-users (use User().Pinned() or something similar to fit in the service properly)
  • username/available (same)
  • users (there is no List endpoint on users, so we can use it for that)
  • users/followers
  • users/following
  • users/get-frequently-replied-users
  • users/notes
  • users/recommendation
  • users/relation
  • users/report-abuse
  • users/search-by-username-and-host
  • users/search
  • users/show

https://misskey.io/api-doc#tag/users

Implement Charts

  • charts/active-users
  • charts/drive
  • charts/federation
  • charts/hashtag
  • charts/instance
  • charts/network
  • charts/notes

User:

  • charts/user/drive
  • charts/user/following
  • charts/user/notes
  • charts/user/reactions
  • charts/users

https://misskey.io/api-doc#tag/charts

Support non-authenticated calls

Some of the endpoints can be called without authentication. Some of them returns with different body (not all fields are populated). For simple requests like Instance Metadata, it's can be useful to provide a way to call it without token, for example Instance aggregators.

Implement Groups

  • users/groups/create
  • users/groups/delete
  • users/groups/invitations/accept
  • users/groups/invitations/reject
  • users/groups/invite
  • users/groups/joined
  • users/groups/owned
  • users/groups/pull
  • users/groups/show
  • users/groups/transfer
  • users/groups/update

https://misskey.io/api-doc#tag/groups

files.CreateFromURL() causes a crash in the client library.

Describe the bug
The CreateFromURL() function in the Drive service module is causing a crash when it is used.

📝 To Reproduce
Code sample:

client := misskey.NewClient("https://host","API KEY")
if file, err := client.Drive().File().CreateFromURL(&files.CreateFromURLOptions{
  URL: "https://path/to/some/image.jpg",
}); err != nil {
panic(err)
}
// do something with the file object

🙂 Expected behavior
Client passes the create_from_url call to the Misskey API on the server.

☹️ Actual Behavior

panic: reflect: call of reflect.Value.NumField on ptr Value

goroutine 1 [running]:
reflect.flag.mustBe(...)
        /usr/local/go/src/reflect/value.go:221
reflect.Value.NumField(0x7e0240, 0xc000028080, 0x16, 0xc000046800)
        /usr/local/go/src/reflect/value.go:1369 +0xc5
github.com/yitsushi/go-misskey/core.parseMultipartFields(0x8a4a00, 0xc000028080, 0x20)
        /users/mick/.go/pkg/mod/github.com/yitsushi/[email protected]/core/multipart.go:19 +0x125
github.com/yitsushi/go-misskey/core.(*MultipartRequest).ToBody(0xc0000ca020, 0x845f96, 0x20, 0x0, 0x8a47c0, 0xc00009a180, 0xc00001c1b0, 0x23, 0x23, 0x0)
        /users/mick/.go/pkg/mod/github.com/yitsushi/[email protected]/core/multipart_request.go:38 +0x1a5
github.com/yitsushi/go-misskey.Client.sendRequest(0x83fe9c, 0x11, 0x845f96, 0x20, 0x8a4cc0, 0xc00009ad20, 0xc0000fe070, 0x8a9160, 0xc0000ca020, 0x7c3fa0, ...)
        /users/mick/.go/pkg/mod/github.com/yitsushi/[email protected]/client.go:64 +0x82
github.com/yitsushi/go-misskey.(*Client).requestHandler(0xc0001117f0, 0x8a9160, 0xc0000ca020, 0x7c3fa0, 0xc0001fc000, 0x29f01, 0xc0000ca020)
        /users/mick/.go/pkg/mod/github.com/yitsushi/[email protected]/services.go:21 +0x114
github.com/yitsushi/go-misskey/services/drive/files.(*Service).Create(0xc000111770, 0x83d9a7, 0xa, 0xc00056c3c0, 0x18, 0x0, 0xc000600000, 0x29ffa, 0x30000, 0x0, ...)
        /users/mick/.go/pkg/mod/github.com/yitsushi/[email protected]/services/drive/files/create.go:25 +0x137
github.com/yitsushi/go-misskey/services/drive/files.(*Service).CreateFromURL(0xc000111770, 0xc000111828, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /users/mick/.go/pkg/mod/github.com/yitsushi/[email protected]/services/drive/files/create_from_url.go:31 +0x17e
main.main()
        /users/mick/testbot/main.go:169 +0x3a5

📌 Additional context
n/a

Parse Data field in admin/queue/jobs response

Is your feature request related to a problem? Please describe.
The admin/queue/jobs endpoint return value depends on the requested Domain. For example Deliver has a very simple structure with only a "To" field in Data, but Inbox contains the while ActivePub Activity object.

Describe the solution you'd like
Maybe #44 gives us the ability to parse the response the right way.

Describe alternatives you've considered
I have no idea now.

Additional context
Related issue: #66

Add CODE_OF_CONDUCT.md

This one will be tricky... Never did it before, so I have to do some extra research on the topic.

Implement Note

  • notes/conversation #54
  • notes/children #53
  • notes/create #51
  • notes/delete #51
  • notes/mentions #52
  • notes/unrenote #52
  • notes/featured #45
  • notes/renotes #45
  • notes/replies #45
  • notes/show #45
  • notes/state #45

Search:

  • notes/search-by-tag #53
  • notes/search #45

Timeline:

  • notes/global-timeline #50
  • notes/hybrid-timeline #50
  • notes/local-timeline #50
  • notes/user-list-timeline #50
  • notes/timeline #50

Polls:

  • notes/polls/recommendation #54
  • notes/polls/vote #54

Favorites:

  • notes/favorites/create #54
  • notes/favorites/delete #54

Watching:

  • notes/watching/create #54
  • notes/watching/delete #54

Reactions: (related: #14)

  • notes/reactions #45
  • notes/reactions/create #49
  • notes/reactions/delete #49

Extra:

  • promo/read #49

Documentation: https://misskey.io/api-doc#tag/notes

It will be more than one PR, most likely. This section has a ton of endpoints.

Feature request: Retrieve user from token

Is your feature request related to a problem? Please describe.
I am trying to build a client for misskey in golang.
I was looking for a library for misskey and found this great library and decided to use it. However, it seems that there is no function (like /api/i) to get a user from a token.
Sorry if I just don't know it.

Describe the solution you'd like
I would like to add the ability to retrieve the user assigned to a token.

I've written a Pull Request to resolve this issue, and I'd like you to Merge it if this is not a problem.

Describe alternatives you've considered

Additional context

Some of the request struct does not respect optional fields

Describe the bug
Some of the requests have missing omitempty annotations, because of that, the request will contain the field with default value (empty string or 0) and Misskey will handle them as requested value and not as an optional field.

🙂 Expected behavior
All request structs have proper JSON annotation.

☹️ Actual Behavior
Some of the request structs have improper JSON annotation.

📌 Additional context
Reference: #93

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.