Go Explore the Vonage APIs with Vonage Go SDK
Published on September 30, 2020

We're delighted to announce the immediate availability of the Vonage Go SDK. We love our developer communities, and it is our mission to make tools that make life easier for them. We know that more and more "gophers" are picking up this excellent Go stack and starting to use our APIs. You can do that from Go directly, but by creating an SDK for you all to try, we hope this will help you get it shipped sooner!

SDK Highlights

What are the advantages of using the Vonage Go SDK? First and foremost, it takes care of the detail for you. For strongly typed languages, such as Go, having defined data models and code that can send and receive the expected API data structures without you having to read the API docs is always a win.

The SDK depends on some generated code from our OpenAPI descriptions, which means that the SDK is accurate, matches the documentation, and can be updated more quickly when adding new features.

In addition to the package documentation, the SDK comes with an additional set of examples to show how to accomplish the core tasks in this library.

Quick Example: Send an SMS

I will never get tired of typing code and then having a message arrive on my phone! Sending an SMS is usually our quickstart example, and with the Go SDK, it's pretty straightforward:

package main

import (
	"fmt"
	"github.com/vonage/vonage-go-sdk"
)

func main() {
	auth := vonage.CreateAuthFromKeySecret(API_KEY, API_SECRET)
	smsClient := vonage.NewSMSClient(auth)
	response, _ := smsClient.Send("44777000000", "44777000777", "Hi from golang", vonage.SMSOpts{})

	if response.Messages[0].Status == "0" {
		fmt.Println("Message sent")
	}
}

We've also tried to bear in mind how the SDK will fit into the applications developers use. Sometimes, the SDK does everything you need, but at other times, it's important to be able to override some of the default library behaviour when the Real World (TM) gets in the way!

To that end, you can access small segments of functionality, such as getting a generated JWT to use with your requests:

package main

import (
	"fmt"

	"github.com/vonage/vonage-go-sdk/jwt"
)

func main() {
    privateKey, _ := ioutil.ReadFile(PATH_TO_PRIVATE_KEY_FILE)
    g := jwt.NewGenerator(APPLICATION_ID, privateKey)

    token, _ := g.GenerateToken()
    fmt.Println(token)
}

This could be useful if you need to change anything about the API calls you make.

Contributions Welcome

It's early days for the Go SDK, but we would love to hear from you if you take it for a spin.

Issues and pull requests on the GitHub repository are very welcome, of course, and we would also be super happy to hear what you build, so tweet at @VonageDev and let us know!

Lorna MitchellVonage Alumni

Lorna is a software engineer with an incurable blogging habit. She tries to tame words and code in equal measure.

Ready to start building?

Experience seamless connectivity, real-time messaging, and crystal-clear voice and video calls-all at your fingertips.

Subscribe to Our Developer Newsletter

Subscribe to our monthly newsletter to receive our latest updates on tutorials, releases, and events. No spam.