The Bitvora PHP SDK provides a simple way to interact with the Bitvora API for Bitcoin and Lightning transactions. This SDK supports functionality for handling transactions, deposits, withdrawals, and managing Lightning invoices and addresses.
You can install the SDK using Composer:
composer require bitvora/bitvora-php
To use the SDK, initialize the BitvoraClient
with the appropriate API key and Network
enum (Network::MAINNET
or Network::SIGNET
), and then call the methods available for each endpoint.
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$transactionsResponse = $client->getTransactions();
$transactions = $transactionsResponse->all(); // Returns an array of TransactionResponse objects
foreach ($transactions as $transaction) {
echo $transaction->getId();
echo $transaction->getAmountSats();
echo $transaction->getStatus();
echo $transaction->getRailType();
}
$transaction->getId();
$transaction->getAmountSats();
$transaction->getRecipient();
$transaction->getStatus();
$transaction->getRailType();
$transaction->isSettled();
$transaction->isPending();
$transaction->isFailed();
$transaction->isPendingApproval();
$transaction->isRejected();
$transaction->isDeposit();
$transaction->isWithdrawal();
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$withdrawalResponse = $client->getWithdrawal('withdrawal_id');
echo $withdrawalResponse->getId();
echo $withdrawalResponse->getAmountSats();
$withdrawal->getId();
$withdrawal->getAmountSats();
$withdrawal->getRecipient();
$withdrawal->getStatus();
$withdrawal->getRailType();
$withdrawal->isSettled();
$withdrawal->isPending();
$withdrawal->isFailed();
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$depositResponse = $client->getDeposit('deposit_id');
echo $depositResponse->getId();
echo $depositResponse->getAmountSats();
$deposit->getId();
$deposit->getAmountSats();
$deposit->getRecipient();
$deposit->getStatus();
$deposit->getRailType();
$deposit->isSettled();
$deposit->isPending();
$deposit->isFailed();
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$balanceResponse = $client->getBalance();
echo $balanceResponse->getBalance();
$balanceResponse->getBalance(); // Returns the balance in satoshis.
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$lightningInvoiceResponse = $client->getLightningInvoice('invoice_id');
echo $lightningInvoiceResponse->getPaymentRequest();
$invoice->getId();
$invoice->getMemo();
$invoice->getAmountSats();
$invoice->getPaymentRequest();
$invoice->isSettled();
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Currency;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$estimateResponse = $client->estimateWithdrawal(1000, Currency::BTC(), 'destination_address');
echo $estimateResponse->getAmountSats();
echo $estimateResponse->getFeeSats();
$estimateResponse->getRecipient();
$estimateResponse->getAmountSats();
$estimateResponse->getFeeSats();
$estimateResponse->getSuccessProbability();
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Currency;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$invoiceResponse = $client->createLightningInvoice(1000, Currency::BTC(), 'Invoice for services', 3600);
echo $invoiceResponse->getPaymentRequest();
$invoice->getId();
$invoice->getMemo();
$invoice->getAmountSats();
$invoice->getPaymentRequest();
$invoice->isSettled();
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$lightningAddressResponse = $client->createLightningAddress();
echo $lightningAddressResponse->getAddress();
$lightningAddress->getId();
$lightningAddress->getHandle();
$lightningAddress->getDomain();
$lightningAddress->getAddress();
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$onChainAddressResponse = $client->createOnChainAddress();
echo $onChainAddressResponse->getAddress();
$onChainAddress->getId();
$onChainAddress->getAddress();
use Bitvora\Client\BitvoraClient;
use Bitvora\Enum\Currency;
use Bitvora\Enum\Network;
$client = new BitvoraClient(Network::MAINNET, 'API_KEY');
$withdrawalResponse = $client->confirmWithdrawal(2100, Currency::SATS(), 'destination_address');
echo $withdrawalResponse->getId();
echo $withdrawalResponse->getStatus();
$withdrawal->getId();
$withdrawal->getAmountSats();
$withdrawal->getRecipient();
$withdrawal->getStatus();
$withdrawal->getRailType();
$withdrawal->isSettled();
$withdrawal->isPending();
$withdrawal->isFailed();
This SDK is open-sourced software licensed under the MIT license.