SDK Overview
Official SDKs for programmatic access to Sparbz Cloud.
Available SDKs
| Language | Package | Status |
|---|---|---|
| Go | github.com/sparbz-cloud/sdk-go | Stable |
| TypeScript/JavaScript | @sparbzcloud/sdk | Stable |
| Python | Coming soon | Planned |
Installation
Go SDK
go get github.com/sparbz-cloud/sdk-go
TypeScript/JavaScript SDK
npm install @sparbzcloud/sdk
# or
bun add @sparbzcloud/sdk
# or
yarn add @sparbzcloud/sdk
Authentication
All SDKs support two authentication methods:
API Key
Best for CI/CD, automation, and server-side applications.
# Create an API key
szc apikey create my-sdk-key --scopes "read:*,write:*"
JWT Token
Best for user-facing applications with per-user authentication.
# Login to get a JWT token
szc auth login
szc auth token
Quick Start
Go
package main
import (
"context"
"fmt"
szc "github.com/sparbz-cloud/sdk-go"
)
func main() {
client := szc.NewClient(szc.WithAPIKey("szc_prod_..."))
// List databases
databases, err := client.Databases.List(context.Background())
if err != nil {
panic(err)
}
for _, db := range databases {
fmt.Printf("Database: %s (%s)\n", db.Name, db.Status)
}
}
TypeScript
import { SparbzCloud } from '@sparbzcloud/sdk';
const client = new SparbzCloud({
apiKey: 'szc_prod_...'
});
// List databases
const databases = await client.databases.list();
for (const db of databases) {
console.log(`Database: ${db.name} (${db.status})`);
}
Features
All SDKs provide:
- Full API Coverage: All Sparbz Cloud APIs are accessible
- Type Safety: Strongly typed for IDE autocompletion and compile-time checks
- Automatic Retries: Built-in retry logic for transient failures
- Pagination: Easy iteration over paginated results
- Error Handling: Structured errors with codes and details
- Logging: Configurable logging for debugging
Resources
Each SDK covers these resource types:
| Resource | Description |
|---|---|
| Databases | PostgreSQL, MySQL, MongoDB management |
| Namespaces | Kubernetes namespace provisioning |
| Storage | S3-compatible object storage |
| Registry | Container image registry |
| Kafka | Event streaming clusters |
| Vault | Secrets management |
| Stacks | Infrastructure as Code |
| Organizations | Team and member management |
| Billing | Usage and subscription info |
SDK vs CLI vs API
| Feature | SDK | CLI | API |
|---|---|---|---|
| Programmatic access | Yes | Limited | Yes |
| Type safety | Yes | No | No |
| Error handling | Structured | Exit codes | HTTP codes |
| Pagination | Automatic | Manual | Manual |
| Best for | Applications | Interactive use | Custom clients |
Rate Limits
API rate limits apply to SDK calls:
| Tier | Requests/minute | Requests/hour |
|---|---|---|
| Free | 60 | 1000 |
| Starter | 300 | 10000 |
| Pro | 1000 | 50000 |
| Enterprise | Custom | Custom |
SDKs automatically handle rate limit errors with exponential backoff.
Versioning
SDKs follow semantic versioning. Major versions may include breaking changes.
| SDK Version | API Version | Status |
|---|---|---|
| 1.x | v1 | Current |