Node SDK
kredo is the server kit. No dependencies, Node 18 or later.
npm install kredoSetup
import { Credits } from "kredo";
const credits = new Credits({ apiKey: process.env.CREDITS_API_KEY! });| Option | Default | Meaning |
|---|---|---|
apiKey | required | Your app's live (uc_live_) or test (uc_test_) key |
baseUrl | https://kredo-api.onrender.com | The network's API |
pagesUrl | https://kredo-omega.vercel.app | The hosted connect, buy and account pages |
retries | 2 | Extra tries after a network failure or rate limit. Writes are safe to retry: each carries a ref |
timeoutMs | 60000 | Per request. Long enough for a transaction to confirm |
Amounts are credits, as a number or an exact decimal string such as "0.5". Every amount the SDK returns is { credits, usd, units }.
Pricing
| Call | What it does |
|---|---|
prices() | Your price list |
setPrices(prices) | Replaces it. { price } per action, or { rate, unit } per unit |
setProfile(profile) | Your directory listing: { name?, description?, logoUrl?, website?, category? } |
quote({ action, quantity } | { credits }) | Price, network fee and what you earn |
Users
| Call | What it does |
|---|---|
connectUrl({ credits, returnTo, expiresInDays }) | Link to the connect page |
exchangeCode(code) | Swaps the one-time code for { user } |
user(address) | Balance, limit, whether they're connected, and what's spendable now |
session(user) | Everything the React kit renders, for a user or undefined |
buyUrl({ credits, returnTo }), accountUrl() | Links to the buy and account pages |
Moving credits
| Call | What it does |
|---|---|
charge({ user, action | credits, quantity, ref }) | Charges now |
hold({ user, action | credits, quantity, ref, ttlSeconds }) | Reserves credits, price locked |
capture(holdId, { credits }) | Charges all or part of a hold, returns the rest |
release(holdId) | Returns the whole hold |
refund({ user, credits, ref }) | Gives credits back, up to what they spent with you |
setExchangeRate(rate) | Light mode: our credits per one of yours, or null to turn it off |
convert({ user, credits, ref }) | Light mode: returns appCredits, how many of yours to add |
Every result includes txHash and an explorer link.
Money and reporting
| Call | What it does |
|---|---|
payout() | Pays unpaid earnings in USDT to your payout address |
activity() | Everything that happened in your app, newest first |
exportCsv() | The same, as CSV |
gas() | Transactions and WBT the network spent for you |
setWebhook(url) | Sets your endpoint and returns a new signing secret |
webhookDeliveries() | Recent deliveries and their status |
Webhooks and errors
verifyWebhook(rawBody, signatureHeader, secret) checks a delivery and returns the event. See Webhooks.
Failures throw CreditsError with code, status, isDeclined and isRetryable. See Errors.
Public data
CreditsNetwork needs no key:
import { CreditsNetwork } from "kredo";
const network = new CreditsNetwork({ baseUrl: process.env.CREDITS_API_URL });
await network.reserves(); // the vault's USDT against what it owes
await network.directory(); // every app, with prices and profileIt also has health() and stats().