The Unimatrix Go SDK provides convenient access to integrate communication capabilities into your Go applications using the Unimatrix HTTP API. The SDK provides support for sending SMS, 2FA verification, and phone number lookup.
Before you begin, you need an Unimatrix account. If you don't have one yet, you can sign up for an Unimatrix account and get free credits to get you started.
Check out the documentation at unimtx.com/docs for a quick overview.
The Unimatrix SDK for Golang uses Go Modules, which is available from the public Github repository.
Run the following command to add uni-go-sdk
as a dependency to your project:
go get github.com/unimtx/uni-go-sdk
The following example shows how to use the Unimatrix Go SDK to interact with Unimatrix services.
package main
import (
"fmt"
"github.com/unimtx/uni-go-sdk"
)
func main() {
client := uni.NewClient()
}
or you can configure your credentials by environment variables:
export UNIMTX_ACCESS_KEY_ID=your_access_key_id
export UNIMTX_ACCESS_KEY_SECRET=your_access_key_secret
Send a text message to a single recipient.
package main
import (
"fmt"
"github.com/unimtx/uni-go-sdk"
)
func main() {
client := uni.NewClient()
res, err := client.Messages.Send(&uni.MessageSendParams{
To: "+1206880xxxx", // in E.164 format
Text: "Your verification code is 2048.",
})
if err != nil {
fmt.Println(err)
} else {
fmt.Println(res)
}
}
Send a one-time passcode (OTP) to a recipient. The following example will send a automatically generated verification code to the user.
package main
import (
"fmt"
"github.com/unimtx/uni-go-sdk"
)
func main() {
client := uni.NewClient()
res, err := client.Otp.Send(&uni.OtpSendParams{
To: "+1206880xxxx",
})
if err != nil {
fmt.Println(err)
} else {
fmt.Println(res)
}
}
Verify the one-time passcode (OTP) that a user provided. The following example will check whether the user-provided verification code is correct.
package main
import (
"fmt"
"github.com/unimtx/uni-go-sdk"
)
func main() {
client := uni.NewClient()
res, err := client.Otp.Verify(&uni.OtpVerifyParams{
To: "+1206880xxxx",
Code: "123456", // the code user provided
})
if err != nil {
fmt.Println(err)
} else {
fmt.Println(res.Valid)
}
}
To find Unimatrix SDKs in other programming languages, check out the list below:
This library is released under the MIT License.