MT5 manager gRPC API Go language client example

Created with Sketch.

MT5 manager gRPC API Go language client example

Table of Contents

MT5 manager gRPC API methods

MT5 manager gRPC API proto file

Ready to run example

Install autogenerated cleint libraries:

go get
go get

Alternatively, use this command for your own libraries' generation, if needed:

docker run --user "$(id -u):$(id -g)" -v `pwd`:/defs namely/protoc-all -f ./$PROJECT/Protos/mt5mng.proto -l go -o ./golib

Put you credentials for mt4 server

Use commands to run the example:

go build main.go
go run main.go

package main

import (
    mt5mng ""

func main() {
    config := &tls.Config{
        InsecureSkipVerify: false,
    channel, channelError := grpc.Dial("", grpc.WithTransportCredentials(credentials.NewTLS(config)))
    if channelError != nil {
        log.Fatalf("failed to connect: %v", channelError)
    defer channel.Close()

    mainClient := mt5mng.NewMainClient(channel)
    var connectResponse, connectionError = mainClient.Connect(context.Background(), &mt5mng.ConnectRequest{
        Server:   "",
        Password: "",
        User:     1,
    if connectionError != nil {
        log.Fatalf("gRPC protocol error: %v", connectionError)
    if connectResponse.Error != nil {
        log.Fatalf("Server error: %v", connectResponse.Error.Message)
    id := connectResponse.Result

    var accountsResponse, accountsError = mainClient.AccountsList(context.Background(), &mt5mng.AccountsRequest{Id: id})
    if accountsError != nil {
        log.Fatalf("gRPC protocol error: %v", accountsError)
    if accountsResponse.Error != nil {
        log.Fatalf("Server error: %v", accountsResponse.Error.Message)

    for _, accountId := range accountsResponse.Result {
        var accountResponse, accountError = mainClient.AccountDetails(context.Background(), &mt5mng.AccountDetailsRequest{
            Id:    id,
            Login: accountId,
        if accountError != nil {
            log.Fatalf("gRPC protocol error: %v", accountError)
        if accountResponse.Error != nil {
            log.Fatalf("Server error: %v", accountResponse.Error.Message)

Leave a Reply

Your email address will not be published. Required fields are marked *