Configuration Guide

Learn how to configure the SDK for your specific needs.

Basic Configuration

Initialize the client with your API key:

javascript
import { Client } from '@your-sdk/core'; const client = new Client({ apiKey: process.env.API_KEY });

Environment Variables

Store sensitive information in environment variables:

bash
# .env API_KEY=your_api_key_here ENVIRONMENT=production
javascript
const client = new Client({ apiKey: process.env.API_KEY, environment: process.env.ENVIRONMENT });

Advanced Configuration

Custom Base URL

javascript
const client = new Client({ apiKey: process.env.API_KEY, baseURL: 'https://api.custom-domain.com' });

Request Timeout

javascript
const client = new Client({ apiKey: process.env.API_KEY, timeout: 30000 // 30 seconds });

Retry Configuration

javascript
const client = new Client({ apiKey: process.env.API_KEY, retry: { maxAttempts: 3, delay: 1000 } });

TypeScript Configuration

For TypeScript projects, enable strict type checking:

json
{ "compilerOptions": { "strict": true, "esModuleInterop": true } }

Best Practices

  1. Never commit API keys to version control
  2. Use environment variables for configuration
  3. Enable logging in development
  4. Set appropriate timeouts for your use case
  1. Create environment-specific keys

    Issue separate API keys for staging and production. Rotate keys if someone leaves the team or a key is exposed.

  2. Load secrets from your host

    Use your platform’s secret manager or encrypted env variables—never hard-code keys in the client bundle.

  3. Tune timeouts and retries

    Set timeouts and retry budgets that match your upstream SLAs so transient errors recover without overwhelming the API.

  4. Verify before deploy

    Run integration tests against a sandbox project and confirm logging redacts sensitive fields.

Is this page helpful?