Monobank REST API client.
- Personal API(with Token authorization).
- API for providers(corporate) with authorization.
- Webhooks(including API for providers).
- Jars(only in Personal API).
go get github.com/vtopc/go-monobank@latest
This will update yours go.mod file.
NOTE: Do not forget to check errors.
package main
import (
"context"
"fmt"
"github.com/vtopc/go-monobank"
)
func main() {
// Create public client.
client := monobank.NewClient(nil)
response, _ := client.Currency(context.Background())
fmt.Println(response)
}
package main
import (
"context"
"fmt"
"os"
"github.com/vtopc/go-monobank"
)
func main() {
token := os.Getenv("TOKEN")
// Create authorized client.
client := monobank.NewPersonalClient(nil).WithAuth(monobank.NewPersonalAuthorizer(token))
response, _ := client.ClientInfo(context.Background())
fmt.Println(response)
}
package main
import (
"context"
"fmt"
"github.com/vtopc/go-monobank"
)
var secKey []byte // put here you private key
const webhook = "https://example.com/webhook"
func main() {
// Create auth creator.
authMaker, _ := monobank.NewCorpAuthMaker(secKey)
// Create authorized client.
client, _ := monobank.NewCorporateClient(nil, authMaker)
// If the user is not authorized yet, do next:
resp, _ := client.Auth(context.Background(), webhook, monobank.PermSt, monobank.PermPI)
// Send `resp.AcceptURL` to the user and wait until it will authorize your client
// in Monobank app on mobile, you will get GET request on `webhook` when it will be done.
// See Documentation for details.
// Store `resp.RequestID` somewhere.
requestID := resp.RequestID
// If user authorized already:
response, _ := client.ClientInfo(context.Background(), requestID)
fmt.Println(response)
}
- https://github.com/shal/mono (last update 16.05.2020)
- https://github.com/artemrys/go-monobank-api (no corporate API)
- More unit tests