The REST API works from any language that can send HTTPS requests. The official libraries save you the
boilerplate: typed objects, automatic idempotency keys, safe retries, webhook verification and a polished payment
widget for the browser.
Library
Package
Runs on
Use it for
Node.js
@yusr/node
Node.js 18+ (ESM and CommonJS)
Your server: transactions, webhooks, events, settlements
Browser
@yusr/js
Browsers (and Node)
Your checkout page: live status and the payment widget
@yusr/js keeps your checkout page in sync with the payment as it happens, using short-lived client tokens so
your secret key never reaches the browser.
Create the transaction and a client token on your server, then render the widget. It shows the amount, account
number with a copy button, bank, account name, an expiry countdown and a live, screen-reader-friendly status.
HTML
<div id="pay"></div><script src="https://unpkg.com/@yusr/js@1/dist/yusr.global.js"></script><script> // transactionId, clientToken and transaction come from your server const { transactionId, clientToken, transaction } = window.CHECKOUT; Yusr.renderPaymentWidget('#pay', { clientToken, transactionId, transaction, baseUrl: 'https://api.yusr.ng', onPaid: () => (window.location.href = '/order/complete'), });</script>
import { subscribeToTransaction, formatNaira } from '@yusr/js';const sub = subscribeToTransaction({ clientToken, transactionId, baseUrl: 'https://api.yusr.ng', onState(txn) { // Current state on every (re)connect, then after each event. statusEl.textContent = txn.status; receivedEl.textContent = formatNaira(txn.amount_received); }, onError(err) { if (err.fatal) console.warn('Live updates stopped:', err.code); },});// When the customer leaves the page:sub.unsubscribe();
The root element also carries data-status (pending, paid, expired …) and data-tone (neutral, success,
warning, danger) for your own styles. See Realtime for a complete checkout page.
Responses are associative arrays that mirror the API's JSON. The client offers transactions, sandbox,
webhookEndpoints, events, settlements, balance and banks, with auto-pagination through
autoPagingIterator().
The API is described by an OpenAPI 3.1 document. Use it to generate a client in another language, import requests
into an API tool, or validate your mocks:
Shell
curl https://api.yusr.ng/v1/openapi.json
The API reference is rendered from the same document.