Developers: SDK Usage
Package
eshop-os-sdk
This package is published on npm and maintained by the eshopOS team.
Docs: https://docs.dukalinks.co.ke
Install
npm install eshop-os-sdk
# or
bun add eshop-os-sdk
# or
pnpm add eshop-os-sdk
If you want automatic preview updates from the latest canary release, install the next channel:
npm install eshop-os-sdk@next
Minimal Working Example (API Key)
Base URL defaults to production. For local dev, set ESHOPOS_PUBLIC_API_BASE_URL to http://localhost:8080.
import { EshopOSPublicClient } from 'eshop-os-sdk';
const client = new EshopOSPublicClient({
baseUrl: process.env.ESHOPOS_PUBLIC_API_BASE_URL ?? 'https://eshopos.dukalinks.co.ke',
apiKey: process.env.ESHOPOS_PUBLISHABLE_KEY,
mode: 'test',
});
const countries = await client.listSupportedPaymentCountries();
console.log(countries.data);
Minimal Working Example (OAuth Token)
import { EshopOSPublicClient } from 'eshop-os-sdk';
const client = new EshopOSPublicClient({
baseUrl: process.env.ESHOPOS_PUBLIC_API_BASE_URL ?? 'https://eshopos.dukalinks.co.ke',
accessToken: process.env.ESHOPOS_OAUTH_ACCESS_TOKEN,
mode: 'live',
});
const merchant = await client.resolveMerchantByHandle('merchant-handle');
console.log(merchant.data);
Use one auth input at a time:
apiKeyfor key-based integrationsaccessTokenfor OAuth app integrations
Error Handling Example
import { EshopOSPublicClient, PublicApiError } from 'eshop-os-sdk';
const client = new EshopOSPublicClient({
baseUrl: process.env.ESHOPOS_PUBLIC_API_BASE_URL ?? 'https://eshopos.dukalinks.co.ke',
apiKey: process.env.ESHOPOS_PUBLISHABLE_KEY,
mode: 'test',
});
try {
await client.listSupportedPaymentCountries();
} catch (error) {
if (error instanceof PublicApiError) {
console.error({
status: error.status,
code: error.code,
requestId: error.requestId,
details: error.details,
});
}
}