Skip to main content

Get started - eSIM SDK

Overview

The eSIM NodeJS SDK provides a comprehensive interface for managing eSIM profiles, packages, and related services. This SDK enables developers to:

  • Manage eSIM inventories and profiles
  • Create and manage data packages
  • Handle eSIM activation through QR codes
  • Configure Policy and Charging Rules (PCR) profiles
  • Query available countries and services
  • Monitor API health and status

The SDK is built on top of the eSIM REST API and provides type-safe methods for all available endpoints. All API calls require proper authentication using API keys and user IDs as described in the Authentication section below.

Base URL

All API endpoints are relative to:

https://esim.betatel.com/api/v1/esim

Installation

Install the eSIM SDK using npm:

npm install @betatelltd/esim-sdk

Or using yarn:

yarn add @betatelltd/esim-sdk

Authentication

Most endpoints require authentication using the following headers:

  • ApiKeyAuth: x-api-key header with your API key
  • ApiUserId: x-user-id header with your user ID

SDK Configuration

import { Configuration, CoreApi } from '@betatelltd/esim-sdk';

const config = new Configuration({
apiKey: (name: string) => {
if (name === 'x-api-key') return 'your-api-key';
if (name === 'x-user-id') return 'your-user-id';
return '';
},
basePath: 'your-base-url',
});

const coreApi = new CoreApi(config);

Replace your-api-key and your-user-id with your actual credentials for secure access.

Error Handling

All SDK methods may throw errors. Always wrap API calls in try-catch blocks:

try {
const { status, data } = await apiInstance.getCountries();
// Handle success
} catch (error) {
if (error.response) {
// API returned error response
console.error(`Error ${error.response.status}: ${error.response.data}`);
} else {
// Network or other error
console.error('Request failed:', error.message);
}
}