Go SDK for the Lob.com API. See the full Lob.com API documentation here.
First, you will need to first create an account at Lob.com and obtain your Test and Live API Keys.
Once you have created an account, you can access your API Keys from the Settings Panel.
lob-go can be installed through the go package manager:
$ go install github.com/lob/lob-go@latest
import (
"context"
"os"
lob "github.com/lob/lob-go"
)
ctx := context.Background()
ctx = context.WithValue(ctx, lob.ContextBasicAuth, lob.BasicAuth{UserName: os.Getenv("LOB_API_TEST_KEY")})
config := *lob.NewConfiguration()
apiClient := *lob.NewAPIClient(&config)
address := *lob.AddressEditable
address.SetName("Harry Zhang")
address.SetAddressLine1("2261 Market Street")
address.SetAddressCity("San Francisco")
address.SetAddressState("CA")
address.SetAddressZip("94114")
myAddress, _, createErr := apiClient.AddressesApi.Create(ctx).AddressEditable(address).Execute()
if createErr != nil {
log.Fatal(createErr)
}
myAddressFromApi, _, getErr := apiClient.AddressesApi.Get(ctx, *myAddress.Id).Execute()
if getErr != nil {
log.Fatal(getErr)
}
resp, _, deleteErr := suite.apiClient.AddressesApi.Delete(suite.ctx, *myAddress.Id).Execute()
if deleteErr != nil {
log.Fatal(deleteErr)
}
The full and comprehensive documentation of Lob's APIs is available here.
Our client libraries follow the Go release schedule. This package is compatible with all current stable versions of Go. If you are using a version that is not listed as an stable version we recommend that you switch to an actively supported LTS version.
Any support or compatability with versions of Go not listed as stable is on a best-efforts basis.
Integration tests run against a live deployment of the Lob API and require multiple valid API keys with access to specific features. As such, it is not expected that these tests will pass for every user in every environment.
To run integration tests:
go test -v ./__tests__
=======================
Copyright © 2022 Lob.com
Released under the MIT License, which can be found in the repository in LICENSE.txt.