@rewritetoday/rest is the low-level Rewrite API client for teams that need direct control over HTTP behavior.
Repository: github.com/RewriteToday/rest
When to use it
- You want explicit request/response control.
- You need custom retry or timeout behavior.
- You run in serverless/edge workers and need strict execution budgets.
- You already have your own abstraction layer and only need transport primitives.
Key capabilities
Route helpers
Use route builders from
@rewritetoday/types to avoid path construction mistakes.Retry controls
Handle transient failures and rate-limit responses with custom backoff logic.
Timeout strategy
Configure request timeout budgets that fit your runtime constraints.
Hooks
Add observability, custom logging, or request/response instrumentation.
Install
Basic example
Resilience example
Best practices
Keep API keys server-side only
Keep API keys server-side only
Never expose Rewrite API keys in frontend bundles, mobile binaries, or public repositories.
Use idempotency for write operations
Use idempotency for write operations
Include idempotency keys for create/send actions to avoid accidental duplicates during retries.
Align routes with @rewritetoday/types
Align routes with @rewritetoday/types
Pair
@rewritetoday/rest with @rewritetoday/types to keep paths and payload contracts synchronized.Add observability early
Add observability early
Log latency, status classes, and retry counts to detect saturation and provider instability.
Related docs
Types library
Route builders, shared contracts, and enums used together with REST.
Errors and retries
Retry guidance, timeout strategy, and failure-handling patterns.