@phoenix-baas/sdk
v0.2.1
Published
Official Node.js SDK for the Phoenix BaaS platform
Maintainers
Readme
@phoenix-baas/sdk
Official Node.js / TypeScript SDK for the Phoenix BaaS platform — AI-powered banking infrastructure for Africa.
Installation
npm install @phoenix-baas/sdk
# or
yarn add @phoenix-baas/sdkRequires Node.js 18+. Zero dependencies — uses the native fetch API.
Quickstart
import { PhoenixClient } from "@phoenix-baas/sdk";
const client = new PhoenixClient({ apiKey: "sk_test_..." });
// 1. Create a customer
const customer = await client.customers.create({
full_name: "Amara Okafor",
email: "[email protected]",
phone: "+2348012345678",
});
// 2. Score with Eye (AI credit engine)
const decision = await client.eye.score({
customer_id: customer.id,
requested_amount: 500_000_00, // ₦500,000 in kobo
tenor_months: 12,
open_banking: {
avg_monthly_inflow: 200_000_00,
salary_detected: true,
bounce_count: 0,
},
});
console.log(decision.outcome); // "approve" | "refer" | "decline"
console.log(decision.pd); // e.g. 0.042
console.log(decision.reasons[0].human_readable); // "Strong salary history"
// 3. Apply for a loan (Rise)
if (decision.outcome === "approve") {
const loan = await client.loans.apply({
customer_id: customer.id,
requested_amount: 500_000_00,
tenor_months: 12,
eye_application_id: decision.application_id,
});
const disbursed = await client.loans.disburse(loan.id, "TXN_001");
console.log(disbursed.schedule[0].due_date);
}Resources
| Resource | Methods |
|---|---|
| client.customers | create, get, update, list |
| client.eye | score, getDecision, fraudCheck, categorise |
| client.loans | apply, get, disburse, recordPayment, list |
| client.accounts | open, get, transfer, transactions, list |
| client.shield | listAlerts, resolveAlert |
Configuration
const client = new PhoenixClient({
apiKey: "sk_test_...",
baseUrl: "https://api.getphoenix.io", // default
eyeUrl: "https://eye.getphoenix.io", // default
timeoutMs: 30_000, // default 30s
});Error handling
import { PhoenixClient, AuthError, NotFoundError, PhoenixError } from "@phoenix-baas/sdk";
try {
const customer = await client.customers.get("cust_nonexistent");
} catch (e) {
if (e instanceof NotFoundError) {
console.log("Customer not found");
} else if (e instanceof AuthError) {
console.log("Invalid API key");
} else if (e instanceof PhoenixError) {
console.log(`API error ${e.statusCode}: ${e.message}`);
}
}TypeScript
Full type definitions are included. All response objects are typed — no any in your codebase.
import type { ScoreDecision, Loan, Customer } from "@phoenix-baas/sdk";License
MIT
