Getting Started with Go

This simple program demonstrates how easy it is to query our GraphQL API over gRPC. It:

  1. Uses our go client to retrieve a JWT
  2. Creates a gRPC connection with credentials
  3. Instantiates a GraphQL client
  4. Executes a simple GraphQL query
  5. Prints the response

Before You Begin

  1. Visit golang gRPC prerequisites
  2. Then make sure that protoc is accessible from your $PATH

import (
    pbgraphql "main/graphql"


func main() {
    token, _, err := eosws.Auth(os.Args[1])
    if err != nil {
        log.Fatalf("cannot get auth token: %s", err)

    credential := oauth.NewOauthAccess(&oauth2.Token{AccessToken: token, TokenType: "Bearer"})
    connection, err := grpc.Dial(
        grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(nil, "")),
    graphqlClient := pbgraphql.NewGraphQLClient(connection)

    q := `subscription  {
       searchTransactionsForward(query: "action:transfer", limit:10) {
         trace { matchingActions { receiver account name json }}}}`

    executionClient, err := graphqlClient.Execute(
        &pbgraphql.Request{Query: q},
    if err != nil {
        log.Fatalf("execution error: %s", err)

    for {
        response, err := executionClient.Recv()
        if err != nil {
            if err != io.EOF {
                fmt.Println("No more result available")

            log.Fatalf("reception error: %s", err)

        fmt.Println("Received response:", response.Data)

Get the Source Code

git clone
git clone

Generate graphql.pb.go

protoc -I graphql-over-grpc graphql/graphql.proto --go_out=plugins=grpc:./example-graphql-grpc

Get the Project Dependencies

cd example-graphql-grpc
go mod init main
go mod tidy

Run it

First, you must visit to get your API key. Then, you can proceed to run the following command

go run main.go YOUR_API_KEY_HERE