PHPackages                             denpa/php-bitapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. denpa/php-bitapi

Abandoned → [denpa/php-bitcoinrpc](/?search=denpa%2Fphp-bitcoinrpc)Library[HTTP &amp; Networking](/categories/http)

denpa/php-bitapi
================

Bitcoin JSON-RPC client based on GuzzleHttp

v2.2.0(3y ago)28221103[11 issues](https://github.com/denpamusic/php-bitcoinrpc/issues)MITPHPPHP &gt;=8.0

Since Jan 20Pushed 3y ago20 watchersCompare

[ Source](https://github.com/denpamusic/php-bitcoinrpc)[ Packagist](https://packagist.org/packages/denpa/php-bitapi)[ Docs](https://github.com/denpamusic/php-bitcoinrpc)[ RSS](/packages/denpa-php-bitapi/feed)WikiDiscussions 2.2.x Synced 2mo ago

READMEChangelog (10)Dependencies (2)Versions (35)Used By (0)

Simple Bitcoin JSON-RPC client based on GuzzleHttp
==================================================

[](#simple-bitcoin-json-rpc-client-based-on-guzzlehttp)

[![Latest Stable Version](https://camo.githubusercontent.com/ea2cdfc0f530e8d4e477f67e3e40a23ffbafbdc4be630c32498be550809e4c82/68747470733a2f2f706f7365722e707567782e6f72672f64656e70612f7068702d626974636f696e7270632f762f737461626c65)](https://packagist.org/packages/denpa/php-bitcoinrpc)[![License](https://camo.githubusercontent.com/57f443ee0ad7346137b321f4d3403c505134ca17bc6c63ef2d0668d9038c16ec/68747470733a2f2f706f7365722e707567782e6f72672f64656e70612f7068702d626974636f696e7270632f6c6963656e7365)](https://packagist.org/packages/denpa/php-bitcoinrpc)[![ci](https://github.com/denpamusic/php-bitcoinrpc/actions/workflows/ci.yml/badge.svg)](https://github.com/denpamusic/php-bitcoinrpc/actions/workflows/ci.yml)[![Code Climate](https://camo.githubusercontent.com/2331b56f13c118c897cef85a2d102231c3206186af873efab54acbd6f8454a6b/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f64656e70616d757369632f7068702d626974636f696e7270632f6261646765732f6770612e737667)](https://codeclimate.com/github/denpamusic/php-bitcoinrpc)[![Code Coverage](https://camo.githubusercontent.com/384a53f11afff36b52b1a18f396fe334d4d284f1195714538a9eca8c7f1e6d7f/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f64656e70616d757369632f7068702d626974636f696e7270632f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/denpamusic/php-bitcoinrpc/coverage)

Installation
------------

[](#installation)

Run `php composer.phar require denpa/php-bitcoinrpc` in your project directory or add following lines to composer.json

```
"require": {
    "denpa/php-bitcoinrpc": "^2.2"
}
```

and run `php composer.phar install`.

Requirements
------------

[](#requirements)

PHP 8.0 or higher
*For PHP 5.6 to 7.0 use [php-bitcoinrpc v2.0.x](https://github.com/denpamusic/php-bitcoinrpc/tree/2.0.x).*
*For PHP 7.0 to 7.4 use [php-bitcoinrpc v2.0.x](https://github.com/denpamusic/php-bitcoinrpc/tree/2.1.x).*

Usage
-----

[](#usage)

Create new object with url as parameter

```
/**
 * Don't forget to include composer autoloader by uncommenting line below
 * if you're not already done it anywhere else in your project.
 **/
// require 'vendor/autoload.php';

use Denpa\Bitcoin\Client as BitcoinClient;

$bitcoind = new BitcoinClient('http://rpcuser:rpcpassword@localhost:8332/');
```

or use array to define your bitcoind settings

```
/**
 * Don't forget to include composer autoloader by uncommenting line below
 * if you're not already done it anywhere else in your project.
 **/
// require 'vendor/autoload.php';

use Denpa\Bitcoin\Client as BitcoinClient;

$bitcoind = new BitcoinClient([
    'scheme'        => 'http',                 // optional, default http
    'host'          => 'localhost',            // optional, default localhost
    'port'          => 8332,                   // optional, default 8332
    'user'          => 'rpcuser',              // required
    'password'      => 'rpcpassword',          // required
    'ca'            => '/etc/ssl/ca-cert.pem',  // optional, for use with https scheme
    'preserve_case' => false,                  // optional, send method names as defined instead of lowercasing them
]);
```

Then call methods defined in [Bitcoin Core API Documentation](https://bitcoin.org/en/developer-reference#bitcoin-core-apis) with magic:

```
/**
 * Get block info.
 */
$block = $bitcoind->getBlock('000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');

$block('hash')->get();     // 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
$block['height'];          // 0 (array access)
$block->get('tx.0');       // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
$block->count('tx');       // 1
$block->has('version');    // key must exist and CAN NOT be null
$block->exists('version'); // key must exist and CAN be null
$block->contains(0);       // check if response contains value
$block->values();          // array of values
$block->keys();            // array of keys
$block->random(1, 'tx');   // random block txid
$block('tx')->random(2);   // two random block txid's
$block('tx')->first();     // txid of first transaction
$block('tx')->last();      // txid of last transaction

/**
 * Send transaction.
 */
$result = $bitcoind->sendToAddress('mmXgiR6KAhZCyQ8ndr2BCfEq1wNG2UnyG6', 0.1);
$txid = $result->get();

/**
 * Get transaction amount.
 */
$result = $bitcoind->listSinceBlock();
$bitcoin = $result->sum('transactions.*.amount');
$satoshi = \Denpa\Bitcoin\to_satoshi($bitcoin);
```

To send asynchronous request, add Async to method name:

```
$bitcoind->getBlockAsync(
    '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
    function ($response) {
        // success
    },
    function ($exception) {
        // error
    }
);
```

You can also send requests using request method:

```
/**
 * Get block info.
 */
$block = $bitcoind->request('getBlock', '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');

$block('hash');            // 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
$block['height'];          // 0 (array access)
$block->get('tx.0');       // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
$block->count('tx');       // 1
$block->has('version');    // key must exist and CAN NOT be null
$block->exists('version'); // key must exist and CAN be null
$block->contains(0);       // check if response contains value
$block->values();          // get response values
$block->keys();            // get response keys
$block->first('tx');       // get txid of the first transaction
$block->last('tx');        // get txid of the last transaction
$block->random(1, 'tx');   // get random txid

/**
 * Send transaction.
 */
$result = $bitcoind->request('sendtoaddress', 'mmXgiR6KAhZCyQ8ndr2BCfEq1wNG2UnyG6', 0.06);
$txid = $result->get();
```

or requestAsync method for asynchronous calls:

```
$bitcoind->requestAsync(
    'getBlock',
    '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
    function ($response) {
        // success
    },
    function ($exception) {
        // error
    }
);
```

Multi-Wallet RPC
----------------

[](#multi-wallet-rpc)

You can use `wallet($name)` function to do a [Multi-Wallet RPC call](https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#Multi-wallet_RPC_calls):

```
/**
 * Get wallet2.dat balance.
 */
$balance = $bitcoind->wallet('wallet2.dat')->getbalance();

echo $balance->get(); // 0.10000000
```

Exceptions
----------

[](#exceptions)

- `Denpa\Bitcoin\Exceptions\BadConfigurationException` - thrown on bad client configuration.
- `Denpa\Bitcoin\Exceptions\BadRemoteCallException` - thrown on getting error message from daemon.
- `Denpa\Bitcoin\Exceptions\ConnectionException` - thrown on daemon connection errors (e. g. timeouts)

Helpers
-------

[](#helpers)

Package provides following helpers to assist with value handling.

#### `to_bitcoin()`

[](#to_bitcoin)

Converts value in satoshi to bitcoin.

```
echo Denpa\Bitcoin\to_bitcoin(100000); // 0.00100000
```

#### `to_satoshi()`

[](#to_satoshi)

Converts value in bitcoin to satoshi.

```
echo Denpa\Bitcoin\to_satoshi(0.001); // 100000
```

#### `to_ubtc()`

[](#to_ubtc)

Converts value in bitcoin to ubtc/bits.

```
echo Denpa\Bitcoin\to_ubtc(0.001); // 1000.0000
```

#### `to_mbtc()`

[](#to_mbtc)

Converts value in bitcoin to mbtc.

```
echo Denpa\Bitcoin\to_mbtc(0.001); // 1.0000
```

#### `to_fixed()`

[](#to_fixed)

Trims float value to precision without rounding.

```
echo Denpa\Bitcoin\to_fixed(0.1236, 3); // 0.123
```

License
-------

[](#license)

This product is distributed under MIT license.

Donations
---------

[](#donations)

If you like this project, please consider donating:
**BTC**: 3L6dqSBNgdpZan78KJtzoXEk9DN3sgEQJu
**Bech32**: bc1qyj8v6l70c4mjgq7hujywlg6le09kx09nq8d350

❤Thanks for your support!❤

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~59 days

Recently: every ~224 days

Total

34

Last Release

1453d ago

Major Versions

1.x-dev → v2.0.0beta12017-08-14

PHP version history (4 changes)v1.0.0PHP &gt;=5.4.0

v1.0.2PHP &gt;=5.6.0

v2.1.0PHP &gt;=7.1

2.2.x-devPHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f8efe9703edc14d73aee59721f70a934b2d914ba12929c81ed51b54301c863b8?d=identicon)[denpamusic](/maintainers/denpamusic)

---

Top Contributors

[![denpamusic](https://avatars.githubusercontent.com/u/16575433?v=4)](https://github.com/denpamusic "denpamusic (264 commits)")[![partyka1](https://avatars.githubusercontent.com/u/19314216?v=4)](https://github.com/partyka1 "partyka1 (4 commits)")[![Doc0x1](https://avatars.githubusercontent.com/u/19937034?v=4)](https://github.com/Doc0x1 "Doc0x1 (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")[![M-Shahbaz](https://avatars.githubusercontent.com/u/3539612?v=4)](https://github.com/M-Shahbaz "M-Shahbaz (1 commits)")[![mtdlaurynas](https://avatars.githubusercontent.com/u/29912829?v=4)](https://github.com/mtdlaurynas "mtdlaurynas (1 commits)")

---

Tags

apiapi-clientbitcoincryptocurrencyguzzlehttpjson-rpcapiGuzzlejsonrpcbitcoin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/denpa-php-bitapi/health.svg)

```
[![Health](https://phpackages.com/badges/denpa-php-bitapi/health.svg)](https://phpackages.com/packages/denpa-php-bitapi)
```

###  Alternatives

[denpa/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

284217.4k4](/packages/denpa-php-bitcoinrpc)[denpa/laravel-bitcoinrpc

Bitcoin JSON-RPC Service Provider for Laravel

9053.4k](/packages/denpa-laravel-bitcoinrpc)[antoinelemaire/aircall-php

Aircall API client built on top of Guzzle 6

1049.6k](/packages/antoinelemaire-aircall-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
