@varve/agency-sdks
Core Concepts

Retries and Runtime

Runtime support, retry behavior, and configuration shared by Varve agency SDKs.

The SDKs are designed to run in the places modern data products run: Node.js, browsers, Workers, edge functions, and scheduled jobs.

They use the standard fetch API and avoid Node-specific runtime dependencies. Node.js 18 or later is recommended because fetch is available globally.

Configuration shape

Most clients accept the same small configuration surface:

const client = new EurostatClient({
  baseUrl: 'https://ec.europa.eu/eurostat/api',
  maxRetries: 2,
  timeoutMs: 30_000,
});

baseUrl is useful for proxies, test fixtures, and controlled network environments. maxRetries controls transient retry attempts. Packages that support request timeouts expose timeoutMs.

Retry behavior

The clients retry transient failures such as rate limits and server-side interruptions. Exact behavior depends on the provider, but common cases include:

  • 429 rate limiting
  • 500 class agency errors
  • provider-specific transient states, such as StatCan WDS 409

When an upstream response includes Retry-After, clients that support it respect that signal.

Browser and edge use

The packages are isomorphic, but agency rules still apply. Some providers require API keys or impose CORS behavior that may make server-side access more appropriate.

For example, FRED requires an API key:

const client = new FredClient({
  apiKey: process.env.FRED_API_KEY,
});

Keep secrets on the server. If you need browser access to a keyed provider, proxy the request through your own backend.

Package shape

Each package ships TypeScript declarations and both ESM and CommonJS output. Zod is a peer dependency so applications that already use Zod do not get duplicate runtime copies.

On this page