Skip to main content
All Amplify SDK functions require initialization before use. Call initAmplifySDK() once at application startup.

Import

import { initAmplifySDK } from "@paxoslabs/amplify-sdk";

Usage

await initAmplifySDK("pxl_your_api_key");

Parameters

ParameterTypeRequiredDescription
apiKeystringYesYour Paxos Labs API key (format: pxl_...)
optionsSDKInitOptionsNoConfiguration options for telemetry and logging

SDKInitOptions

interface SDKInitOptions {
  /** Enable/disable PostHog telemetry (default: true) */
  telemetry?: boolean;

  /** Log level for SDK operations (default: LogLevel.ERROR) */
  logLevel?: LogLevel;

  /** Custom logger implementation */
  logger?: Logger;
}
OptionTypeDefaultDescription
telemetrybooleantrueEnable PostHog error tracking
logLevelLogLevelLogLevel.ERRORMinimum log level to output
loggerLoggerBuilt-in console loggerCustom logger implementation

Return Type

Promise<void>

Examples

import { initAmplifySDK } from "@paxoslabs/amplify-sdk";

await initAmplifySDK("pxl_your_api_key");

Behavior

  • Validates API key - Ensures key follows expected format (pxl_...)
  • Pre-populates cache - Fetches vaults and assets during initialization
  • Configures telemetry - Sets up PostHog if enabled
  • Configures logging - Sets log level and optional custom logger
  • Idempotent - Multiple calls with same key are no-ops
  • Re-initialization - Different key clears cache and reconfigures

Error Handling

try {
  await initAmplifySDK("pxl_your_api_key");
} catch (error) {
  if (error.code === "INVALID_API_KEY") {
    console.error("Invalid API key format");
  }
}
Error CodeDescriptionResolution
SDK_NOT_INITIALIZEDSDK used before initAmplifySDK()Call initAmplifySDK() first
INVALID_API_KEYAPI key validation failedCheck API key format