Skip to main content

Core API

Overview

The Core API provides essential functionalities for interacting with the eSIM service, including querying available countries.

getCountries

This method returns a paginated list of all available countries with their ISO codes, useful for location-based configurations and services.

Parameters

  • count (optional): Number of items to return (defaults to 100)
  • offset (optional): Number of items to skip (defaults to 0)

Return Type:

  • GetCountriesResponse

Authorization:

  • Requires ApiUserId and ApiKeyAuth

Example

Here's how to use the Core API to fetch countries:

import { CoreApi, Configuration } 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: 'base-url',
});
const apiInstance = new CoreApi(configuration);

let count = 100; // Number of items to return per page (optional)
let offset = 0; // Number of items to skip (optional)

const { status, data } = await apiInstance.getCountries(count, offset);

Response Codes

  • 200: Successfully retrieved countries list.
  • 400: Bad Request - Invalid parameters.
  • 401: Unauthorized - Invalid API key or user ID.

GetCountriesResponse

The GetCountriesResponse object contains the following properties:

NameTypeDescriptionNotes
totalnumberTotal number of countries available in the system[default to undefined]
countnumberNumber of countries returned in this response[default to undefined]
offsetnumberNumber of countries skipped[default to undefined]
countriesArrayArray of country objects[default to undefined]

Example

import { GetCountriesResponse } from '@betatelltd/esim-sdk';

const instance: GetCountriesResponse = {
total: 195,
count: 100,
offset: 0,
countries: [{ id: "US", name: "United States", iso_code: "US", country_code: "+1" }]
};