The Turnkey Go SDK is an early tool for interacting with the Turnkey API.
There is much work to be done, but it is completly usable in its current form. The main thing to keep in mind is that each requests needs to be manually provided the client.Authenticator.
Example:
import (
"fmt"
"github.com/tkhq/go-sdk"
"github.com/tkhq/go-sdk/pkg/api/client/users"
"github.com/tkhq/go-sdk/pkg/api/models"
)
func ExampleClient() {
client, err := sdk.New("")
if err != nil {
return
}
p := users.NewPublicAPIServiceGetWhoamiParams().WithBody(&models.V1GetWhoamiRequest{
OrganizationID: client.DefaultOrganization(),
})
resp, err := client.V0().Users.PublicAPIServiceGetWhoami(p, client.Authenticator)
if err != nil {
return
}
fmt.Println(*resp.Payload.UserID)
}
In order to use the SDK, you will need an API key. When creating API keys, the private part never leaves the local system, but the public part must be registered to your Turnkey account.
The easiest way to manage your API keys is with the Turnkey CLI, but you can also create one using this SDK. See this example.
- Install go-swagger:
brew tap go-swagger/go-swagger
brew install go-swagger
- Update the swagger file in
inputs/
with a new one - Run
make generate