Introduction
S2 provides a REST API for managing durable streams and streaming data. The API is designed for:- Real-time streaming - Continuous reads and writes with SSE and S2S protocols
- Durability - All data is persisted to object storage before acknowledgment
- Scalability - Serverless architecture with automatic scaling
- Simplicity - Clean REST endpoints with JSON and Protocol Buffer support
Base URLs
S2 uses two different endpoint types:Account Endpoint
Used for account-level operations like managing basins and access tokens.Basin Endpoint
Used for stream operations within a specific basin. Each basin can have its own endpoint.API Versioning
All API endpoints are versioned under the/v1 path prefix:
The current API version is
v1. Future versions will be introduced under new path prefixes while maintaining backwards compatibility.Content Types
The S2 API supports multiple content types:Request/Response Formats
JSON Format
Default format for most REST endpoints:Protocol Buffers
For high-performance scenarios, use Protocol Buffers:Core Resources
The S2 API is organized around three main resources:Basins
A basin is a namespace for streams with shared configuration. Key operations:- Create basin
- List basins
- Configure basin settings
- Delete basin
Streams
A stream is a durable, ordered log of records within a basin. Key operations:- Create stream
- List streams
- Configure stream settings
- Delete stream
- Check tail position
Records
Records are the data items stored in streams. Key operations:- Append records (write)
- Read records (query historical or stream real-time)
- Trim records (delete old data)
Streaming Protocols
S2 supports three methods for reading streams:1. Unary Read (REST)
Simple HTTP request/response for batch reads:2. Server-Sent Events (SSE)
Real-time streaming using standard SSE protocol:3. S2S Streaming Sessions
Bi-directional streaming protocol optimized for S2:- Binary framed protocol with compression (gzip, zstd)
- Supports streaming reads and writes
- Lower latency and higher throughput than SSE
Rate Limits
S2 automatically scales to handle your workload. Rate limits are applied per account to ensure fair usage.
Error Handling
The API uses standard HTTP status codes:Error Response Format
Error responses include a JSON body with details:Idempotency
For write operations, use thes2-request-token header to ensure idempotent retries:
The request token must be unique per operation. If the same token is used for an identical request, S2 will return the original response without re-executing the operation.
Compression
S2 supports compression for both requests and responses: Request compression:Next Steps
Authentication
Learn how to authenticate API requests with access tokens
S2S Protocol
Understand the S2S streaming session protocol