Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fox-one/mixin-sdk-go
Golang sdk for Mixin Network & Mixin Messenger
https://github.com/fox-one/mixin-sdk-go
golang mixin mixin-messenger mixin-network mixin-sdk mixin-sdk-go
Last synced: about 1 month ago
JSON representation
Golang sdk for Mixin Network & Mixin Messenger
- Host: GitHub
- URL: https://github.com/fox-one/mixin-sdk-go
- Owner: fox-one
- License: mit
- Created: 2020-06-28T10:24:29.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-29T14:15:02.000Z (4 months ago)
- Last Synced: 2024-04-30T06:27:49.379Z (4 months ago)
- Topics: golang, mixin, mixin-messenger, mixin-network, mixin-sdk, mixin-sdk-go
- Language: Go
- Homepage: https://developers.mixin.one/
- Size: 690 KB
- Stars: 44
- Watchers: 8
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mixin - Mixin SDK Go - The most widely used 3rd party Golang SDK, provided by Fox.ONE, used by many teams, comprehensive API supported for both Mixin Network and Mixin Messenger. (SDK / 3rd-party SDK)
README
# mixin-sdk-go
Golang sdk for Mixin Network & Mixin Messenger## Install
`go get -u github.com/fox-one/mixin-sdk-go/v2`
## Features
* **Comprehensive** most of the Mixin Network & Mixin Messenger api supported
* **Security** verify Response `X-Request-ID` & signature automatically
* **Flexible** initialize [Client](https://github.com/fox-one/mixin-sdk-go/blob/master/client.go) from `keystore`, `ed25519_oauth_token` or `access_token`## Examples
See [_examples/](https://github.com/fox-one/mixin-sdk-go/blob/master/_examples/) for a variety of examples.
**Quick Start**
```go
package mainimport (
"context"
"log""github.com/fox-one/mixin-sdk-go/v2"
)func main() {
ctx := context.Background()
s := &mixin.Keystore{
ClientID: "",
SessionID: "",
PrivateKey: "",
PinToken: "",
}client, err := mixin.NewFromKeystore(s)
if err != nil {
log.Panicln(err)
}user, err := client.UserMe(ctx)
if err != nil {
log.Printf("UserMe: %v", err)
return
}log.Println("user id", user.UserID)
}
```## Error handling?
check error code by `mixin.IsErrorCodes`
```go
if _, err := client.UserMe(ctx); err != nil {
switch {
case mixin.IsErrorCodes(err,mixin.Unauthorized,mixin.EndpointNotFound):
// handle unauthorized error
case mixin.IsErrorCodes(err,mixin.InsufficientBalance):
// handle insufficient balance error
default:
}
}
```