JavaScript client

Configuration

Configure the client for API URLs, credentials, and custom fetch implementations.

type ClientOptions = {
  apiKey?: string;
  apiUrl: string;
  fetch?: typeof fetch;
  publishableKey?: string;
  readToken?: string;
};
const client = new GalleryClient({
  apiUrl: process.env.DEGALLERY_API_URL ?? 'https://api.degallery.mpotulo.com',
  apiKey: process.env.DEGALLERY_API_KEY,
  fetch: instrumentedFetch,
});

Credential precedence is apiKey, then readToken, then publishableKey. Use apiKey only in trusted server runtimes. Use readToken or publishableKey for client-safe reads according to the credential contract issued for your environment.

The client accepts a custom fetch implementation for testing, tracing, retries, or framework adapters. Keep retry policy bounded and do not retry validation or authorization failures blindly.