DevelopersSDKs
Go SDK
Official Go client library for the RevKeen API
The RevKeen Go SDK is the official Go client for the RevKeen API, generated from the canonical OpenAPI specification through Fern.
Installation
go get github.com/revkeen/revkeen-goRequires Go 1.22 or later.
Initialize the client
package main
import (
"context"
revkeen "github.com/revkeen/revkeen-go"
"github.com/revkeen/revkeen-go/option"
)
func main() {
client := revkeen.NewClient(
option.WithAPIKey("rk_sandbox_your_api_key"),
)
// Use client...
}Use https://api.revkeen.com (default) in production and https://staging-api.revkeen.com for integration work:
client := revkeen.NewClient(
option.WithAPIKey("rk_sandbox_your_api_key"),
option.WithBaseURL("https://staging-api.revkeen.com"),
)Payments example
Create a hosted checkout session:
session, err := client.CheckoutSessions.Create(context.Background(), &revkeen.CheckoutSessionCreateRequest{
Mode: revkeen.CheckoutModePayment,
CustomerID: "cus_xxxxxxxx",
SuccessURL: "https://yourapp.com/success",
CancelURL: "https://yourapp.com/cancel",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(session.Data.URL)Subscriptions example
subscription, err := client.Subscriptions.Create(context.Background(), &revkeen.SubscriptionCreateRequest{
CustomerID: "cus_xxxxxxxx",
ProductID: "prod_xxxxxxxx",
TrialDays: revkeen.Int(14),
})
if err != nil {
log.Fatal(err)
}
fmt.Println(subscription.Data.ID)List customers
customers, err := client.Customers.List(context.Background(), &revkeen.CustomersListRequest{
Limit: revkeen.Int(10),
})
if err != nil {
log.Fatal(err)
}
for _, c := range customers.Data {
fmt.Println(c.Name, c.Email)
}Error handling
The SDK returns typed errors for API error responses:
_, err := client.Customers.Get(context.Background(), "cus_nonexistent")
if err != nil {
var apiErr *revkeen.APIError
if errors.As(err, &apiErr) {
fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Message)
}
}Package and source
- Package:
github.com/revkeen/revkeen-go - Source: github.com/revkeen/sdk-go
- Reference: API Reference
Compatibility
- Runtime: Go 1.22+
- Versioning: SDK releases are versioned independently from the REST API and generated from the Fern pipeline