bivvydocs
Developers / API reference
BIVVY DOCS

A small, familiar API.

A focused bridge to the things your app needs.

Bivvy

MethodReturns
bivvy.connect(){ pubkey }
bivvy.disconnect()void
bivvy.destroy()void; removes the iframe and rejects pending requests

Bitcoin

MethodReturns
bivvy.bitcoin.getBalance(){ balance: string }
bivvy.bitcoin.getOnchainAddress()string
bivvy.bitcoin.getTransfers(limit?, offset?){ transfers, offset }
bivvy.bitcoin.createLightningInvoice({ amountSats, memo? }){ id, invoice, status }
bivvy.bitcoin.payLightningInvoice({ invoice, maxFeeSats? }){ id, status, paymentPreimage? }
bivvy.bitcoin.estimateOnchainFee({ address, amountSats, speed? }){ feeSats, expiresAt }
bivvy.bitcoin.sendOnchain({ address, amountSats, maxFeeSats, speed? }){ id, status, amountSats, feeSats, txid? }

Nostr

MethodReturns
bivvy.nostr.getPublicKey()string
bivvy.nostr.signEvent(event)signed Nostr event
bivvy.nostr.getRelays()relay preferences
bivvy.nostr.nip44.encrypt(pubkey, text)ciphertext
bivvy.nostr.nip44.decrypt(pubkey, ciphertext)plaintext
bivvy.nostr.nip04.encrypt(pubkey, text)ciphertext (legacy)
bivvy.nostr.nip04.decrypt(pubkey, ciphertext)plaintext (legacy)

Errors

Requests reject with a BivvyError containing a code and message. Handle errors without assuming a payment failed before submission.

JavaScript
try {
  await bivvy.nostr.getPublicKey();
} catch (error) {
  if (error.code === "BUSY") {
    // Finish the current request first.
  } else {
    showError(error.message);
  }
}
REJECTEDUser declined, closed the popup, or the operation failed.
INVALID_REQUESTUnknown method, invalid parameters, or prohibited values.
BUSYAnother request is being reviewed or executed.
REPLAYThe request ID was already received.
TIMEOUTNo response within 3 minutes; payment outcome may be unknown.
UNAVAILABLEBivvy could not load within 20 seconds.
DISCONNECTEDThe iframe was removed and pending requests were cancelled.
PAYMENT_PENDINGWebLN has no settled payment preimage yet.

Events and globals

The script dispatches bivvy:ready after creating window.bivvy. It installs window.nostr and window.webln only when those globals are absent. Requests mount the iframe lazily.

Amounts and limits

Satoshi inputs must be positive safe integers. Bivvy returns balances as decimal strings to avoid precision loss. The default Lightning fee cap is 100 sats. Supply a smaller explicit cap if your app requires one.

Made to be understood. Built to be yours.View the source