npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

leja-recharge-node-sdk

v0.1.2

Published

Node.js SDK for Leja Recharge API

Readme

Leja Recharge Node.js SDK

A Node.js SDK for interacting with the Leja Recharge API.

npm version License: MIT

Documentation

Take a look at the API docs here

Installation

npm install leja-recharge-node-sdk
# or
yarn add leja-recharge-node-sdk

Authentication

The SDK uses Basic Authentication with your Client ID and API key (Both found on your dashboard). You'll need both credentials to initialize the client:

import { LejaRechargeClient } from 'leja-recharge-node-sdk';

// Initialize the client with your credentials
const client = new LejaRechargeClient({
  clientId: 'your_client_id',
  apiKey: 'your_api_key'
});

Quick Start

import { LejaRechargeClient, AirtimeRecipient } from 'leja-recharge-node-sdk';

// Initialize the client with your credentials
const client = new LejaRechargeClient({
  clientId: 'your_client_id',
  apiKey: 'your_api_key'
});

// Purchase airtime
const recipients: AirtimeRecipient[] = [
  {
    phoneNumber: '+254712345678',
    amount: 10.0,
    country: 'KE'
  }
];

const transaction = await client.purchaseAirtime(
  '+254712345678',
  recipients,
  true,
  'https://your-callback-url.com/webhook'
);

// Get transaction details
const transactionDetails = await client.getTransaction(transaction.trackingId);

// Get account balance
const balance = await client.getBalance();

// Get supported countries
const countries = await client.getCountries(1, 20);

Features

  • Purchase airtime for multiple recipients
  • Get transaction details
  • Check account balance
  • List supported countries
  • Async support for airtime purchases
  • Webhook callbacks for async transactions
  • Comprehensive error handling
  • TypeScript support with type definitions
  • Request and response validation using Zod

Error Handling

The SDK provides custom exceptions for different error scenarios:

import {
  LejaRechargeError,
  AuthenticationError,
  ValidationError,
  APIError,
  NetworkError
} from 'leja-recharge-node-sdk';

try {
  const client = new LejaRechargeClient({
    clientId: 'invalid_client_id',
    apiKey: 'invalid_api_key'
  });
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error(`Authentication failed: ${error.message}`);
  }
}

Exception Types

  • LejaRechargeError: Base exception class for all SDK errors
  • AuthenticationError: Raised when authentication fails
  • ValidationError: Raised when input validation fails
  • APIError: Raised when the API returns an error response
  • NetworkError: Raised when network communication fails

TypeScript Support

The SDK is written in TypeScript and provides type definitions for all models:

import {
  AirtimeRecipient,
  TransactionResponse,
  BalanceResponse,
  CountryResponse,
  PaginatedResponse
} from 'leja-recharge-node-sdk';

Development

  1. Clone the repository

    git clone https://github.com/Asilimia/leja-recharge-node-sdk.git
    cd leja-recharge-node-sdk
  2. Install dependencies:

    npm install
    # or
    yarn install
  3. Build the project:

    npm run build
    # or
    yarn build
  4. Run tests:

    npm test
    # or
    yarn test

Testing

The test suite includes:

  • Unit tests for all SDK functionality
  • Mock tests for API interactions
  • Model validation tests
  • Error handling tests
  • Integration test examples

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License