gRPC / Protobuf

All Mnemonic APIs are implemented as a gRPC service by default.

A language-agnostic specification for this API is defined using Protocol Buffers (v3), which can be used to generate client libraries in a variety of programming languages.

The protobuf source files can be found in Mnemonic public Buf repository.

Assets & Libraries

Mnemonic uses buf to generate and manage client libraries and documentation based on the protobuf specification. For now only Go client implementation is provided out of the box and can simply be used as a Go module in your application. If you are implementing your application in Go we highly recommend using provided Mnemonic assets as they are properly versioned, packaged and ensure backward compatibility.

By default, there are two types of assets provided: library/go and library/go-grpc.

The dependencies then can be installed from the command line:

gRPC

Copy
Copied
$ go get go.buf.build/grpc/go/mnemonic/mnemonicapis

Protobuf only

Copy
Copied
$ go get go.buf.build/protocolbuffers/go/mnemonic/mnemonicapis

Documentation

Explore our buf-generated docs.

Endpoints

The gRPC API endpoints are provided below:

Ethereum

ethereum.grpc.mnemonichq.com

Polygon

polygon.grpc.mnemonichq.com

Authentication

Authenticated requests must include a valid API key.

Note: In beta only one API key is issued per user. The key can be rotated if necessary upon request.

gRPC clients need to pass the key value as x-api-key in metadata with the method call.

Go

Copy
Copied
package main

import (
    "context"

    "google.golang.org/grpc/metadata"
)

func main() {
    // ... your grpc client configuration
    c := pb.NewGreeterClient(conn)

    ctx := context.Background()
    ctx = metadata.AppendToOutgoingContext(ctx, "x-api-key", "YOUR_API_KEY_HERE")

    r, err := c.SayHello(ctx, &pb.HelloRequest{Name: name})
}

Client configuration

Provide basic TLS configuration for the gRPC client connection.

Copy
Copied
creds := credentials.NewTLS(&tls.Config{})
conn, err = grpc.Dial(target, grpc.WithTransportCredentials(creds))