This package is abandoned and no longer maintained. No replacement package was suggested.

BlockCypher's PHP SDK for REST API

v2.0.0-beta.1 2020-05-13 14:37 UTC

This package is auto-updated.

Last update: 2020-11-23 18:31:18 UTC


Due to the lack of usage, the PHP SDK has been deprecated. However our RESTful APIs are extremely easy to integrate with any good HTTP client library.

PHP REST API SDK for BlockCypher

Home Image

PHP Composer Coverage Status

Welcome to BlockCypher PHP SDK. This repository contains BlockCypher's PHP SDK and samples for REST API.

Warning: the legacy version (up to v1.5.0) which targets PHP >= 5.5.0 is in the branch php55. The master branch targets PHP >= 7.1.0 and is release as v2. While we are transitioning to v2 some of the documentation might be out of date. Please open an issue if this is the case.

SDK Documentation

Our BlockCypher-PHP-SDK Page includes all the documentation related to PHP SDK. Everything from SDK Wiki, to Sample Codes, to Releases. Here are few quick links to get you there faster.


More help

Upcoming features

Currently unavailable/upcoming REST API features

  • Install from phar

New samples

  • Capturing callback sample.
  • Managing errors in batching requests.

Quick Examples

Setup ApiContext

// Autoload the SDK Package. Installed via direct download.
require __DIR__  . '/php-client/autoload.php';
// Require the Composer autoloader. Installed via composer
//require 'vendor/autoload.php';

use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Rest\ApiContext;
use BlockCypher\Api\Address;

// Provide your Token. Replace the given one with your app Token
$token = 'c0afcccdde5081d6429de37d16166ead';

// SDK config
$config = array(
    'mode' => 'sandbox',
    'log.LogEnabled' => true,
    'log.FileName' => 'BlockCypher.log',
    'validation.level' => 'log',

$apiContext = ApiContext::create(
    'main', 'btc', 'v1',
    new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'),

Get Address info

use BlockCypher\Client\AddressClient;

$addressClient = new AddressClient($apiContext);
$address = $addressClient->get('1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD');

echo "JSON Address: " . $address->toJson() . "\n";

Send a microtransaction

$microTXClient = new MicroTXClient($apiContext);

try {
    $microTX = $microTXClient->sendSigned(
        "2c2cc015519b79782bd9c5af66f442e808f573714e3c4dc6df7d79c183963cff", // private key
        "C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi", // to address
        10000 // value (satoshis)
} catch (\Exception $e) {
    echo "There was an error sending the microtx.\n";