Skip to content

SDKs & Client Libraries

Production-ready SDKs with full type safety, automatic retries, circuit breakers, and gRPC streaming support.

Installation

npm install @spooled/sdk

Quick Start

Create a job with any SDK (or cURL):

curl -X POST https://api.spooled.cloud/api/v1/jobs \
  -H "Authorization: Bearer sp_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "queue_name": "my-queue",
    "payload": {
      "event": "user.created",
      "user_id": "usr_123",
      "email": "alice@example.com"
    },
    "idempotency_key": "user-created-usr_123"
  }'

Node.js / TypeScript SDK

✅ Production Ready

The Node.js SDK is fully featured and ready for production use. Includes comprehensive test coverage and type-safe APIs.

Features

  • Full TypeScript Support - Comprehensive type definitions
  • ESM & CommonJS - Works in any Node.js project
  • Automatic Retries - Exponential backoff with jitter
  • Circuit Breaker - Fault tolerance built-in
  • gRPC Streaming - High-performance workers (lower latency than HTTP)
  • Worker Runtime - Built-in job processing
  • Workflow DAGs - Complex job dependencies
  • Realtime Events - WebSocket & SSE support
  • Plan Limits - Automatic enforcement

Core Resources

Jobs

Create, list, claim, complete, fail, retry, cancel

Workers

Register, heartbeat, deregister, SpooledWorker class

Queues

List, get, stats, pause, resume, delete, configure

Schedules

Cron schedules with timezone support

Workflows

DAG execution with job dependencies

DLQ

Dead letter queue operations

gRPC Client

High-performance gRPC client with automatic plan limit enforcement:

import { SpooledGrpcClient } from '@spooled/sdk';

const grpcClient = new SpooledGrpcClient({
  address: 'grpc.spooled.cloud:443',
  apiKey: process.env.SPOOLED_API_KEY!,
  useTls: true,
});

await grpcClient.waitForReady();

// Register worker
const { workerId } = await grpcClient.workers.register({
  queueName: 'emails',
  hostname: 'worker-1',
  maxConcurrency: 10,
});

// Dequeue jobs in batch
const { jobs } = await grpcClient.queue.dequeue({
  queueName: 'emails',
  workerId,
  batchSize: 10,
});

// Process and complete
for (const job of jobs) {
  await processJob(job);
  await grpcClient.queue.complete({
    jobId: job.id,
    workerId,
    result: { success: true },
  });
}

grpcClient.close();

⚡ Performance: gRPC is typically lower-latency than HTTP for high-throughput workers

Documentation


Python SDK

✅ Production Ready

The Python SDK is fully featured, type-safe, and ready for production use. Includes sync & async clients, worker runtime, gRPC support, and comprehensive error handling.

Features

  • Full Type Safety - Pydantic models with type hints
  • Sync & Async - Both synchronous and asynchronous clients
  • Worker Runtime - Decorator-based job processing
  • gRPC Support - High-performance gRPC client (optional)
  • Real-time Events - WebSocket and SSE support
  • Resilience - Retry logic with exponential backoff and circuit breaker
  • Production Ready - Comprehensive error handling and logging

Documentation


Go SDK

✅ Production Ready

The Go SDK is fully featured, idiomatic, and ready for production use. Includes comprehensive test coverage, type-safe APIs, gRPC support, and worker runtime.

Features

  • Idiomatic Go - Functional options pattern, context propagation
  • Full Type Safety - Strongly typed request/response structures
  • gRPC Support - High-performance gRPC client for workers
  • Worker Runtime - Built-in concurrent job processing
  • Automatic Retries - Exponential backoff with jitter
  • Circuit Breaker - Fault tolerance built-in
  • Real-time Events - WebSocket & SSE support
  • Workflows - DAG execution with job dependencies

Quick Start

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/spooled-cloud/spooled-sdk-go/spooled"
	"github.com/spooled-cloud/spooled-sdk-go/spooled/resources"
)

func ptr[T any](v T) *T { return &v }

func main() {
	client, err := spooled.NewClient(spooled.WithAPIKey(os.Getenv("SPOOLED_API_KEY")))
	if err != nil {
		panic(err)
	}

	resp, err := client.Jobs().Create(context.Background(), &resources.CreateJobRequest{
		QueueName:      "my-queue",
		Payload:        map[string]any{"key": "value"},
		IdempotencyKey: ptr("unique-key"),
		MaxRetries:     ptr(3),
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("Created job: %s\n", resp.ID)
}

Documentation


PHP SDK

✅ Production Ready

The PHP SDK is fully featured, type-safe, and ready for production use. Requires PHP 8.2+ with full readonly DTO support, worker runtime, optional gRPC, and comprehensive error handling.

Features

  • PHP 8.2+ - Modern PHP with readonly properties and type hints
  • PSR-Compliant - Works with any PSR-compatible HTTP client and logger
  • Worker Runtime - Built-in job processing with concurrency control
  • gRPC Support - Optional high-performance gRPC client
  • Real-time Events - WebSocket and SSE support
  • Resilience - Retry logic with exponential backoff and circuit breaker
  • Framework Agnostic - Works with Laravel, Symfony, or vanilla PHP
  • Webhook Ingestion - Validate GitHub, Stripe, and custom webhooks

Quick Start

<?php

use Spooled\SpooledClient;
use Spooled\Config\ClientOptions;

$client = new SpooledClient(new ClientOptions(
    apiKey: getenv('SPOOLED_API_KEY'),
));

$userId = 'usr_123';

// Create a job
$job = $client->jobs->create([
    'queue' => 'email-notifications',
    'payload' => [
        'to' => 'user@example.com',
        'subject' => 'Welcome!',
        'template' => 'welcome',
    ],
    'idempotencyKey' => "welcome-{$userId}",
    'maxRetries' => 5,
]);

echo "Created job: {$job->id}\n";

Documentation


Plan Limits

All SDKs automatically enforce tier-based limits:

Tier Active Jobs Daily Jobs Queues Workers
Free 10 1,000 5 3
Starter 100 100,000 25 25
Enterprise Unlimited Unlimited Unlimited Unlimited

See the Limits documentation for more details.

Dashboard Tip

📍 Account → Usage

What to look for:

  • Current usage vs plan limits
  • Jobs created today
  • Active workers and queues

Actions:

  • Upgrade plan if approaching limits
  • Monitor usage trends

Need help?