Skip to content

TypeScript SDK configuration ​

The Socifyr constructor takes one object. Only apiKey is required; the rest have defaults.

typescript
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? ​

OptionTypeDefaultDescription
apiKeystringrequiredAPI key starting with sk_
apiUrlstringhttps://api.socifyr.com/apiBase URL. Trailing slashes are stripped
timeoutnumber30000Per-request timeout in milliseconds
maxRetriesnumber2Retries 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? ​

typescript
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 timeout ms)
  • 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.

Next steps ​