JavaScript/TypeScript SDK (Web & Telegram Mini Apps)
npm install @localcredit/sdk-js
# or
yarn add @localcredit/sdk-jsimport { Localcredit } from '@localcredit/sdk-js';
// Initialize with your API key (from developer dashboard)
const lc = new Localcredit({
apiKey: 'your_api_key_here',
environment: 'production' // or 'test' for sandbox
});// Get the user's signed proof (wallet signature)
const userProof = await lc.requestProof();
// This opens a wallet modal (TON Connect for Mini Apps, WalletConnect for web)
// Query the score
try {
const result = await lc.getScore(userProof);
console.log('Score:', result.score); // 82
console.log('Risk Tier:', result.riskTier); // 'Low'
console.log('Estimated Limit:', result.creditLimitUsd); // 5200
console.log('Breakdown:', result.breakdown);
} catch (error) {
if (error.code === 'NO_SCORE') {
// User has no Localcredit profile yet
await lc.redirectToOnboarding(); // seamless deep link
}
}Last updated