A Node.js SDK written in Typescript for the Bitvora API and Webhooks.
npm install bitvora
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function sendBitcoin(): Promise<Withdrawal> {
const withdrawal = await bitvora.withdraw(
"[email protected]", // accepts on-chain, lightning invoice (payment request), lightning address, lnurl
10.0, // amount in your desired currency
Currency.USD // currency code
);
await withdrawal.isSettled(); // wait until the payment succeeds or fails, optional
return withdrawal;
}
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function createLightningAddress(): Promise<CreateLightningAddressResponse> {
let metadata = {
userID: "your-internal-user-id",
email: "[email protected]",
}; // optional metadata object to attach, accepts any valid key-value object
return bitvora.createLightningAddress(metadata); // also accepts null
}
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function createLightningInvoice(): Promise<LightningInvoice> {
let metadata = {
userID: "your-internal-user-id",
email: "[email protected]",
}; // optional metadata object to attach, accepts any valid key-value object
const invoice = await bitvora.createLightningInvoice(
50,
Currency.SATS,
"this is from the sdk",
3600,
metadata
);
await invoice.isSettled();
return invoice;
}
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function getBalance(): Promise<number> {
return bitvora.getBalance();
}
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function getTransactions(): Promise<GetTransactionsResponse> {
return bitvora.getTransactions();
}
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function getDeposit(): Promise<BitcoinDepositResponse> {
return bitvora.getDeposit("UUID-HERE");
}
import { BitvoraClient } from "bitvora";
const bitvora = BitvoraClient(API_KEY, BitcoinNetwork.MAINNET); // ["mainnet", "testnet", "signet"]
async function getWithdrawal(): Promise<BitcoinWithdrawalResponse> {
return bitvora.getWithdrawal("UUID-HERE");
}