Go SDK
The official Go client library for the VoxBurst API.
Module: github.com/FortheanLabsProjects/voxburst-go
Requires: Go 1.21 or later
Features:
- Full API coverage — Posts, Accounts, Media, Analytics, Webhooks
- Automatic retries with exponential backoff and jitter
- Context support for cancellation and timeouts
- Idempotency keys to prevent duplicate operations
- Type-safe strongly typed requests and responses
- Pagination helpers for large result sets
Installation
go get github.com/FortheanLabsProjects/voxburst-goQuick Start
package main
import (
"context"
"fmt"
"log"
"os"
"time"
voxburst "github.com/FortheanLabsProjects/voxburst-go"
)
func main() {
client := voxburst.NewClient(os.Getenv("VOXBURST_API_KEY"))
ctx := context.Background()
scheduledFor := time.Now().Add(24 * time.Hour)
post, err := client.Posts.Create(ctx, voxburst.CreatePostParams{
Content: "Hello from Go! 🚀",
Platforms: []voxburst.Platform{voxburst.PlatformTwitter, voxburst.PlatformLinkedIn},
AccountIDs: []string{"acc_123", "acc_456"},
ScheduledFor: &scheduledFor,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Post created: %s\n", post.ID)
}Configuration
client := voxburst.NewClient(apiKey,
// Use staging environment
voxburst.WithStaging(),
// Or specify a custom base URL
voxburst.WithBaseURL("https://api-staging.voxburst.io/v1"),
// Custom HTTP client
voxburst.WithHTTPClient(myHTTPClient),
// Request timeout
voxburst.WithTimeout(30 * time.Second),
// Retry configuration
voxburst.WithMaxRetries(3),
voxburst.WithNoRetry(), // Disable retries entirely
// Debug logging
voxburst.WithDebug(true),
// Custom User-Agent
voxburst.WithUserAgent("my-app/1.0"),
)Resources
Posts
// Create a post
post, err := client.Posts.Create(ctx, voxburst.CreatePostParams{
Content: "Hello world!",
Platforms: []voxburst.Platform{voxburst.PlatformTwitter},
AccountIDs: []string{"acc_123"},
})
// Get a post
post, err := client.Posts.Get(ctx, "post_abc123")
// List posts (manual pagination)
result, err := client.Posts.List(ctx, &voxburst.ListPostsParams{
Status: voxburst.PostStatusScheduled,
Limit: 50,
})
// Auto-paginate through all posts
iter := client.Posts.ListAll(ctx, nil)
for iter.Next() {
fmt.Println(iter.Current().Content)
}
if err := iter.Err(); err != nil {
log.Fatal(err)
}
// Publish immediately
err = client.Posts.Publish(ctx, "post_abc123")Accounts
// List accounts
accounts, err := client.Accounts.List(ctx, nil)
// Initiate OAuth
authResult, err := client.Accounts.Connect(ctx, voxburst.PlatformTwitter, voxburst.ConnectParams{
RedirectURI: "https://yourapp.com/oauth/callback",
})
// Redirect user to authResult.AuthorizationURL
// Complete OAuth flow
account, err := client.Accounts.Callback(ctx, voxburst.PlatformTwitter, voxburst.CallbackParams{
Code: "oauth_code",
State: "oauth_state",
RedirectURI: "https://yourapp.com/oauth/callback",
})
// Disconnect
err = client.Accounts.Disconnect(ctx, "acc_123")Analytics
// Post metrics
metrics, err := client.Analytics.GetPostMetrics(ctx, "post_abc123")
// Account metrics
accountMetrics, err := client.Analytics.GetAccountMetrics(ctx, "acc_123",
&voxburst.AccountMetricsParams{
From: "2026-01-01",
To: "2026-01-31",
},
)
// Overview
overview, err := client.Analytics.GetOverview(ctx, nil)Supported Platforms
| Platform | Constant |
|---|---|
| Twitter/X | voxburst.PlatformTwitter |
voxburst.PlatformLinkedIn | |
voxburst.PlatformInstagram | |
voxburst.PlatformFacebook | |
| Bluesky | voxburst.PlatformBluesky |
| Threads | voxburst.PlatformThreads |
Error Handling
post, err := client.Posts.Create(ctx, params)
if err != nil {
switch {
case voxburst.IsNotFound(err):
fmt.Println("Resource not found")
case voxburst.IsRateLimited(err):
apiErr := voxburst.GetAPIError(err)
fmt.Printf("Rate limited. Status: %d\n", apiErr.StatusCode)
case voxburst.IsUnauthorized(err):
fmt.Println("Invalid API key")
case voxburst.IsValidationError(err):
apiErr := voxburst.GetAPIError(err)
fmt.Printf("Validation error: %s\n", apiErr.Message)
default:
log.Fatal(err)
}
}Error helper functions:
voxburst.IsNotFound(err)— 404 errorsvoxburst.IsRateLimited(err)— 429 errorsvoxburst.IsUnauthorized(err)— 401 errorsvoxburst.IsValidationError(err)— 400 errorsvoxburst.IsServerError(err)— 5xx errorsvoxburst.GetAPIError(err)— Access the full API error struct
The SDK automatically retries on rate limiting and server errors. Pass a context with a deadline to set an overall timeout for retried requests.
Examples
See the examples/ directory in the repository:
examples/create_post/main.go— Create and schedule a postexamples/connect_account/main.go— Connect a social account via OAuth
Last updated on