Configuration

The SDK works with only a secretKey, but you can configure request behavior for production services.

const kyshi = new Kyshi({
  secretKey: process.env.KYSHI_SECRET_KEY!,
  environment: 'test',
  timeoutMs: 30_000,
  maxRetries: 2,
  retryDelayMs: 250,
});

Options

OptionTypeDescription
secretKeystringRequired Kyshi secret key.
environmenttest or liveSDK environment label. Defaults to test.
baseUrlstringOptional custom API base URL.
timeoutMsnumberRequest timeout in milliseconds. Defaults to 30000.
maxRetriesnumberDefault retry count for retryable requests. Defaults to 2.
retryDelayMsnumberInitial retry delay in milliseconds. Defaults to 250.
fetchfunctionOptional custom Fetch implementation.

Idempotency

For operations that create money movement or payment state, send stable references from your system.

await kyshi.transactions.initialize({
  email: '[email protected]',
  localCurrency: 'NGN',
  amount: 1000,
  reference: 'ORDER-10001',
});

The SDK uses known references as idempotency keys for supported methods. You can also pass an explicit idempotency key through request options:

await kyshi.client.post(
  'transfer',
  {
    beneficiaryId: 'beneficiary-id',
    currency: 'NGN',
    amount: 1000,
    narration: 'Vendor payout',
  },
  {
    idempotencyKey: 'PAYOUT-10001',
  },
);

Low-Level Client

Use the low-level client for supported HTTP methods when you need a route that is not yet wrapped by a resource method.

const result = await kyshi.client.get('transactions/history', {
  query: { page: 1, limit: 10 },
});

The client handles authentication, JSON parsing, query serialization, response unwrapping, request timeouts, and retries for safe requests.