kejayangu-node-sdk
v1.0.2
Published
The official Node.js SDK for the KejaYangu Kenya Real Estate Platform API
Downloads
23
Maintainers
Readme
KejaYangu Node SDK
The official Node.js / TypeScript SDK for the KejaYangu Trust API.
This SDK allows developers to easily integrate KejaYangu's B2B Trust Infrastructure—verifying real estate agents, validating property authenticity, and running user KYC—directly into their own applications with zero manual HTTP configuration.
📦 Installation
Install the package via NPM or Yarn:
npm install kejayangu
# or
yarn add kejayangu🚀 Quick Start
Initialize the SDK using your Secret or Test API Key.
import { KejaYangu } from 'kejayangu';
// Initialize the client
const keja = new KejaYangu('kj_test_847392847...', {
environment: 'sandbox' // Use 'live' for production
});
async function run() {
try {
const result = await keja.trust.verifyAgent('EARB-12345');
console.log('Agent Status:', result.status);
} catch (error) {
console.error('API Error:', error.message);
}
}
run();🛡️ Trust Infrastructure API
The keja.trust service provides three primary methods for mitigating fraud in the Kenyan Real Estate sector.
1. Verify Estate Agent (verifyAgent)
Cross-references an agent's license number against the Estate Agents Registration Board (EARB) database.
const result = await keja.trust.verifyAgent('EARB-12345');
/* Response:
{
"status": "verified",
"last_checked": "2026-02-27T18:55:15.648Z",
"provider": "EARB"
}
*/2. Verify Property Authenticity (verifyProperty)
Validates Land Reference (LR) numbers to ensure the property belongs to the claimed owner and isn't subject to ongoing disputes.
const result = await keja.trust.verifyProperty({
lrNumber: 'LR-NBI-99482',
location: 'Kilimani, Nairobi' // Optional
});
/* Response:
{
"status": "pending_verification",
"message": "Verification requested for LR No: LR-NBI-99482"
}
*/3. User Identity Check (kycUser)
Performs a KYC flow on a user, checking for SIM Swaps and matching National ID credentials.
const result = await keja.trust.kycUser({
phoneNumber: '+254712345678',
idNumber: '34567890'
});
/* Response:
{
"status": "kyc_initiated",
"message": "KYC process has been queued.",
"reference_id": "live_kyc_1709062345"
}
*/❌ Error Handling
The KejaYangu API returns programmatic, Stripe-grade error schemas. If a request fails (e.g., due to an invalid API key, missing parameters, or hitting a rate limit), the SDK throws the parsed JSON error directly.
try {
await keja.trust.verifyAgent('');
} catch (error) {
console.log(error.type); // "invalid_request_error"
console.log(error.code); // "missing_parameter"
console.log(error.message); // "Missing required parameter: license_number"
console.log(error.param); // "license_number"
// A link to our developer docs explaining this exact error!
console.log(error.doc_url); // "https://docs.kejayangu.co.ke/errors/missing_parameter"
}📘 Typescript Support
This SDK is written entirely in TypeScript and exports all relevant types and interfaces. Modern IDEs like VS Code will provide full autocomplete hints for every method and response object.
import { KejaYangu, VerificationResult } from 'kejayangu';
// `result` will be strictly typed as `VerificationResult`
const result: VerificationResult = await keja.trust.verifyAgent('EARB-123');🔒 Security
Never expose your live API Key (kj_live_...) in client-side code like React, React Native, or Vue. This SDK is intended for backend Node.js environments (Express, Next.js API Routes, Serverless Functions).
If you need to test the frontend integration, safely use your sandbox key (kj_test_...) or proxy the requests through your own backend.
