@resellos/resellos-sdk
v1.0.1
Published
The official Node.js SDK for Resellos Developer API
Downloads
170
Maintainers
Readme
Resellos Node.js SDK
The official Node.js SDK for the Resellos Developer API.
Installation
npm install resellos-sdkUsage
const { Resellos } = require("resellos-sdk");
// Initialize with your API Key, Store ID, and optional log level
const client = new Resellos("sk_live_...", {
storeId: "your-store-slug",
logLevel: "DEBUG", // Options: "DEBUG", "INFO", "NONE"
});
// Use built-in utilities
const requestId = client.utils.generateRequestId("vtPass");
const phone = "08031234567";
// New Utilities
const isValid = client.utils.isValidPhoneNumber(phone); // true
const network = client.utils.detectNetwork(phone); // "MTN"
const formattedPrice = client.utils.formatCurrency(5000); // "₦5,000"
/**
* Fetch Service Plans (Flexible & Paged)
*/
async function fetchPlans() {
const response = await client.getPlans({
type: "DATA",
network: "MTN",
search: "1GB",
limit: 10, // Results per page
page: 1, // Current page
status: "active", // Only active plans
});
console.log(response.data); // Array of plans
console.log(response.pagination); // { total: 45, page: 1, limit: 10, totalPages: 5 }
}
async function buyData() {
try {
const response = await client.purchase.data({
planId: "plan_123",
phoneNumber: phone,
requestId: requestId,
});
if (response.success) {
console.log("Success:", response.data.transactionId);
} else {
console.log("Error:", response.message);
}
} catch (err) {
console.error("SDK Error:", err);
}
}Features
- Logging: Built-in support for
DEBUGandINFOlevels with automatic masking of sensitive data (pins, keys). - Utilities:
ResellosUtilsfor generating compliant request IDs (VTpass, General) and formatting phone numbers. - Type-safe requests: Full IntelliSense support for all Resellos services.
- Automated environment detection: Automatically handles
sk_liveandsk_testkeys.
License
MIT
