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 🙏

© 2025 – Pkg Stats / Ryan Hefner

prestmit-partners-api

v0.0.1

Published

Prestmit Partners API SDK

Readme

Prestmit Partners API Client

License: MIT npm version TypeScript

A TypeScript/JavaScript client library for interacting with the Prestmit Partners API. This SDK provides a convenient way to integrate with Prestmit's gift card trading, wallet management, and other services in your Node.js applications.

Features

  • Gift Card Trading: Buy and sell gift cards programmatically
  • Wallet Management: Check balances and transaction history
  • Bank Account Integration: Manage Naira and Cedis bank accounts
  • TypeScript Support: Full type definitions for better development experience
  • Promise-based API: Modern async/await support
  • Environment Support: Switch between production and sandbox environments

Installation

npm install prestmit-partners-api
# or
yarn add prestmit-partners-api

Prerequisites

  • Node.js 14.x or later
  • Prestmit Partner API credentials (API Key and Secret Key)

Usage

Basic Setup

import { PrestmitService } from "prestmit-partners-api";

// Initialize the service with your API credentials
const service = new PrestmitService({
  environment: "sandbox", // or 'production'
  apiKey: "your-api-key",
  secretKey: "your-secret-key",
});

Example: Fetching Gift Card Categories

async function getGiftCardCategories() {
  try {
    const categories = await service.fetchGiftcardCategories();
    console.log("Available categories:", categories);
    return categories;
  } catch (error) {
    console.error("Error fetching categories:", error);
    throw error;
  }
}

Example: Selling a Gift Card

async function sellGiftCard(cardDetails) {
  try {
    const result = await service.sellGiftcard({
      categoryID: cardDetails.categoryId,
      subCategoryID: cardDetails.subCategoryId,
      amount: cardDetails.amount,
      rate: cardDetails.rate,
      payoutMethod: cardDetails.payoutMethod,
      attachments: [cardDetails.receiptImagePath],
      // ... other required fields
    });
    console.log("Gift card sold successfully:", result);
    return result;
  } catch (error) {
    console.error("Error selling gift card:", error);
    throw error;
  }
}

API Reference

PrestmitService

The main class for interacting with the Prestmit API.

Constructor

new PrestmitService(options: PrestmitServiceOptions)

Options:

| Parameter | Type | Required | Description | | ----------- | ------------------------- | -------- | -------------------------------- | | environment | 'production' | 'sandbox' | Yes | The API environment to use | | apiKey | string | Yes | Your Prestmit Partner API key | | secretKey | string | Yes | Your Prestmit Partner secret key | | version | string | No | API version (default: 'v1') |

Available Methods

Gift Card Operations

  • fetchGiftcardCategories(): Get list of available gift card categories
  • fetchGiftcardSubcategories(params): Get subcategories for a category
  • fetchGiftcardOrderHistory(page): Get gift card order history
  • sellGiftcard(data): Sell a gift card

Wallet Operations

  • fetchFiatWalletDetails(wallet): Get fiat wallet details
  • fetchFiatWithdrawalHistory(page, wallet): Get withdrawal history
  • fetchWithdrawalReceipt(id): Get withdrawal receipt

Bank Account Operations

  • addNairaBankAccount(data): Add a Naira bank account
  • fetchNairaBankAccounts(page): List Naira bank accounts
  • removeNairaBankAccount(id): Remove a Naira bank account
  • addCedisBankAccount(data): Add a Cedis bank account
  • fetchCedisBankAccounts(page): List Cedis bank accounts
  • removeCedisBankAccount(id): Remove a Cedis bank account

Error Handling

The SDK throws PrestmitError for API-related errors. Always wrap API calls in try/catch blocks:

try {
  const result = await service.someMethod();
} catch (error) {
  console.error("API Error:", error.message);
  console.error("Status Code:", error.status);
  console.error("Error Details:", error.details);
}

Development

Prerequisites

  • Node.js 14+
  • npm or yarn

Setup

  1. Clone the repository
  2. Install dependencies:
    npm install
    # or
    yarn
  3. Create a .env file with your test credentials:
    SECRETE_KEY=your_test_secret_key
    API_KEY=your_test_api_key

Building

# Build the project
npm run build

# Watch for changes and rebuild
npm run build:watch

Testing

# Run tests
npm test

# Run in development mode with hot-reload
npm run dev

Running and Testing

Prerequisites

Before running the tests, make sure you have:

  • Node.js 14.x or later installed
  • Valid Prestmit Partner API credentials (API Key and Secret Key)
  • Environment variables set up (see Setup section)

Development Mode

To run in development mode with hot-reloading:

npm run dev

This will:

  1. Watch for file changes and rebuild automatically
  2. Run the test script from test-folder/script.ts
  3. Show API responses in the console

Running Specific Examples

The test-folder/script.ts contains various test cases. You can uncomment the specific API call you want to test:

// Example: Test service status
service.checkServiceStatus().then(console.log).catch(console.error);

// Example: Fetch gift card categories
// service.fetchGiftcardCategories()
//   .then(console.log)
//   .catch(console.error);

// Example: Fetch user profile
// service.fetchUserProfile()
//   .then(console.log)
//   .catch(console.error);

Testing with Different Environments

You can switch between environments by changing the environment parameter when initializing the service:

// For sandbox/testing environment
const sandboxService = new PrestmitService({
  environment: "sandbox",
  apiKey: "your_sandbox_api_key",
  secretKey: "your_sandbox_secret_key",
});

// For production environment
const productionService = new PrestmitService({
  environment: "production",
  apiKey: "your_production_api_key",
  secretKey: "your_production_secret_key",
});

Debugging

To enable debug logging, set the DEBUG environment variable:

DEBUG=prestmit:* npm run dev

This will show detailed request/response information in the console.

Common Issues

  1. Connection Issues:

    • Ensure you have a stable internet connection
    • Check if the Prestmit API is accessible from your network
    • Verify the API endpoint URLs in src/core/clients.ts
  2. Authentication Errors:

    • Double-check your API key and secret key
    • Ensure you're using the correct environment (sandbox vs production)
    • Verify that your account has the necessary permissions
  3. Rate Limiting:

    • The API might have rate limits
    • Add delays between requests if you encounter rate limit errors
  4. TypeScript Errors:

    • Run npm run build to check for TypeScript compilation errors
    • Make sure all required environment variables are properly typed

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, please contact Prestmit support at [email protected]

Acknowledgements

  • Prestmit for their API
  • All contributors who have helped improve this library