Overview
About the FluidStack Software Development Kit for TypeScript applications
FluidStack’s TypeScript SDK assists in developing applications in TypeScript using the FluidStack API.
It includes the following features:
- TypeScript interfaces for all request and response types
- Exception handling as subclasses of FluidStackApiError
- Ability to abort requests
- Runtime compatibility
- Ability to customize the fetch client
- Automatic retries with exponential backoff
- Configurable timeouts
Request and response types
The SDK exports all request and response types as TypeScript interfaces. Import them with the following namespace:
Exception handling
When the API returns a non-success status code (4xx or 5xx response), a subclass of FluidStackApiError
is thrown.
Abort requests
Abort requests at any point by passing in an abort signal.
Runtime compatibility
The SDK defaults to node-fetch
but will use the global fetch
client if present.
The SDK works in the following runtimes:
- Node.js 18+
- Vercel
- Cloudflare Workers
- Deno v1.25+
- Bun 1.0+
- React Native
Customize the fetch client
The SDK provides a way for your to customize the underlying HTTP client or fetch
function. If you’re running in an unsupported environment, this provides a way for you to break the glass and ensure that the SDK works.
Advanced
Retries
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retriable and the number of retry attempts has not grown larger than the configured retry limit (default: 2
).
A request is deemed retriable when any of the following HTTP status codes is returned:
- 408 (Timeout)
- 429 (Too Many Requests)
- 5XX (Internal Server Errors)
Use the maxRetries
request option to configure this behavior.
Timeouts
The SDK defaults to a 60-second timeout. Use the timeoutInSeconds
option to configure this behavior.