TypeScript SDK configuration
The Socifyr constructor takes one object. Only apiKey is required; the rest have defaults.
import { Socifyr } from '@socifyr/sdk'
const socifyr = new Socifyr({
apiKey: 'sk_...',
apiUrl: 'https://api.socifyr.com/api', // optional
timeout: 30_000, // optional
maxRetries: 2, // optional
})What options does the constructor accept?
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | API key starting with sk_ |
apiUrl | string | https://api.socifyr.com/api | Base URL. Trailing slashes are stripped |
timeout | number | 30000 | Per-request timeout in milliseconds |
maxRetries | number | 2 | Retries for transient failures on safe methods |
A missing apiKey throws a plain Error from the constructor.
The key belongs to exactly one workspace, and every request acts on it. To work in another workspace, create a second client with that workspace's key.
How do I point the SDK at a self-hosted or local API?
const socifyr = new Socifyr({
apiKey: process.env.SOCIFYR_API_KEY!,
apiUrl: 'http://localhost:8101/api',
})When does the SDK retry a request?
Retries apply to GET, HEAD and OPTIONS only. A POST, PATCH, PUT or DELETE is never re-sent automatically, so a post that times out is not published twice.
For those safe methods the SDK retries on:
- HTTP
408,500,502,503,504 - Timeouts (the request is aborted after
timeoutms) - Network failures
It does not retry other 4xx responses, including 429. A 429 throws RateLimitError with retryAfter (seconds, from the Retry-After header, default 60), and your code decides when to try again.
Backoff is min(1000 * 2^attempt, 10000) ms plus up to 20% jitter.
What happens when a request times out?
After retries are used up, the SDK throws SocifyrError with status: 408 and code: 'timeout'. A network failure throws SocifyrError with status: 0 and code: 'network_error'. A timed-out POST may still have reached the server, so check uploads.list() before re-sending.