NAV
cURL JavaScript Ruby Python Go PHP

Introduction

#  _               _                  
# |_) |  _   _ |  /     ._  |_   _  ._
# |_) | (_) (_ |< \_ \/ |_) | | (/_ | 
#                    /  |             
//  _               _                  
// |_) |  _   _ |  /     ._  |_   _  ._
// |_) | (_) (_ |< \_ \/ |_) | | (/_ | 
//                    /  |             
#  _               _                  
# |_) |  _   _ |  /     ._  |_   _  ._
# |_) | (_) (_ |< \_ \/ |_) | | (/_ | 
#                    /  |             
//  _               _                  
// |_) |  _   _ |  /     ._  |_   _  ._
// |_) | (_) (_ |< \_ \/ |_) | | (/_ | 
//                    /  |             
//  _               _                  
// |_) |  _   _ |  /     ._  |_   _  ._
// |_) | (_) (_ |< \_ \/ |_) | | (/_ | 
//                    /  |             
<?php
/**
 *  _               _
 * |_) |  _   _ |  /     ._  |_   _  ._
 * |_) | (_) (_ |< \_ \/ |_) | | (/_ |
 *                    /  |
 */

Welcome to BlockCypher’s API documentation! BlockCypher is a simple, mostly RESTful JSON API for interacting with blockchains, accessed over HTTP or HTTPS from the api.blockcypher.com domain. Currently, BlockCypher supports Bitcoin, Bitcoin Testnet3, Litecoin, Dogecoin, and BlockCypher’s Test Chain (more about BlockCypher’s Test Chain below).

BlockCypher’s API provides a superset of the endpoints you’d find in reference implementations, in addition to some special features that make BlockCypher uniquely powerful, like our unconfirmed transaction Confidence Factor, dependable WebHook or WebSockets-based Events, On-Chain Microtransactions, and Payment Forwarding.

Consequently, if you’re familiar with a blockchain’s reference implementation, you’ll feel at home using BlockCypher, but without worrying about scaling or implementation challenges. And if you’re not familiar—with the reference implementations or blockchains in general—BlockCypher’s API is a great way to dip your toes into blockchain development, without a lengthy setup process. In either case, BlockCypher has 99.99% up-time, and maintains an expressive, logical API that you’ll love.

Documentation Structure

man curl | grep -A 3 "DESCRIPTION"

DESCRIPTION
curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.
// JavaScript examples use JQuery and can be run directly in your browser
// console (ctrl+shift+i or cmd+shift+i).
// Porting them to node.js should be trivial, replacing JQuery methods with
// request.js for example.

console.log('Welcome to BlockCypher');
# Ruby examples use irb, and our official ruby sdk:
# https://github.com/blockcypher/ruby-client

# You can install it easily from rubygems.org:
# https://rubygems.org/gems/blockcypher-ruby
gem install blockcypher-ruby

# Remember to require the library after installing
> require 'blockcypher'
=> true

# Unless otherwise noted, all requests assume an initialized API 'block_cypher' API object
> block_cypher = BlockCypher::Api.new(api_token:"YOURTOKEN")
=> #<BlockCypher::Api:0x000000010e4060 @api_token="YOURTOKEN", @currency="btc", @network="main", @version="v1">
# The official python library (https://github.com/blockcypher/blockcypher-python) works with python2/3
# Install it like this at the command line:
$ pip install blockcypher

# To access any method, first import the blockcypher module:
>>> import blockcypher

# Then call the method:
>>> blockcypher.foo()

# In your codebase, you should probably do it like this though:
>>> from blockcypher import foo
>>> foo()

# By default, all methods return results for BTC, but blockcyphers support many coins.
# You can pass coin_sybmol='foo' as an argument to any method, where foo is one of the following:
>>> blockcypher.constants.COIN_SYMBOL_LIST
[
    "btc", 
    "btc-testnet", 
    "ltc", 
    "doge", 
    "bcy",  # blockcypher's testnet
]

# Here's how to determine which version of the blockcypher SDK you're running:
>>> import pkg_resources
>>> pkg_resources.get_distribution("blockcypher")
blockcypher 1.0.39 (/usr/local/lib/python2.7/site-packages)
// Go examples use the official SDK, which you can find here:
// https://github.com/blockcypher/gobcy

// To install, use Go Get on the command line 
// go get github.com/blockcypher/gobcy

// Then import the package in your Go application
// All examples assume fmt is also imported, and 
// will require additional packages as necessary
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    // For Bitcoin main:
    btc := gobcy.API{"YOURTOKEN","btc","main"}
    // For BlockCypher's internal testnet:
    bcy := gobcy.API{"YOURTOKEN","bcy","test"}
    //examples will always follow in main()
}

// You can see additional info in the GoDoc, accessible here:
// https://godoc.org/github.com/blockcypher/gobcy
PHP Client
----------

REQUIREMENTS
- PHP 5.4+
- ext-curl
- ext-gmp
- ext-mcrypt
- Composer
- Git

INSTALL SAMPLES
git clone https://github.com/blockcypher/php-client.git
cd php-client

RUNNING SAMPLES ON CONSOLE
php -f .\sample\docs-sample\address-api\address-endpoint.php
Log file is generate in the folder when you run the command

To see detailed PHP client info, check the official PHP repository:
https://github.com/blockcypher/php-client

Less relevant/repetitive code is not shown in samples. You can get the full sample version from:
https://github.com/blockcypher/php-client/tree/master/sample

Unless noted otherwise, all samples assume this initializing code:
<?php
require __DIR__ . '/../bootstrap.php';

use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Rest\ApiContext;
// ... other classes

$apiContext = ApiContext::create(
    'main', 'btc', 'v1',
    new SimpleTokenCredential('$YOUR_TOKEN'),
    array('log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG')
);

In these docs you’ll find everything you need to leverage BlockCypher for your applications. For all officially supported languages, you’ll see code samples, in addition to basic cURL requests/responses for every endpoint. You can switch between cURL/language samples via the selector in the upper right. We’re working on supporting more languages, but if you’re working on your own language library, definitely let us know: we’d love to add more community supported libraries here.

Section Summaries

In-Browser Code Examples

We know many learn more from code examples than specific reference documentation, which is why we have code samples in our official languages. In addition, we have a number of in-browser code examples for particular use cases, which you can see here:

Changelog and Errors

Our documentation is powered by GitHub Pages and Slate, which makes viewing changes as simple as checking the git commit history. If there’s an error or you’d like to suggest a change, please consider submitting a pull request to benefit the broader BlockCypher community.

API Versions

All API calls are versioned, and the current BlockCypher API is v1. We will never introduce any breaking changes within v1, but we may add new, non-breaking features from time to time.

BlockCypher Supported Language SDKs

BlockCypher has client SDKs for the following languages:

If you’re using these languages, we strongly encourage you to use an official SDK. Of course, all our API calls are standard HTTP endpoints using JSON formatted responses, so any language (or cURL from the command-line) will work just fine.

Unofficial Libraries

This client SDK was made by the community, and is not officially supported by BlockCypher. As such, BlockCypher cannot guarantee that it’s fully up to date, but we hope it will provide a nice jumping-off point for developers using this language. We’ll endeavor to keep this list updated, if any of these prove obsolete. If there’s enough support for a particular language, we’ll work with the community to turn it into an officially supported SDK.

RESTful Resources

curl https://api.blockcypher.com/v1/btc/main

{
  "name": "BTC.main",
  "height": 360060,
  "hash": "000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8",
  "time": "2015-06-08T22:57:08.260165627Z",
  "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8",
  "previous_hash": "000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8",
  "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8",
  "peer_count": 239,
  "unconfirmed_count": 617,
  "high_fee_per_kb": 46086,
  "medium_fee_per_kb": 29422,
  "low_fee_per_kb": 12045,
  "last_fork_height": 359865,
  "last_fork_hash": "00000000000000000aa6462fd9faf94712ce1b5a944dc666f491101c996beab9"
}
$.get('https://api.blockcypher.com/v1/btc/main').then(function(d) {console.log(d)});
> {
>   "name": "BTC.main",
>   "height": 355578,
>   "hash": "00000000000000000a0b253f20709b0c77d8a56aa8db632ecbdc7381816504cd",
>   "time": "2015-05-08T23:12:55.243311146Z",
>   "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000a0b253f20709b0c77d8a56aa8db632ecbdc7381816504cd",
>   "previous_hash": "00000000000000000acef50ef89494493b4a08a8419588e1e3e20cd73bc85a6b",
>   "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000acef50ef89494493b4a08a8419588e1e3e20cd73bc85a6b",
>   "peer_count": 250,
>   "unconfirmed_count": 637,
>   "high_fee_per_kb": 45768,
>   "medium_fee_per_kb": 29415,
>   "low_fee_per_kb": 12045
> }
# Import Ruby SDK
> require 'blockcypher'
=> true

# Make new Api object, intialize with your token
> block_cypher = BlockCypher::Api.new(api_token:"YOURTOKEN")
=> #<BlockCypher::Api:0x000000010e4060 @api_token="YOURTOKEN", @currency="btc", @network="main", @version="v1">

# Query base resource
> block_cypher.blockchain
=> {"name"=>"BTC.main",
 "height"=>361218,
 "hash"=>"00000000000000000be2dca8e5336b01454fa032635a6f92d6adf0b98cdc6324",
 "time"=>"2015-06-16T19:53:57.157318741Z",
 "latest_url"=>"https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000be2dca8e5336b01454fa032635a6f92d6adf0b98cdc6324",
 "previous_hash"=>"00000000000000000c2f3f4b87214d1791289820f9f7b696d7484987a073f567",
 "previous_url"=>"https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000c2f3f4b87214d1791289820f9f7b696d7484987a073f567",
 "peer_count"=>260,
 "unconfirmed_count"=>4442,
 "high_fee_per_kb"=>45494,
 "medium_fee_per_kb"=>24444,
 "low_fee_per_kb"=>12301,
 "last_fork_height"=>360362,
 "last_fork_hash"=>"000000000000000002d5cf67bfaa92ba5b371c1590eb48d25031c669ef6233a0"}
>>> from blockcypher import get_blockchain_overview
>>> get_blockchain_overview()
{
    "hash": "000000000000000006c488791bafc490efb365ad609ed39e6ee51d1afbc8ed83", 
    "height": 379780, 
    "high_fee_per_kb": 57607, 
    "last_fork_hash": "00000000000000000aef777b65b5d32301c914e7d9f2c4cf1f7366e1eb217124", 
    "last_fork_height": 280959, 
    "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000006c488791bafc490efb365ad609ed39e6ee51d1afbc8ed83", 
    "low_fee_per_kb": 24554, 
    "medium_fee_per_kb": 28847, 
    "name": "BTC.main", 
    "peer_count": 817, 
    "previous_hash": "0000000000000000026727709d704d20de7d756427a10a86cd0b084066632e55", 
    "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000026727709d704d20de7d756427a10a86cd0b084066632e55", 
    "time": "datetime.datetime(2015, 10, 20, 19, 35, 50, 174235, tzinfo=tzutc())", 
    "unconfirmed_count": 100231
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    chainInfo, err := btc.GetChain()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", chainInfo)
}

//Result from `go run`: 
//{Name:BTC.main Height:378750 Hash:000000000000000001d8c28595ba3ebacc5bd1dc7cc91a3cd47400e2c83c1123 Time:2015-10-13 20:47:03.575975057 +0000 UTC PrevHash:00000000000000000601c02134e4d49c7d5903f0fe382a5f10d24f7de457c5c0 PeerCount:1000 HighFee:50628 MediumFee:27723 LowFee:22560 UnconfirmedCount:58707 LastForkHeight:378316 LastForkHash:000000000000000000cc3179570758c48ebe31a47f55e74ad765541d8adb32ea}
<?php
// Run on console:
// php -f .\sample\chain-api\ChainEndpoint.php

$blockchainClient = new BlockchainClient($apiContext);
$blockchain = $blockchainClient->get('BTC.main');

{
  "name":"BTC.main",
  "height":360602,
  "hash":"00000000000000000a1268afd1eb419817106a37c9a87852228cadb752a64f2a",
  "time":"2015-06-12T13:09:56.69966089Z",
  "latest_url":"https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000a1268afd1eb419817106a37c9a87852228cadb752a64f2a",
  "previous_hash":"00000000000000000cea706491da61bc755a1250d7260becff5aafc9d26613f2",
  "previous_url":"https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000cea706491da61bc755a1250d7260becff5aafc9d26613f2",
  "peer_count":250,
  "unconfirmed_count":1794,
  "high_fee_per_kb":40018,
  "medium_fee_per_kb":26652,
  "low_fee_per_kb":12299,
  "last_fork_height":360362,
  "last_fork_hash":"000000000000000002d5cf67bfaa92ba5b371c1590eb48d25031c669ef6233a0"
}

Almost all resources exist under a given blockchain, and follow this pattern:

https://api.blockcypher.com/$API_VERSION/$COIN/$CHAIN/

Currently, there’s only one version of the API (v1). Thus, here’s an exhaustive list of blockchains and their corresponding resources:

Coin Chain Resource
Bitcoin Main api.blockcypher.com/v1/btc/main
Bitcoin Testnet3 api.blockcypher.com/v1/btc/test3
Dogecoin Main api.blockcypher.com/v1/doge/main
Litecoin Main api.blockcypher.com/v1/ltc/main
BlockCypher Test api.blockcypher.com/v1/bcy/test

Rate Limits and Tokens

# Adding your token as URL parameter
curl https://api.blockcypher.com/v1/btc/main?token=$YOURTOKEN

# Checking your token's limits
curl https://api.blockcypher.com/v1/tokens/$YOURTOKEN
{
"token": "YOURTOKEN",
"limits": {
    "api/hour": 10000,
    "api/second": 500,
    "hooks/hour": 5000,
    "confidence/hour": 1000,
    "hooks": 5000,
    "payments": 5000
},
"hits": {
    "api/hour": 280,
    "hooks/hour": 240,
    "confidence/hour": 100
},
"hits_history": {
    {
    "api/hour": 253,
    "confidence/hour": 50,
    "time": "2016-06-15T07:00:00-00:00",
    "hooks": 358,
    },
    {
    "api/hour": 2,
    "hooks/hour": 30,
    "time": "2016-06-15T06:00:00-00:00"
    "hooks": 358,
    },
    ...
}
}
# These are quite above the default limits, but if you'd like them, reach out at contact@blockcypher.com ;)
// Adding your token as URL parameter
const TOKEN = 'YOUR_TOKEN';
$.get('https://api.blockcypher.com/v1/btc/main?token='+TOKEN);
# Import Ruby SDK
> require 'blockcypher'
=> true

# Make new Api object, intialize with your token
> block_cypher = BlockCypher::Api.new(api_token:"YOURTOKEN")
=> #<BlockCypher::Api:0x000000010e4060 @api_token="YOURTOKEN", @currency="btc", @network="main", @version="v1">
>>> from blockcypher import get_token_info
>>> get_token_info('YOUR_TOKEN')
{
    "hits": {
        "api/hour": 16366, 
        "hooks/hour": 266,
        "confidence/hour": 101
    }, 
    "limits": {
        "api/hour": 500000, 
        "api/second": 200, 
        "hooks/hour": 30000,
        "confidence/hour": 1000,
        "hooks": 10000,
        "payments": 10000
    }, 
    "token": "YOUR_TOKEN"
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    //Adding your token is part of the API coin/chain initialization
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    fmt.Printf("%+v\n", btc)
}

//Result from `go run`:
//{Token:YOURTOKEN Coin:btc Chain:main}
<?php
# Adding your token as client credential to API context
$apiContext = ApiContext::create(
    'main', 'btc', 'v1',
    new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'),
    array('log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG')
);

# Use $apiContext as function param or set as default ApiContext 

We want everyone to try BlockCypher with as little friction as possible, which is why you don’t need a token for any read-only GET calls. Please register for a user token if you want to use POST and DELETE calls. Once you have your token, you can append it to all your requests like any other URL parameter if you’re using cURL, or through the appropriate method in the language SDK you’re using.

We do rate-limit our free tier, with or without a token (though tokens are required for Confidence lookups, WebHooks/Sockets, Payments, and any POST or DELETE calls):

The hourly rate limits reset on the top of the hour UTC. For example, if you’re under the free tier, and you have used 200 regular requests by 03:58 UTC, you’ll hit a rate limit until it resets at 04:00 UTC.

On the accounts page, you’ll find paid plans starting at $75 a month (with a 10% discount if you pay with Bitcoin). To request higher limits or SLAs beyond what’s offered on the accounts page, please email us.

You can check your current limits and usage via a GET on the following endpoint, outside of our normal coin/chain pattern:

https://api.blockcypher.com/v1/tokens/$YOURTOKEN

Within that return object, you’ll also find hits_history array, which shows your token’s last 48 hours of usage, while hits shows the current hour’s usage.

You can even see information about your remaining limits by checking the X-Ratelimit-Remaining attribute in the HTTP header in normal API calls. Keep in mind the X-Ratelimit-Remaining attribute corresponds to the hourly rate limit associated with the endpoint you call (e.g., if it’s from a WebHook, that corresponds to the Hooks/Hour; if it’s a normal call, the number corresponds to the normal Requests/Hour limit).

Batching

# Batching blocks 5, 6, and 7
curl 'https://api.blockcypher.com/v1/btc/main/blocks/5;6;7'

[{
"hash": "000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d",
"height": 6,
"chain": "BTC.main",
"total": 0,
"fees": 0,
"ver": 1,
"time": "2009-01-09T03:29:49Z",
...,
},
{
"hash": "000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc",
"height": 5,
"chain": "BTC.main",
"total": 0,
"fees": 0,
"ver": 1,
"time": "2009-01-09T03:23:48Z",
...,
},
{
"hash": "0000000071966c2b1d065fd446b1e485b2c9d9594acd2007ccbd5441cfc89444",
"height": 7,
"chain": "BTC.main",
"total": 0,
"fees": 0,
"ver": 1,
"time": "2009-01-09T03:39:29Z",
...,
}]
// Batching blocks 5, 6, and 7

$.get('https://api.blockcypher.com/v1/btc/main/blocks/5;6;7')
  .then(function(d) {console.log(d);});
> [{
> "hash": "000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d",
> "height": 6,
> "chain": "BTC.main",
> "total": 0,
> "fees": 0,
> "ver": 1,
> "time": "2009-01-09T03:29:49Z",
> ...,
> },
> {
> "hash": "000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc",
> "height": 5,
> "chain": "BTC.main",
> "total": 0,
> "fees": 0,
> "ver": 1,
> "time": "2009-01-09T03:23:48Z",
> ...,
> },
> {
> "hash": "0000000071966c2b1d065fd446b1e485b2c9d9594acd2007ccbd5441cfc89444",
> "height": 7,
> "chain": "BTC.main",
> "total": 0,
> "fees": 0,
> "ver": 1,
> "time": "2009-01-09T03:39:29Z",
> ...,
> }]
# Batching blocks 5, 6, and 7
> block_cypher.blockchain_block('5;6;7')
=> [{"hash"=>"0000000071966c2b1d065fd446b1e485b2c9d9594acd2007ccbd5441cfc89444",
  "height"=>7,
  "chain"=>"BTC.main",
  "total"=>0,
  "fees"=>0,
  "ver"=>1,
  "time"=>"2009-01-09T03:39:29Z",
  ...},
 {"hash"=>"000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d",
  "height"=>6,
  "chain"=>"BTC.main",
  "total"=>0,
  "fees"=>0,
  "ver"=>1,
  "time"=>"2009-01-09T03:29:49Z",
  ...},
 {"hash"=>"000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc",
  "height"=>5,
  "chain"=>"BTC.main",
  "total"=>0,
  "fees"=>0,
  "ver"=>1,
  "time"=>"2009-01-09T03:23:48Z",
  ...}]
# Where possible, the python library will batch requests for speed
>>> from blockcypher import get_blocks_overview
# Batching blocks 5, 6, and 7
>>> get_blocks_overview([5,6,7])
[
    {
        "bits": 486604799, 
        "chain": "BTC.main", 
        "depth": 379775, 
        "fees": 0, 
        "hash": "000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d", 
        "height": 6, 
        "mrkl_root": "20251a76e64e920e58291a30d4b212939aae976baca40e70818ceaa596fb9d37", 
        "n_tx": 1, 
        "nonce": 2538380312, 
        "prev_block": "000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc", 
        "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc", 
        "received_time": "datetime.datetime(2009, 1, 9, 3, 29, 49, 0, tzinfo=tzutc())", 
        "relayed_by": "", 
        "time": "datetime.datetime(2009, 1, 9, 3, 29, 49, 0, tzinfo=tzutc())", 
        "total": 0, 
        "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", 
        "txids": [
            "20251a76e64e920e58291a30d4b212939aae976baca40e70818ceaa596fb9d37"
        ], 
        "ver": 1
    }, 
    {
        "bits": 486604799, 
        "chain": "BTC.main", 
        "depth": 379774, 
        "fees": 0, 
        "hash": "0000000071966c2b1d065fd446b1e485b2c9d9594acd2007ccbd5441cfc89444", 
        "height": 7, 
        "mrkl_root": "8aa673bc752f2851fd645d6a0a92917e967083007d9c1684f9423b100540673f", 
        "n_tx": 1, 
        "nonce": 2258412857, 
        "prev_block": "000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d", 
        "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d", 
        "received_time": "datetime.datetime(2009, 1, 9, 3, 39, 29, 0, tzinfo=tzutc())", 
        "relayed_by": "", 
        "time": "datetime.datetime(2009, 1, 9, 3, 39, 29, 0, tzinfo=tzutc())", 
        "total": 0, 
        "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", 
        "txids": [
            "8aa673bc752f2851fd645d6a0a92917e967083007d9c1684f9423b100540673f"
        ], 
        "ver": 1
    }, 
    {
        "bits": 486604799, 
        "chain": "BTC.main", 
        "depth": 379776, 
        "fees": 0, 
        "hash": "000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc", 
        "height": 5, 
        "mrkl_root": "63522845d294ee9b0188ae5cac91bf389a0c3723f084ca1025e7d9cdfe481ce1", 
        "n_tx": 1, 
        "nonce": 2011431709, 
        "prev_block": "000000004ebadb55ee9096c9a2f8880e09da59c0d68b1c228da88e48844a1485", 
        "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000004ebadb55ee9096c9a2f8880e09da59c0d68b1c228da88e48844a1485", 
        "received_time": "datetime.datetime(2009, 1, 9, 3, 23, 48, 0, tzinfo=tzutc())", 
        "relayed_by": "", 
        "time": "datetime.datetime(2009, 1, 9, 3, 23, 48, 0, tzinfo=tzutc())", 
        "total": 0, 
        "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", 
        "txids": [
            "63522845d294ee9b0188ae5cac91bf389a0c3723f084ca1025e7d9cdfe481ce1"
        ], 
        "ver": 1
    }
]
//Batching requests is currently unsupported in the Go SDK
//But you can still request things serially
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    blocks := make([]gobcy.Block, 3)
    heights := []int{5, 6, 7}
    for i, v := range heights {
        blk, err := btc.GetBlock(v, "")
        if err != nil {
            fmt.Println(err)
        }
        blocks[i] = blk
    }
    fmt.Printf("%+v\n", blocks)
}

//Result from `go run`:
//[{Hash:000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc Height:5 Depth:378755 Chain:BTC.main Total:0 Fees:0 Ver:1 Time:2009-01-09 03:23:48 +0000 UTC ReceivedTime:2009-01-09 03:23:48 +0000 UTC RelayedBy: Bits:486604799 Nonce:2011431709 NumTX:1 PrevBlock:000000004ebadb55ee9096c9a2f8880e09da59c0d68b1c228da88e48844a1485 MerkleRoot:63522845d294ee9b0188ae5cac91bf389a0c3723f084ca1025e7d9cdfe481ce1 TXids:[63522845d294ee9b0188ae5cac91bf389a0c3723f084ca1025e7d9cdfe481ce1] NextTXs:} {Hash:000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d Height:6 Depth:378754 Chain:BTC.main Total:0 Fees:0 Ver:1 Time:2009-01-09 03:29:49 +0000 UTC ReceivedTime:2009-01-09 03:29:49 +0000 UTC RelayedBy: Bits:486604799 Nonce:2538380312 NumTX:1 PrevBlock:000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc MerkleRoot:20251a76e64e920e58291a30d4b212939aae976baca40e70818ceaa596fb9d37 TXids:[20251a76e64e920e58291a30d4b212939aae976baca40e70818ceaa596fb9d37] NextTXs:} {Hash:0000000071966c2b1d065fd446b1e485b2c9d9594acd2007ccbd5441cfc89444 Height:7 Depth:378753 Chain:BTC.main Total:0 Fees:0 Ver:1 Time:2009-01-09 03:39:29 +0000 UTC ReceivedTime:2009-01-09 03:39:29 +0000 UTC RelayedBy: Bits:486604799 Nonce:2258412857 NumTX:1 PrevBlock:000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d MerkleRoot:8aa673bc752f2851fd645d6a0a92917e967083007d9c1684f9423b100540673f TXids:[8aa673bc752f2851fd645d6a0a92917e967083007d9c1684f9423b100540673f] NextTXs:}]
<?php
// Run on console:
// php -f .\sample\introduction\Batching.php
// Batching blocks 5, 6, and 7

$blockClient = new BlockClient($apiContext);
$blockList = array('5', '6', '7');
$blocks = $blockClient->getMultiple($blockList);

[{
"hash": "000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d",
"height": 6,
"chain": "BTC.main",
"total": 0,
"fees": 0,
"ver": 1,
"time": "2009-01-09T03:29:49Z",
...,
},
{
"hash": "000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc",
"height": 5,
"chain": "BTC.main",
"total": 0,
"fees": 0,
"ver": 1,
"time": "2009-01-09T03:23:48Z",
...,
},
{
"hash": "0000000071966c2b1d065fd446b1e485b2c9d9594acd2007ccbd5441cfc89444",
"height": 7,
"chain": "BTC.main",
"total": 0,
"fees": 0,
"ver": 1,
"time": "2009-01-09T03:39:29Z",
...,
}]

# Note, when constructing the block array (first param) programatically you can use alternative syntax like:
$blockList = array('5', '6', '7');
$blockList = explode(";", "5;6;7");
$blockList = [5,6,7]; // PHP 5.4

All endpoints that can retrieve a single Object can be batched to return multiple objects. If you’re cURLing the API directly, batching simply requires appending each identifier to the previous one using a semicolon (check the code pane for an example). The results are aggregated in a JSON array. The other supported client SDKs batch differently, but each idiomatic to their respective language (check the code pane examples in each library).

When cURLing BlockCypher, batching also works when the identifiers aren’t the last part of the URL; e.g., this URL will return the balances of three separate addresses:

https://api.blockcypher.com/v1/btc/main/addrs/1J38WorKngZLJvA7qMin9g5jqUfTQUBZNE;1JP8FqoXtCMrR1sZc2McLWmHxENox1Y1PV;1ENn7XmqXNnReiQEFHhBGzfiv5gAyBj7r1/balance

Testing

We offer two different options for testing your blockchain application: Bitcoin Testnet3, and BlockCypher’s Test Chain. We offer automated faucets for both Testnet3 and BlockCypher’s Test Chain, but we recommend using BlockCypher’s Test Chain for a variety of reasons:

In case you missed the Resources section, the BlockCypher Test Chain is accessible from this resource:

https://api.blockcypher.com/v1/bcy/test

# Note resource change to bcy/test instead of btc/main
# Make new address; returns private key/public key/address
curl -X POST https://api.blockcypher.com/v1/bcy/test/addrs?token=$YOURTOKEN

{
"private": "26415016a2fb49f51aef161cb35bd537be07b75a6ac1e297d3b7a370cc85433b",
"public": "02c572d062fefcc8c3e1bf5016450addcedb89cd7e4507d8a323f327b4ad1018e0",
"address": "CFqoZmZ3ePwK5wnkhxJjJAQKJ82C7RJdmd"
}

# Fund prior address with faucet
curl -d '{"address": "CFqoZmZ3ePwK5wnkhxJjJAQKJ82C7RJdmd", "amount": 100000}' https://api.blockcypher.com/v1/bcy/test/faucet?token=$YOURTOKEN
{
"tx_ref": "02dbf5585d438a1cba82a9041dd815635a6b0df684225cb5271e11397a759479"
}
// Make new address; returns private key/public key/address
$.post('https://api.blockcypher.com/v1/bcy/test/addrs?token=$YOUR_TOKEN')
  .then(function(d) {console.log(d)});
> {
> "private": "26415016a2fb49f51aef161cb35bd537be07b75a6ac1e297d3b7a370cc85433b",
> "public": "02c572d062fefcc8c3e1bf5016450addcedb89cd7e4507d8a323f327b4ad1018e0",
> "address": "CFqoZmZ3ePwK5wnkhxJjJAQKJ82C7RJdmd"
> }

// Fund prior address with faucet
var data = {"address": "CFqoZmZ3ePwK5wnkhxJjJAQKJ82C7RJdmd", "amount": 100000}
$.post('https://api.blockcypher.com/v1/bcy/test/faucet?token=$YOUR_TOKEN', JSON.stringify(data))
  .then(function(d) {console.log(d)});
> {
>   "tx_ref": "02dbf5585d438a1cba82a9041dd815635a6b0df684225cb5271e11397a759479"
> }
# Create new api object on BlockCypher Testnet
> bc_test = BlockCypher::Api.new(currency:BlockCypher::BCY, network:BlockCypher::TEST_NET, api_token:"YOURTOKEN")
=> #<BlockCypher::Api:0x000000030169b0 @api_token="YOURTOKEN", @currency="bcy", @network="test", @version="v1">

# Generate new test address
> bc_test.address_generate
=> {"private"=>"5a3675bbc7e24e63224bff60a3850a77d5a494419735e3b94173eac5379437c9",
 "public"=>"0311ab9780760dd8c5d2d9319f1eee9c9328eddd503d0b86e3af253b1665638b8a",
 "address"=>"Bv6rJzFmSg41nhibjfEfqSeeb2Te1Hh3FG",
 "wif"=>"BrMPimGAWyUUuGduxHZi1Q9n9Nveunton8sC5ouZeJp6EhKNaAcZ"}

# Fund with faucet
> bc_test.faucet("Bv6rJzFmSg41nhibjfEfqSeeb2Te1Hh3FG", 1000000)
=> {"tx_ref"=>"59ddf03d9e292da5b3160e6ac341c9773873b693203c799a4ba8a4e05ef5a0d7"}
# Fund existing address with faucet
>>> from blockcypher import send_faucet_coins
# bcy is the coin_symbol for the blockcypher (not bitcoin) testnet
>>> send_faucet_coins(address_to_fund='CFqoZmZ3ePwK5wnkhxJjJAQKJ82C7RJdmd', satoshis=10000, api_key='YOUR_TOKEN', coin_symbol='bcy')
{
    "tx_ref": "5d59f2ff777594fdfd964cd5ee4853e80cc3dc097a2ce67a55c16e643a99dddb"
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    bcy := gobcy.API{"YOURTOKEN", "bcy", "test"}
    //Generate new address
    pair, err := bcy.GenAddrKeychain()
    //Fund it with faucet
    txhash, err := bcy.Faucet(pair, 100000)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("Address: %v, Faucet TXHash: %v\n", pair.Address, txhash)
}

//Result from `go run`:
//Address: Buvu6hXdvs52UiRmwtRDs2VXEuta3iWM1Y, Faucet TXHash: 31da1be35d10711eae224f149ae600a8515def0e9045901c0d144e71098c9a20
<?php
// Make new address; returns private key/public key/address
// Run on console:
// php -f .\sample\introduction\GenerateBcyAddress.php

$addressClient = new AddressClient($apiContext);
$addressKeyChain = $addressClient->generateAddress();

{
  "private":"40e0d6e6210307b9b9d0113bceb9b8c5be6b9e010a03e07f25f75f462ed00a90",
  "public":"03bd50fc57b1cdf3badbdf0662a4bb54b4d7a0b96eb27cc216b01503b8bf29b29e",
  "address":"Bxi1GmU6xgqgyBEzugcqFZRLyJd1cpEv2S",
  "wif":"BqW9QJ24VFcEvDp8UvYvLTnDxn1SjpxsvTeysPAjBW6BX9NggYfr"
}

<?php
// Fund prior address with faucet
// Run on console:
// php -f .\sample\introduction\FundAddressWithFaucetEndpoint.php

$faucetClient = new FaucetClient($apiContext);
$faucetResponse = $faucetClient->fundAddress('Bxi1GmU6xgqgyBEzugcqFZRLyJd1cpEv2S', 100000);

{
  "tx_ref":"0fa68cf5c39dbd918a5ca49fc092be36b8bcece83cbfed919ad6c77b5f24cceb"
}

Test Faucets

To help facilitate automated testing in your applications, a faucet endpoint is available on both BlockCypher’s Test Chain and Bitcoin Testnet3. Calling the faucet endpoint, along with passing a valid address, will automatically create—and propagate—a new transaction funding the address with the amount you provide.

This example shows how to leverage the faucet to programmatically fund addresses, to test your applications. While the example used BlockCypher’s Test Chain, the same example could have used Bitcoin Testnet3 and worked the exact same way.

Objects

# All cURL'd Objects are JSON:

{
    key: value,
    key: value,
}

Before diving into BlockCypher’s endpoints, this section details all the Objects exposed and expected by the API. Some of you might be more interested in the endpoints themselves, in which case, feel free to skip to the next section. But for others, a section dedicated to all of BlockCypher’s Objects might prove a useful overview, especially if you’re new to Blockchain development in general. And in either case, this section provides a comprehensive reference for Objects in the API. For each Object there’s a description and a link to a germane API endpoint.

Blockchain

curl https://api.blockcypher.com/v1/btc/main

{
  "name": "BTC.main",
  "height": 360060,
  "hash": "000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8",
  "time": "2015-06-08T22:57:08.260165627Z",
  "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8",
  "previous_hash": "000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8",
  "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8",
  "peer_count": 239,
  "unconfirmed_count": 617,
  "high_fee_per_kb": 46086,
  "medium_fee_per_kb": 29422,
  "low_fee_per_kb": 12045,
  "last_fork_height": 359865,
  "last_fork_hash": "00000000000000000aa6462fd9faf94712ce1b5a944dc666f491101c996beab9"
}
>>> from blockcypher import get_blockchain_overview
>>> get_blockchain_overview()
{
    "hash": "000000000000000006c488791bafc490efb365ad609ed39e6ee51d1afbc8ed83", 
    "height": 379780, 
    "high_fee_per_kb": 57607, 
    "last_fork_hash": "00000000000000000aef777b65b5d32301c914e7d9f2c4cf1f7366e1eb217124", 
    "last_fork_height": 280959, 
    "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000006c488791bafc490efb365ad609ed39e6ee51d1afbc8ed83", 
    "low_fee_per_kb": 24554, 
    "medium_fee_per_kb": 28847, 
    "name": "BTC.main", 
    "peer_count": 817, 
    "previous_hash": "0000000000000000026727709d704d20de7d756427a10a86cd0b084066632e55", 
    "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000026727709d704d20de7d756427a10a86cd0b084066632e55", 
    "time": "datetime.datetime(2015, 10, 20, 19, 35, 50, 174235, tzinfo=tzutc())", 
    "unconfirmed_count": 100231
}

A Blockchain represents the current state of a particular blockchain from the Coin/Chain resources that BlockCypher supports. Typically returned from the Chain API endpoint.

Attribute Type Description
name string The name of the blockchain represented, in the form of $COIN.$CHAIN.
height integer The current height of the blockchain; i.e., the number of blocks in the blockchain.
hash string The hash of the latest confirmed block in the blockchain; in Bitcoin, the hashing function is SHA256(SHA256(block)).
time time The time of the latest update to the blockchain; typically when the latest block was added.
latest_url url The BlockCypher URL to query for more information on the latest confirmed block; returns a Block.
previous_hash string The hash of the second-to-latest confirmed block in the blockchain.
previous_url url The BlockCypher URL to query for more information on the second-to-latest confirmed block; returns a Block.
peer_count integer N/A, will be deprecated soon.
high_fee_per_kb integer A rolling average of the fee (in satoshis) paid per kilobyte for transactions to be confirmed within 1 to 2 blocks.
medium_fee_per_kb integer A rolling average of the fee (in satoshis) paid per kilobyte for transactions to be confirmed within 3 to 6 blocks.
low_fee_per_kb integer A rolling average of the fee (in satoshis) paid per kilobyte for transactions to be confirmed in 7 or more blocks.
unconfirmed_count integer Number of unconfirmed transactions in memory pool (likely to be included in next block).
last_fork_height integer Optional The current height of the latest fork to the blockchain; when no competing blockchain fork present, not returned with endpoints that return Blockchains.
last_fork_hash string Optional The hash of the latest confirmed block in the latest fork of the blockchain; when no competing blockchain fork present, not returned with endpoints that return Blockchains.

Block

curl https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412

{
"hash": "0000000000000000189bba3564a63772107b567...",
"height": 294322,
"chain": "BTC.main",
"total": 1146652915,
"fees": 130999,
"ver": 2,
"time": "2014-04-05T07:49:18Z",
"received_time": "2014-04-05T07:49:18Z",
"relayed_by": "",
"bits": 419486617,
"nonce": 1225187768,
"n_tx": 10,
"prev_block": "0000000000000000ced0958bd27720b71d3...",
"mrkl_root": "359d624d37aee1efa5662b7f5dbc390e996d...",
"txids": [
    "32b3b86e40d996b1f281e24e8d4af2ceacbf874c403836...",
    "1579f716359ba1a207f70248135f5e5fadf539be1dcf53...",
    ...,
],
"depth": 61793,
"prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0",
"tx_url": "https://api.blockcypher.com/v1/btc/main/txs/"
}
>>> from blockcypher import get_block_overview
>>> get_block_overview('0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412')
{
    "bits": 419486617, 
    "chain": "BTC.main", 
    "depth": 85570, 
    "fees": 130999, 
    "hash": "0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412", 
    "height": 294322, 
    "mrkl_root": "359d624d37aee1efa5662b7f5dbc390e996d561afc8148e8d716cf6ad765a952", 
    "n_tx": 10, 
    "nonce": 1225187768, 
    "prev_block": "0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0", 
    "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0", 
    "received_time": "datetime.datetime(2014, 4, 5, 7, 49, 18, 0, tzinfo=tzutc())", 
    "relayed_by": "", 
    "time": "datetime.datetime(2014, 4, 5, 7, 49, 18, 0, tzinfo=tzutc())", 
    "total": 1146652915, 
    "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", 
    "txids": [
        "32b3b86e40d996b1f281e24e8d4af2ceacbf874c4038369cc21baa807409b277", 
        "1579f716359ba1a207f70248135f5e5fadf539be1dcf5300613aedcb6577d287", 
        "dd1f183348eb41eaaa9ecf8012f9cca3ecbae41a6349f0cc4bfd2b1a497fa3d0", 
        "749d12ccd180968b82aef4c271ca4effdf981d9b5d12523264457c9d4e6fa78e", 
        "c4fe2ee16b8e3067d3d95caf7944011f4959781288b807df8bf853b7f80ed97c", 
        "5a2114675265522d2b7ce8a7874cfa7a22ccc3fb6566a8599d6432c6805b1b5f", 
        "077d851c8240671de80caa8be9f5285201c08a70edc5a45a9cd35fe7eaebf5e1", 
        "6202cc55fbd9130e065c9294a5b2e061c26f3d2c8df56c32da605d9f183103f9", 
        "ad3e7aa1c33f1d3e1c105d94f7b1542808da07bbe66b9621b050104a85dbf650", 
        "36cc61016b9d1bd69768666f287db1edaa9b292fb442f152af7099305677230e"
    ], 
    "ver": 2
}

A Block represents the current state of a particular block from a Blockchain. Typically returned from the Block Hash and Block Height endpoints.

Attribute Type Description
hash string The hash of the block; in Bitcoin, the hashing function is SHA256(SHA256(block))
height integer The height of the block in the blockchain; i.e., there are height earlier blocks in its blockchain.
depth integer The depth of the block in the blockchain; i.e., there are depth later blocks in its blockchain.
chain string The name of the blockchain represented, in the form of $COIN.$CHAIN
total integer The total number of satoshis transacted in this block.
fees integer The total number of fees—in satoshis—collected by miners in this block.
size integer Optional Raw size of block (including header and all transactions) in bytes. Not returned for bitcoin blocks earlier than height 389104.
ver integer Block version.
time time Recorded time at which block was built. Note: Miners rarely post accurate clock times.
received_time time The time BlockCypher’s servers receive the block. Our servers’ clock is continuously adjusted and accurate.
relayed_by string Address of the peer that sent BlockCypher’s servers this block.
bits integer The block-encoded difficulty target.
nonce integer The number used by a miner to generate this block.
n_tx integer Number of transactions in this block.
prev_block string The hash of the previous block in the blockchain.
prev_block_url url The BlockCypher URL to query for more information on the previous block.
tx_url url The base BlockCypher URL to receive transaction details. To get more details about specific transactions, you must concatenate this URL with the desired transaction hash(es).
mrkl_root string The Merkle root of this block.
txids array[string] An array of transaction hashes in this block. By default, only 20 are included.
next_txids url Optional If there are more transactions that couldn’t fit in the txids array, this is the BlockCypher URL to query the next set of transactions (within a Block object).

TX

curl https://api.blockcypher.com/v1/btc/main/txs/f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449

{
"block_hash": "0000000000000000c504bdea36e531d80...",
"block_height": 293000,
"hash": "f854aebae95150b379cc1187d848d58225f3c41...",
"addresses": [
    "13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy",
    "19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L",
    "1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy",
    "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq",
    "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
],
"total": 70320221545,
"fees": 0,
"size": 636,
"preference": "low",
"relayed_by": "",
"confirmed": "2014-03-29T01:29:19Z",
"received": "2014-03-29T01:29:19Z",
"ver": 1,
"lock_time": 0,
"double_spend": false,
"vin_sz": 4,
"vout_sz": 1,
"confirmations": 63171,
"inputs": [
    {
        "prev_hash": "583910b7bf90ab802e22e5c25a89...",
        "output_index": 1,
        "script": "4830450220504b1ccfddf508422bdd8...",
        "output_value": 16450000,
        "sequence": 4294967295,
        "addresses": [
            "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq"
        ],
        "script_type": "pay-to-pubkey-hash"
    },
    ...,
    ...,
],
"outputs": [
    {
        "value": 70320221545,
        "script": "76a914e6aad9d712c419ea8febf009a...",
        "spent_by": "35832d6c70b98b54e9a53ab2d5117...",
        "addresses": [
            "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
        ],
        "script_type": "pay-to-pubkey-hash"
    }
]
}

A TX represents the current state of a particular transaction from either a Block within a Blockchain, or an unconfirmed transaction that has yet to be included in a Block. Typically returned from the Unconfirmed Transactions and Transaction Hash endpoints.

Attribute Type Description
block_height integer Height of the block that contains this transaction. If this is an unconfirmed transaction, it will equal -1.
hash string The hash of the transaction. While reasonably unique, using hashes as identifiers may be unsafe.
addresses array[string] Array of bitcoin public addresses involved in the transaction.
total integer The total number of satoshis exchanged in this transaction.
fees integer The total number of fees—in satoshis—collected by miners in this transaction.
size integer The size of the transaction in bytes.
preference string The likelihood that this transaction will make it to the next block; reflects the preference level miners have to include this transaction. Can be high, medium or low.
relayed_by string Address of the peer that sent BlockCypher’s servers this transaction.
received time Time this transaction was received by BlockCypher’s servers.
ver integer Version number, typically 1 for Bitcoin transactions.
lock_time integer Time when transaction can be valid. Can be interpreted in two ways: if less than 500 million, refers to block height. If more, refers to Unix epoch time.
double_spend bool true if this is an attempted double spend; false otherwise.
vin_sz integer Total number of inputs in the transaction.
vout_sz integer Total number of outputs in the transaction.
confirmations integer Number of subsequent blocks, including the block the transaction is in. Unconfirmed transactions have 0 confirmations.
inputs array[TXInput] TXInput Array, limited to 20 by default.
outputs array[TXOutput] TXOutput Array, limited to 20 by default.
opt_in_rbf bool Optional Returns true if this transaction has opted in to Replace-By-Fee (RBF), either true or not present. You can read more about Opt-In RBF here.
confidence float Optional The percentage chance this transaction will not be double-spent against, if unconfirmed. For more information, check the section on Confidence Factor.
confirmed time Optional Time at which transaction was included in a block; only present for confirmed transactions.
receive_count integer Optional Number of peers that have sent this transaction to BlockCypher; only present for unconfirmed transactions.
change_address string Optional Address BlockCypher will use to send back your change, if you constructed this transaction. If not set, defaults to the address from which the coins were originally sent.
block_hash string Optional Hash of the block that contains this transaction; only present for confirmed transactions.
double_of string Optional If this transaction is a double-spend (i.e. double_spend == true) then this is the hash of the transaction it’s double-spending.
data_protocol string Optional Returned if this transaction contains an OP_RETURN associated with a known data protocol. Data protocols currently detected: blockchainid ; openassets ; factom ; colu ; coinspark ; omni
hex string Optional Hex-encoded bytes of the transaction, as sent over the network.
next_inputs url Optional If there are more transaction inptus that couldn’t fit into the TXInput array, this is the BlockCypher URL to query the next set of TXInputs (within a TX object).
next_outputs url Optional If there are more transaction outputs that couldn’t fit into the TXOutput array, this is the BlockCypher URL to query the next set of TXOutputs(within a TX object).

TXInput

{
"prev_hash": "e5c9be87798b0fa8ad55a22b5d731d6f50d72bffaa6179f9999499e57388cc33",
"output_index": 1,
"script": "004730440220689409a16c98fa1659cae4c20...",
"output_value": 2450698356,
"sequence": 4294967295,
"addresses": [
    "34ch2jrhYXDFsLK1FZQ3SjqgFRnX8mGC5W"
],
"script_type": "pay-to-script-hash",
"age": 5
}

A TXInput represents an input consumed within a transaction. Typically found within an array in a TX. In most cases, TXInputs are from previous UTXOs, with the most prominent exceptions being attempted double-spend and coinbase inputs.

Attribute Type Description
prev_hash string The previous transaction hash where this input was an output. Not present for coinbase transactions.
output_index integer The index of the output being spent within the previous transaction. Not present for coinbase transactions.
output_value integer The value of the output being spent within the previous transaction. Not present for coinbase transactions.
script_type string The type of script that encumbers the output corresponding to this input.
script string Raw hexadecimal encoding of the script.
addresses array[string] An array of public addresses associated with the output of the previous transaction.
sequence integer Legacy 4-byte sequence number, not usually relevant unless dealing with locktime encumbrances.
age integer Optional Number of confirmations of the previous transaction for which this input was an output. Currently, only returned in unconfirmed transactions.
wallet_name string Optional Name of Wallet or HDWallet from which to derive inputs. Only used when constructing transactions via the Creating Transactions process.
wallet_token string Optional Token associated with Wallet or HDWallet used to derive inputs. Only used when constructing transactions via the Creating Transactions process.

TXOutput

{
"value": 70320221545,
"script": "76a914e6aad9d712c419ea8febf009a3f3bfdd8d222fac88ac",
"spent_by": "35832d6c70b98b54e9a53ab2d51176eb19ad11bc4505d6bb1ea6c51a68cb92ee",
"addresses": [
    "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
],
"script_type": "pay-to-pubkey-hash"
}

A TXOutput represents an output created by a transaction. Typically found within an array in a TX.

Attribute Type Description
value int Value in this transaction output, in satoshis.
script string Raw hexadecimal encoding of the encumbrance script for this output.
addresses array[string] Addresses that correspond to this output; typically this will only have a single address, and you can think of this output as having “sent” value to the address contained herein.
script_type string The type of encumbrance script used for this output.
spent_by string Optional The transaction hash that spent this output. Only returned for outputs that have been spent. The spending transaction may be unconfirmed.
data_hex string Optional A hex-encoded representation of an OP_RETURN data output, without any other script instructions. Only returned for outputs whose script_type is null-data.
data_string string Optional An ASCII representation of an OP_RETURN data output, without any other script instructions. Only returned for outputs whose script_type is null-data and if its data falls into the visible ASCII range.

TXConfidence

curl https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9/confidence

{
"age_millis": 12725,
"receive_count": 666,
"confidence": 0.9901509730004237,
"txhash": "43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9",
"txurl": "https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9"
}

A TXConfidence represents information about the confidence that an unconfirmed transaction will make it into the next block. Typically used as a return object from the Transaction Confidence Endpoint.

Attribute Type Description
age_millis integer The age of the transaction in milliseconds, based on the earliest time BlockCypher saw it relayed in the network.
receive_count integer Number of peers that have sent this transaction to BlockCypher; only positive for unconfirmed transactions. -1 for confirmed transactions.
confidence float A number from 0 to 1 representing BlockCypher’s confidence that the transaction won’t be double-spent against.
txhash string The hash of the transaction. While reasonably unique, using hashes as identifiers may be unsafe.
txurl url The BlockCypher URL one can use to query more detailed information about this transaction.

TXRef

{
"tx_hash": "14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e",
"block_height": 302013,
"tx_input_n": -1,
"tx_output_n": 0,
"value": 20213,
"ref_balance": 4433416,
"spent": false,
"confirmations": 54405,
"confirmed": "2014-05-22T03:46:25Z",
"double_spend": false
}

A TXRef object represents summarized data about a transaction input or output. Typically found in an array within an Address object, which is usually returned from the standard Address Endpoint.

Attribute Type Description
address string Optional The address associated with this transaction input/output. Only returned when querying an address endpoint via a wallet/HD wallet name.
block_height integer Height of the block that contains this transaction input/output. If it’s unconfirmed, this will equal -1.
tx_hash string The hash of the transaction containing this input/output. While reasonably unique, using hashes as identifiers may be unsafe.
tx_input_n integer Index of this input in the enclosing transaction. It’s a negative number for an output.
tx_output_n integer Index of this output in the enclosing transaction. It’s a negative number for an input.
value integer The value transfered by this input/output in satoshis exchanged in the enclosing transaction.
preference string The likelihood that the enclosing transaction will make it to the next block; reflects the preference level miners have to include the enclosing transaction. Can be high, medium or low.
spent bool true if this is an output and was spent. If it’s an input, or an unspent output, it will be false.
double_spend bool true if this is an attempted double spend; false otherwise.
confirmations integer Number of subsequent blocks, including the block the transaction is in. Unconfirmed transactions have 0 confirmations.
script string Optional Raw, hex-encoded script of this input/output.
ref_balance integer Optional The past balance of the parent address the moment this transaction was confirmed. Not present for unconfirmed transactions.
confidence float Optional The percentage chance this transaction will not be double-spent against, if unconfirmed. For more information, check the section on Confidence Factor.
confirmed time Optional Time at which transaction was included in a block; only present for confirmed transactions.
spent_by string Optional The transaction hash that spent this output. Only returned for outputs that have been spent. The spending transaction may be unconfirmed.
received time Optional Time this transaction was received by BlockCypher’s servers; only present for unconfirmed transactions.
receive_count integer Optional Number of peers that have sent this transaction to BlockCypher; only present for unconfirmed transactions.
double_of string Optional If this transaction is a double-spend (i.e. double_spend == true) then this is the hash of the transaction it’s double-spending.

TXSkeleton

# Note resource change to bcy/test instead of btc/main
curl -d '{"inputs":[{"addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"]}],"outputs":[{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}]}' https://api.blockcypher.com/v1/bcy/test/txs/new

{
"tx": {
    "block_height": -1,
    "block_index": 0,
    "hash": "4d6e32d71313fb548232642fd...",
    "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
        "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
    ],
    "total": 5419600,
    "fees": 12500,
    "size": 119,
    ...
},
"tosign": [
    "97d81abd54cae1648951f49..."
],
"errors": [
    { "error": "..." }
],
"signatures": [],
"pubkeys": []
}

A TXSkeleton is a convenience/wrapper Object that’s used primarily when Creating Transactions through the New and Send endpoints.

Attribute Type Description
tx TX A temporary TX, usually returned fully filled but missing input scripts.
tosign array[string] Array of hex-encoded data for you to sign, one for each input.
signatures array[string] Array of signatures corresponding to all the data in tosign, typically provided by you.
pubkeys array[string] Array of public keys corresponding to each signature. In general, these are provided by you, and correspond to the signatures you provide.
tosign_tx array[string] Optional Array of hex-encoded, work-in-progress transactions; optionally returned to validate the tosign data locally.
errors array[“error”:string] Optional Array of errors in the form “error”:“description-of-error”. This is only returned if there was an error in any stage of transaction generation, and is usually accompanied by a HTTP 400 code.

NullData

curl -d '{"data":"I am the walrus", "encoding":"string"}' https://api.blockcypher.com/v1/btc/main/txs/data?token=YOURTOKEN

{
  "data": "I am the walrus",
  "encoding": "string",
  "token": "YOURTOKEN",
  "hash": "cb6974e0fd57c91b70403e85ef48c840eecdca4804dfc4897b1321d5328e4f18"
}

A NullData Object is used exclusively by our Data Endpoint to embed small pieces of data on the blockchain. If your data is over 40 bytes, it cannot be embedded into the blockchain and will return an error

Attribute Type Description
data string The string representing the data to embed, can be either hex-encoded or plaintext.
token string Optional Your BlockCypher API token, can either be included here or as a URL Parameter in your request.
encoding string Optional The encoding of your data, can be either string (for plaintext) or hex (for hex-encoded). If not set, defaults to hex.
hash string Optional The hash of the transaction containing your data; only part of return object.

MicroTX

{
"from_pubkey": "03bb318b00de944086fad67ab78a832eb1bf26916053ecd3b14a3f48f9fbe0821f",
"to_address": "mrS82nWF3TCfhafSaKnmUUktGNYuTZn1Ap",
"value_satoshis": 5000,
"token": "YOURTOKEN",
"signatures": [
    "3045022100..."
],
"tosign" : [
    "cbac3d3105..."
],
"inputs": [
    {
    "prev_hash": "88e6f4fa0dea77e...",
    "output_index": 2
    },
    {
    "prev_hash": "a02ccb59238178e...",
    "output_index": 1
    }
],
"outputs": [
    {
    "address": "13My...",
    "value": 10000
    },
    {
    "address": "1bs15...",
    "value": 9995590
    }
],
"fees": 735
}

A MicroTX represents a streamlined—and typically much lower value—microtransaction, one which BlockCypher can sign for you if you send your private key. MicroTXs can also be signed on the client-side without ever sending your private key. You’ll find these objects used in the Microtransaction API.

Attribute Type Description
from_pubkey string Hex-encoded public key from which you’re sending coins.
from_private string Hex-encoded private key from which you’re sending coins.
from_wif string WIF-encoded private key from which you’re sending coins.
to_address string The target address to which you’re sending coins.
value_satoshis int Value you’re sending/you’ve sent in satoshis.
token string Your BlockCypher API token
change_address string Optional Address BlockCypher will use to send back your change. If not set, defaults to the address from which the coins were originally sent. While not required, we recommend that you set a change address.
wait_guarantee bool Optional If not set, defaults to true, which means the API will wait for BlockCypher to guarantee the transaction, using our Confidence Factor. The guarantee usually takes around 8 seconds. If manually set to false, the Microtransaction endpoint will return as soon as the transaction is broadcast.
tosign array[string] Optional Hex-encoded data for you to sign after initiating the microtransaction. Sent in reply to a microtransaction generated using from_pubkey/a public key.
signatures array[string] Optional Hex-encoded signatures for you to send back after having received (and signed) tosign.
inputs array[TXInput] Optional Partial list of inputs that will be used with this transaction. Inputs themsleves are heavily pared down, see cURL sample. Only returned when using from_pubkey.
outputs array[TXOutput] Optional Partial list of outputs that will be used with this transaction. Outputs themselves are heavily pared down, see cURL sample. Only returned when using from_pubkey.
fees integer Optional BlockCypher’s optimally calculated fees for this MicroTX to guarantee swift 99% confirmation, only returned when using from_pubkey. BlockCypher pays these fees for the first 8,000 microtransactions, but like regular transactions, it is deducted from the source address thereafter.
hash string Optional The hash of the finalized transaction, once sent.

Address

curl https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD

{
"address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
"total_received": 4433416,
"total_sent": 0,
"balance": 4433416,
"unconfirmed_balance": 0,
"final_balance": 4433416,
"n_tx": 7,
"unconfirmed_n_tx": 0,
"final_n_tx": 7,
"txrefs": [
    ...
],
"unconfirmed_txrefs": [
    ...
]
}

An Address represents a public address on a blockchain, and contains information about the state of balances and transactions related to this address. Typically returned from the Address Balance, Address, and Address Full Endpoint.

Attribute Type Description
address string Optional The requested address. Not returned if querying a wallet/HD wallet.
wallet Wallet Optional The requested wallet object. Only returned if querying by wallet name instead of public address.
hd_wallet HDWallet Optional The requested HD wallet object. Only returned if querying by HD wallet name instead of public address.
total_received integer Total amount of confirmed satoshis received by this address.
total_sent integer Total amount of confirmed satoshis sent by this address.
balance integer Balance of confirmed satoshis on this address. This is the difference between outputs and inputs on this address, but only for transactions that have been included into a block (i.e., for transactions whose confirmations > 0).
unconfirmed_balance integer Balance of unconfirmed satoshis on this address. Can be negative (if unconfirmed transactions are just spending outputs). Only unconfirmed transactions (haven’t made it into a block) are included.
final_balance integer Total balance of satoshis, including confirmed and unconfirmed transactions, for this address.
n_tx integer Number of confirmed transactions on this address. Only transactions that have made it into a block (confirmations > 0) are counted.
unconfirmed_n_tx integer Number of unconfirmed transactions for this address. Only unconfirmed transactions (confirmations == 0) are counted.
final_n_tx integer Final number of transactions, including confirmed and unconfirmed transactions, for this address.
tx_url url Optional To retrieve base URL transactions. To get the full URL, concatenate this URL with a transaction’s hash.
txs array[TX] Optional Array of full transaction details associated with this address. Usually only returned from the Address Full Endpoint.
txrefs array[TXRef] Optional Array of transaction inputs and outputs for this address. Usually only returned from the standard Address Endpoint.
unconfirmed_txrefs array[TXRef] Optional All unconfirmed transaction inputs and outputs for this address. Usually only returned from the standard Address Endpoint.
hasMore bool Optional If true, then the Address object contains more transactions than shown. Useful for determining whether to poll the API for more transaction information.

AddressKeychain

curl -X POST https://api.blockcypher.com/v1/btc/test3/addrs

{
"private": "86751cb880a9a1addcc3b67979976158dd800afe9d14b68349921299b20c94dd",
"public": "03866586fbe3652eb219c5ed99c3fc72d125472248183f966e0673be08a1c543de",
"address": "n1ucSDLByN5GLLQuE7BMrtTWHwHtkaVkfA",
"wif": "cS64ygfjWjN73S78oUbJQeikDn9uS7KNWS1PL7NqeBUuF4UobnAy"
}

An AddressKeychain represents an associated collection of public and private keys alongside their respective public address. Generally returned and used with the Generate Address Endpoint.

Attribute Type Description
address string Standard address representation.
public string Hex-encoded Public key.
private string Hex-encoded Private key.
wif string Wallet import format, a common encoding for the private key.
pubkeys array[string] Optional Array of public keys to provide to generate a multisig address.
script_type string Optional If generating a multisig address, the type of multisig script; typically “multisig-n-of-m”, where n and m are integers.
original_address string Optional If generating an OAP address, this represents the parent blockchain’s underlying address (the typical address listed above).
oap_address string Optional The OAP address, if generated using the Generate Asset Address Endpoint.

Wallet

curl -d '{"name": "alice","addresses": ["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]}' https://api.blockcypher.com/v1/btc/main/wallets?token=YOURTOKEN

{
"token":"YOURTOKEN",
"name": "alice",
"addresses": ["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]
}
Attribute Type Description
token string User token associated with this wallet.
name string Name of the wallet.
addresses array[string] List of addresses associated with this wallet.

A Wallet contains a list of addresses associated by its name and the user’s token. It can be used interchangeably with all the Address API endpoints, and in many places that require addresses, like when Creating Transactions.

The name of a wallet must be 1-25 characters long and cannot start with any characters that start an address for the currency contained in the wallet. For example, bitcoin wallet names cannot start with ‘1’ or '3’.

HDWallet

curl -d '{"name": "bob", "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"}' https://api.blockcypher.com/v1/btc/main/wallets/hd?token=YOURTOKEN

{"token": "YOURTOKEN",
"name": "bob",
"hd": true,
"extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
"chains": [
    {"chain_addresses": [
        {
            "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
            "path": "m/0"
        },
        {
            "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
            "path": "m/1"
        },
        {
            "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
            "path": "m/2"
        }
    ]}
]}

An HDWallet contains addresses derived from a single seed. Like normal wallets, it can be used interchangeably with all the Address API endpoints, and in many places that require addresses, like when Creating Transactions.

Attribute Type Description
token string User token associated with this HD wallet.
name string Name of the HD wallet.
chains array[HDChain] List of HD chains associated with this wallet, each containing HDAddresses. A single chain is returned if the wallet has no subchains.
hd bool true for HD wallets, not present for normal wallets.
extended_public_key string The extended public key all addresses in the HD wallet are derived from. It’s encoded in BIP32 format
subchain_indexes array[integer] optional returned for HD wallets created with subchains.

The name of a wallet must be 1-25 characters long and cannot start with any characters that start an address for the currency contained in the wallet. For example, bitcoin wallet names cannot start with '1’ or '3’.

HDChain

curl https://api.blockcypher.com/v1/btc/main/wallet/hd/bob/addresses?token=YOURTOKEN

{"chains": [
    {"chain_addresses": [
        {
            "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
            "path": "m/0"
        },
        {
            "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
            "path": "m/1"
        },
        {
            "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
            "path": "m/2"
        }]
    }
]}

An array of HDChains are included in every HDWallet and returned from the Get Wallet, Get Wallet Addresses and Derive Address in Wallet endpoints.

Attribute Type Description
chain_addresses array[HDAddress] Array of HDAddresses associated with this subchain.
index integer optional Index of the subchain, returned if the wallet has subchains.

HDAddress

Attribute Type Description
address string Standard address representation.
path string The BIP32 path of the HD address.
public string optional Contains the hex-encoded public key if returned by Derive Address in Wallet endpoint.

An HD Address object contains an address and its BIP32 HD path (location of the address in the HD tree). It also contains the hex-encoded public key when returned from the Derive Address in Wallet endpoint.

OAPIssue

{
"from_private": "0eb369746401c3369517239...", 
"to_address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK",
"amount": 200,
"metadata": "1a2b3c4d5e6f"
}

An OAPIssue represents a request for either issuance or transfer of new assets, as detailed in the Asset API.

Attribute Type Description
from_private string The private key being used to issue or transfer assets.
to_address string The target OAP address assets for issue or transfer.
amount int The amount of assets being issued or transfered.
metadata string Optional Hex-encoded metadata that can optionally be encoded into the issue or transfer transaction.

OAPTX

{
  "ver": 1,
  "assetid": "1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui",
  "hash": "022e05bdfa2e148bc1882cb7a81506b8316fee6957b11625126d075a8cf8791b",
  "confirmed": "2015-10-25T04:50:06Z",
  "received": "2015-10-25T04:49:32.37Z",
  "oap_meta": "1a2b3c4d5e6f",
  "double_spend": false,
  "inputs": [
    {
      "prev_hash": "56253cffa1b3508d106391da3646cda2aee0bd080db427321c77ad11739e4239",
      "output_index": 0,
      "address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP",
      "output_value": 1000
    }
  ],
  "outputs": [
    {
      "address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK",
      "value": 200,
      "original_output_index": 1
    }
  ]
}

An OAPTX represents an Open Assets Protocol transaction, generated when issuing or transfering assets.

Attribute Type Description
ver int Version of Open Assets Protocol transaction. Typically 1.
assetid string Unique indentifier associated with this asset; can be used to query other transactions associated with this asset.
hash string This transaction’s unique hash; same as the underlying transaction on the asset’s parent blockchain.
confirmed time Optional Time this transaction was confirmed; only returned for confirmed transactions.
received time Time this transaction was received.
oap_meta string Optional Associated hex-encoded metadata with this transaction, if it exists.
double_spend bool true if this is an attempted double spend; false otherwise.
inputs array[…] Array of input data, which can be seen explicitly in the cURL example. Very similar to array of TXInputs, but with values related to assets instead of satoshis.
outputs array[…] Array of output data, which can be seen explicitly in the cURL example. Very similar to array of TXOutputs, but with values related to assets instead of satoshis.

Event

curl https://api.blockcypher.com/v1/btc/main/hooks/399d0923-e920-48ee-8928-2051cbfbc369

{
"id": "399d0923-e920-48ee-8928-2051cbfbc369"
"event": "unconfirmed-tx",
"address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
"token": "YOURTOKEN",
"url": "https://my.domain.com/callbacks/new-tx",
"callback_errors": 0
}

An Event represents a WebHooks or WebSockets-based notification request, as detailed in the Events & Hooks section of the documentation.

Attribute Type Description
id string Identifier of the event; generated when a new request is created.
event string Type of event; can be unconfirmed-tx, new-block, confirmed-tx, tx-confirmation, double-spend-tx, tx-confidence.
hash string optional Only objects with a matching hash will be sent. The hash can either be for a block or a transaction.
wallet_name string optional Only transactions associated with the given wallet will be sent; can use a regular or HD wallet name. If used, requires a user token.
token string optional Required if wallet_name is used, though generally we advise users to include it (as they can reach API throttling thresholds rapidly).
address string optional Only transactions associated with the given address will be sent. A wallet name can also be used instead of an address, which will then match on any address in the wallet.
confirmations integer optional Used in concert with the tx-confirmation event type to set the number of confirmations desired for which to receive an update. You’ll receive an updated TX for every confirmation up to this amount. The maximum allowed is 10; if not set, it will default to 6.
confidence float optional Used in concert with the tx-confidence event type to set the minimum confidence for which you’ll receive a notification. You’ll receive a TX once this threshold is met. Will accept any float between 0 and 1, exclusive; if not set, defaults to 0.99.
script string optional Only transactions with an output script of the provided type will be sent. The recognized types of scripts are: pay-to-pubkey-hash, pay-to-multi-pubkey-hash, pay-to-pubkey, pay-to-script-hash, null-data (sometimes called OP_RETURN), empty or unknown.
url url optional Callback URL for this Event’s WebHook; not applicable for WebSockets usage.
callback_errors int Number of errors when attempting to POST to callback URL; not applicable for WebSockets usage.

PaymentForward

curl -d '{"destination":"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh","callback_url": "https://my.domain.com/callbacks/new-pay","process_fees_address": "1LWw6FdzNUcX8bnekMMZ7eofcGF7SXmbrL", "process_fees_percent": 0.1,"token":"YOURTOKEN"}' https://api.blockcypher.com/v1/btc/main/payments

{
"input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX",
"destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
"callback_url": "https://my.domain.com/callbacks/new-pay"
"process_fees_address": "1LWw6FdzNUcX8bnekMMZ7eofcGF7SXmbrL",
"process_fees_percent": 0.1,
"token": "YOURTOKEN"
}

A PaymentForward object represents a request set up through the Payment Forwarding service.

Attribute Type Description
id string Identifier of the payment forwarding request; generated when a new request is created.
token string The mandatory user token.
destination string The required destination address for payment forwarding.
input_address string The address which will automatically forward to destination; generated when a new request is created.
process_fees_address string Optional Address to forward processing fees, if specified. Allows you to receive a fee for your own services.
process_fees_satoshis int Optional Fixed processing fee amount to be sent to the fee address. A fixed satoshi amount or a percentage is required if a process_fees_address has been specified.
process_fees_percent float Optional Percentage of the transaction to be sent to the fee address. A fixed satoshi amount or a percentage is required if a process_fees_address has been specified.
callback_url url Optional The URL to call anytime a new payment is forwarded.
enable_confirmations bool Optional Whether to also call the callback_url with subsequent confirmations of the forwarding transactions. Automatically sets up a WebHook.
mining_fees_satoshis int Optional Mining fee amount to include in the forwarding transaction, in satoshis. If not set, defaults to 10,000.
transactions array[string] Optional History of forwarding transaction hashes for this payment forwarding request.

PaymentForwardCallback

{
"value": 100000000,
"input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX",
"destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
"input_transaction_hash": "39bed5d...",
"transaction_hash": "1aa6103..."
}

A PaymentForwardCallback object represents the payload delivered to the optional callback_url in a PaymentForward request.

Attribute Type Description
value int Amount sent to the destination address, in satoshis.
input_address string The intermediate address to which the payment was originally sent.
destination string The final destination address to which the payment will eventually be sent.
input_transaction_hash string The transaction hash representing the initial payment to the input_address.
transaction_hash string The transaction hash of the generated transaction that forwards the payment from the input_address to the destination.

Job

{
    "token": "YOURTOKEN",
    "analytics_engine": "payeeaddresses",
    "created_at": "2016-07-11T19:33:35.518605498Z",
    "completed_at": "2016-07-11T19:35:25.539002964Z",
    "finished": true,
    "started": true,
    "ticket": "50b77697-ff13-4a50-8a2b-cee605bc3000",
    "result_path": "https://api.blockcypher.com/v1/btc/main/analytics/job/50b77697-ff13-4a50-8a2b-cee605bc3000/results",
    "args": {
        "address": "1bones5gF1HJeiexQus6UtvhU4EUD4qfj",
        "value_threshold": 100000000
    }
}

A Job represents an analytics query set up through the Analytics API.

Attribute Type Description
token string The token that created this job.
analytics_engine string The engine used for the job query.
created_at time The time this job was created.
completed_at time Optional When this job was completed; only present on complete jobs.
finished bool true if this job is finished processing, false otherwise.
started bool true if this job has begun processing, false otherwise.
ticket string Unique identifier for this job, used to get job status and results.
result_path url Optional URL to query job results; only present on complete jobs.
args JobArgs Query arguments for this job.

JobArgs

{
    "address": "1bones5gF1HJeiexQus6UtvhU4EUD4qfj",
    "degree": 2,
    "limit": 100
}

A JobArgs represents the query parameters of a particular analytics job, used when Creating an Analytics Job and returned within a Job. Note that the required and optional arguments can change depending on the engine you’re using; for more specifics check the Analytics Engine and Parameters section.

Attribute Type Description
address string Address hash this job is querying.
value_threshold int Minimal/threshold value (in satoshis) to query.
limit int Limit of results to return.
start time Beginning of time range to query.
end time End of time range to query.
degree int Degree of connectiveness to query.
source string IP address and port, of the form “0.0.0.0:80”. Ideally an IP and port combination found from another API lookup (for example, relayed_by from the Transaction Hash Endpoint)

JobResults

{
    "page": 0,
    "more": true,
    "next_page": "https://api.blockcypher.com/v1/btc/main/analytics/job/50b77697-ff13-4a50-8a2b-cee605bc3000/results?page=1",
    "results": [
        {
            "DstAddr": "1changemCPo732F6oYUyhbyGtFcNVjprq",
            "SrcAddr": "1bones5gF1HJeiexQus6UtvhU4EUD4qfj",
            "TxHash": "0x3b06b1e9d70217d5e02644703fe79f54355b0ea05cd535787f5a6c627f1c
            43ef",
            "Value": 1e+08
        },
        ....
    ]
}

A JobResults represents the result of a particular analytics job, returned from Get Analytics Job Results. Note that the results field will depend largely on the engine used.

Attribute Type Description
page int Current page of results.
more bool true if there are more results in a separate page; false otherwise.
next_page url Optional URL to get the next page of results; only present if there are more results to show.
results array[…] Results of analytics job; structure of results are dependent on engine-type of query, but are generally either strings of address hashes or JSON objects.

Blockchain API

The first component—and highest level—of the BlockCypher API allows you to query general information about blockchain and blocks based on the coin/chain resource you’ve selected for your endpoints.

If you’re new to blockchains, you can think of the blockchain itself as an immutable, distributed ledger. Each block in the blockchain is like a “page” in the ledger containing information about transactions between parties. A great place to start understanding the mechanics behind blockchains is the original Bitcoin whitepaper.

Chain Endpoint

curl https://api.blockcypher.com/v1/btc/main

{
  "name": "BTC.main",
  "height": 360060,
  "hash": "000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8",
  "time": "2015-06-08T22:57:08.260165627Z",
  "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8",
  "previous_hash": "000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8",
  "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8",
  "peer_count": 239,
  "unconfirmed_count": 617,
  "high_fee_per_kb": 46086,
  "medium_fee_per_kb": 29422,
  "low_fee_per_kb": 12045,
  "last_fork_height": 359865,
  "last_fork_hash": "00000000000000000aa6462fd9faf94712ce1b5a944dc666f491101c996beab9"
}
$.get('https://api.blockcypher.com/v1/btc/main').then(function(d) {console.log(d)});
> {
>   "name": "BTC.main",
>   "height": 355578,
>   "hash": "00000000000000000a0b253f20709b0c77d8a56aa8db632ecbdc7381816504cd",
>   "time": "2015-05-08T23:12:55.243311146Z",
>   "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000a0b253f20709b0c77d8a56aa8db632ecbdc7381816504cd",
>   "previous_hash": "00000000000000000acef50ef89494493b4a08a8419588e1e3e20cd73bc85a6b",
>   "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000acef50ef89494493b4a08a8419588e1e3e20cd73bc85a6b",
>   "peer_count": 250,
>   "unconfirmed_count": 637,
>   "high_fee_per_kb": 45768,
>   "medium_fee_per_kb": 29415,
>   "low_fee_per_kb": 12045
> }
> block_cypher.blockchain
=> {"name"=>"BTC.main",
 "height"=>361218,
 "hash"=>"00000000000000000be2dca8e5336b01454fa032635a6f92d6adf0b98cdc6324",
 "time"=>"2015-06-16T19:53:57.157318741Z",
 "latest_url"=>"https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000be2dca8e5336b01454fa032635a6f92d6adf0b98cdc6324",
 "previous_hash"=>"00000000000000000c2f3f4b87214d1791289820f9f7b696d7484987a073f567",
 "previous_url"=>"https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000c2f3f4b87214d1791289820f9f7b696d7484987a073f567",
 "peer_count"=>260,
 "unconfirmed_count"=>4442,
 "high_fee_per_kb"=>45494,
 "medium_fee_per_kb"=>24444,
 "low_fee_per_kb"=>12301,
 "last_fork_height"=>360362,
 "last_fork_hash"=>"000000000000000002d5cf67bfaa92ba5b371c1590eb48d25031c669ef6233a0"}
>>> from blockcypher import get_blockchain_overview
>>> get_blockchain_overview()
{
    "hash": "0000000000000000097ebad5b89f15d46bc2bb36423af7cbcaa83a87f3f2a178", 
    "height": 379892, 
    "high_fee_per_kb": 51535, 
    "last_fork_hash": "000000000000000004d09e31247aa0efbba89cb35c146f96f7150d76c810d395", 
    "last_fork_height": 379357, 
    "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000097ebad5b89f15d46bc2bb36423af7cbcaa83a87f3f2a178", 
    "low_fee_per_kb": 24372, 
    "medium_fee_per_kb": 29490, 
    "name": "BTC.main", 
    "peer_count": 896, 
    "previous_hash": "00000000000000000bbd491173b40160b74e212650b7324bc74b33367d0e0a6b", 
    "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000bbd491173b40160b74e212650b7324bc74b33367d0e0a6b", 
    "time": "datetime.datetime(2015, 10, 21, 14, 11, 21, 603114, tzinfo=tzutc())", 
    "unconfirmed_count": 78701
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    chain, err := btc.GetChain()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", chain)
}

//Result from `go run`:
//{Name:BTC.main Height:378882 Hash:000000000000000005e5b78413032db5d54a6df5600549f5d3ec339dd7bac4c0 Time:2015-10-14 17:01:57.647896489 +0000 UTC PrevHash:0000000000000000111be2620123bcf2f8ca6209140a8b1f0d8c2412dd9067f2 PeerCount:896 HighFee:52463 MediumFee:27563 LowFee:24926 UnconfirmedCount:81047 LastForkHeight:378316 LastForkHash:00000000000000000806c49f6b53b439beec2a1434f15ae713b84b87a26bbb51}
<?php
// Run on console:
// php -f .\sample\chain-api\ChainEndpoint.php

$blockchainClient = new BlockchainClient($apiContext);
$blockchain = $blockchainClient->get('BTC.main');

{
  "name":"BTC.main",
  "height":360602,
  "hash":"00000000000000000a1268afd1eb419817106a37c9a87852228cadb752a64f2a",
  "time":"2015-06-12T13:09:56.69966089Z",
  "latest_url":"https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000a1268afd1eb419817106a37c9a87852228cadb752a64f2a",
  "previous_hash":"00000000000000000cea706491da61bc755a1250d7260becff5aafc9d26613f2",
  "previous_url":"https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000cea706491da61bc755a1250d7260becff5aafc9d26613f2",
  "peer_count":250,
  "unconfirmed_count":1794,
  "high_fee_per_kb":40018,
  "medium_fee_per_kb":26652,
  "low_fee_per_kb":12299,
  "last_fork_height":360362,
  "last_fork_hash":"000000000000000002d5cf67bfaa92ba5b371c1590eb48d25031c669ef6233a0"
}

General information about a blockchain is available by GET-ing the base resource.

Resource Method Return Object
/ GET Blockchain

The returned object contains a litany of information about the blockchain, including its height, the time/hash of the latest block, and more.

For more detailed information about the data returned, check the Blockchain object.

Block Hash Endpoint

curl https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412

{
"hash": "0000000000000000189bba3564a63772107b567...",
"height": 294322,
"chain": "BTC.main",
"total": 1146652915,
"fees": 130999,
"ver": 2,
"time": "2014-04-05T07:49:18Z",
"received_time": "2014-04-05T07:49:18Z",
"bits": 419486617,
"nonce": 1225187768,
"n_tx": 10,
"prev_block": "0000000000000000ced0958bd27720b71d3...",
"mrkl_root": "359d624d37aee1efa5662b7f5dbc390e996d...",
"txids": [
    "32b3b86e40d996b1f281e24e8d4af2ceacbf874c403836...",
    "1579f716359ba1a207f70248135f5e5fadf539be1dcf53...",
    ...,
],
"depth": 61793,
"prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0",
"tx_url": "https://api.blockcypher.com/v1/btc/main/txs/"
}
$.get('https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412')
  .then(function(d) {console.log(d)});
> {
> "hash": "0000000000000000189bba3564a63772107b567...",
> "height": 294322,
> "chain": "BTC.main",
> "total": 1146652915,
> "fees": 130999,
> "ver": 2,
> "time": "2014-04-05T07:49:18Z",
> "received_time": "2014-04-05T07:49:18Z",
> "bits": 419486617,
> "nonce": 1225187768,
> "n_tx": 10,
> "prev_block": "0000000000000000ced0958bd27720b71d3...",
> "mrkl_root": "359d624d37aee1efa5662b7f5dbc390e996d...",
> "txids": [
>   "32b3b86e40d996b1f281e24e8d4af2ceacbf874c403836...",
>   "1579f716359ba1a207f70248135f5e5fadf539be1dcf53...",
>   ...,
> ],
> "depth": 61793,
> "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0",
> "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/"
> }
> block_cypher.blockchain_block("0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412")
=> {"hash"=>"0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412",
 "height"=>294322,
 "chain"=>"BTC.main",
 "total"=>1146652915,
 "fees"=>130999,
 "ver"=>2,
 "time"=>"2014-04-05T07:49:18Z",
 "received_time"=>"2014-04-05T07:49:18Z",
 "bits"=>419486617,
 "nonce"=>1225187768,
 "n_tx"=>10,
 "prev_block"=>"0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0",
 "mrkl_root"=>"359d624d37aee1efa5662b7f5dbc390e996d561afc8148e8d716cf6ad765a952",
 "txids"=>
  ["32b3b86e40d996b1f281e24e8d4af2ceacbf874c4038369cc21baa807409b277",
   "1579f716359ba1a207f70248135f5e5fadf539be1dcf5300613aedcb6577d287",
   "dd1f183348eb41eaaa9ecf8012f9cca3ecbae41a6349f0cc4bfd2b1a497fa3d0",
   "749d12ccd180968b82aef4c271ca4effdf981d9b5d12523264457c9d4e6fa78e",
   "c4fe2ee16b8e3067d3d95caf7944011f4959781288b807df8bf853b7f80ed97c",
   "5a2114675265522d2b7ce8a7874cfa7a22ccc3fb6566a8599d6432c6805b1b5f",
   "077d851c8240671de80caa8be9f5285201c08a70edc5a45a9cd35fe7eaebf5e1",
   "6202cc55fbd9130e065c9294a5b2e061c26f3d2c8df56c32da605d9f183103f9",
   "ad3e7aa1c33f1d3e1c105d94f7b1542808da07bbe66b9621b050104a85dbf650",
   "36cc61016b9d1bd69768666f287db1edaa9b292fb442f152af7099305677230e"],
 "depth"=>66905,
 "prev_block_url"=>"https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0",
 "tx_url"=>"https://api.blockcypher.com/v1/btc/main/txs/"}
>>> from blockcypher import get_block_overview
>>> get_block_overview('0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412')
{
    "bits": 419486617, 
    "chain": "BTC.main", 
    "depth": 85570, 
    "fees": 130999, 
    "hash": "0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412", 
    "height": 294322, 
    "mrkl_root": "359d624d37aee1efa5662b7f5dbc390e996d561afc8148e8d716cf6ad765a952", 
    "n_tx": 10, 
    "nonce": 1225187768, 
    "prev_block": "0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0", 
    "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0", 
    "received_time": "datetime.datetime(2014, 4, 5, 7, 49, 18, 0, tzinfo=tzutc())", 
    "relayed_by": "", 
    "time": "datetime.datetime(2014, 4, 5, 7, 49, 18, 0, tzinfo=tzutc())", 
    "total": 1146652915, 
    "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", 
    "txids": [
        "32b3b86e40d996b1f281e24e8d4af2ceacbf874c4038369cc21baa807409b277", 
        "1579f716359ba1a207f70248135f5e5fadf539be1dcf5300613aedcb6577d287", 
        "dd1f183348eb41eaaa9ecf8012f9cca3ecbae41a6349f0cc4bfd2b1a497fa3d0", 
        "749d12ccd180968b82aef4c271ca4effdf981d9b5d12523264457c9d4e6fa78e", 
        "c4fe2ee16b8e3067d3d95caf7944011f4959781288b807df8bf853b7f80ed97c", 
        "5a2114675265522d2b7ce8a7874cfa7a22ccc3fb6566a8599d6432c6805b1b5f", 
        "077d851c8240671de80caa8be9f5285201c08a70edc5a45a9cd35fe7eaebf5e1", 
        "6202cc55fbd9130e065c9294a5b2e061c26f3d2c8df56c32da605d9f183103f9", 
        "ad3e7aa1c33f1d3e1c105d94f7b1542808da07bbe66b9621b050104a85dbf650", 
        "36cc61016b9d1bd69768666f287db1edaa9b292fb442f152af7099305677230e"
    ], 
    "ver": 2
}
# note that you can batch blocks with blockcypher.get_blocks_overview()
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    block, err := btc.GetBlock(0, "0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", block)
}

//Result from `go run`:
//{Hash:0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412 Height:294322 Depth:84560 Chain:BTC.main Total:1146652915 Fees:130999 Ver:2 Time:2014-04-05 07:49:18 +0000 UTC ReceivedTime:2014-04-05 07:49:18 +0000 UTC RelayedBy: Bits:419486617 Nonce:1225187768 NumTX:10 PrevBlock:0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0 MerkleRoot:359d624d37aee1efa5662b7f5dbc390e996d561afc8148e8d716cf6ad765a952 TXids:[32b3b86e40d996b1f281e24e8d4af2ceacbf874c4038369cc21baa807409b277 1579f716359ba1a207f70248135f5e5fadf539be1dcf5300613aedcb6577d287 dd1f183348eb41eaaa9ecf8012f9cca3ecbae41a6349f0cc4bfd2b1a497fa3d0 749d12ccd180968b82aef4c271ca4effdf981d9b5d12523264457c9d4e6fa78e c4fe2ee16b8e3067d3d95caf7944011f4959781288b807df8bf853b7f80ed97c 5a2114675265522d2b7ce8a7874cfa7a22ccc3fb6566a8599d6432c6805b1b5f 077d851c8240671de80caa8be9f5285201c08a70edc5a45a9cd35fe7eaebf5e1 6202cc55fbd9130e065c9294a5b2e061c26f3d2c8df56c32da605d9f183103f9 ad3e7aa1c33f1d3e1c105d94f7b1542808da07bbe66b9621b050104a85dbf650 36cc61016b9d1bd69768666f287db1edaa9b292fb442f152af7099305677230e] NextTXs:}
<?php
// Run on console:
// php -f .\sample\block-api\BlockHashEndpoint.php

$blockClient = new BlockClient($apiContext);
$block = $blockClient->get('0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412');

{
  "hash":"0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328",
  "height":293000,
  "chain":"BTC.main",
  "total":288801092067,
  "fees":6635337,
  "ver":2,
  "time":"2014-03-29T01:29:19Z",
  "received_time":"2014-03-29T01:29:19Z",
  "bits":419486617,
  "nonce":704197304,
  "n_tx":373,
  "prev_block":"0000000000000000b358b3b54788547080f49ed52392c2ed32a241951e2c9d5f",
  "mrkl_root":"5edf6a7e92e65d32843a79227042c215b875675fb92ff9613c90d6964fb069cd",
  "txids":[
    "7f00b52d075b3596cbd37ba5418640ace14a22ed6c5d154c4db5dd80e049b800",
    "a90d9bc04a4e6be53e0ddc47b043625a0bdc849ef3bc05f551bc05336de3a87c",
    ...
  ],
  "depth":67602,
  "prev_block_url":"https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000b358b3b54788547080f49ed52392c2ed32a241951e2c9d5f",
  "tx_url":"https://api.blockcypher.com/v1/btc/main/txs/",
  "next_txids":"https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328?txstart=20\u0026limit=20"
}

If you want more data on a particular block, you can use the Block Hash endpoint.

Resource Method Return Object
/blocks/$BLOCK_HASH GET Block
Flag Type Effect
txstart integer Filters response to only include transaction hashes after txstart in the block.
limit integer Filters response to only include a maximum of limit transactions hashes in the block. Maximum value allowed is 500.

BLOCK_HASH is a string representing the hash of the block you’re interested in querying, for example:

0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412

The returned object contains information about the block, including its height, the total amount of satoshis transacted within it, the number of transactions in it, transaction hashes listed in the canonical order in which they appear in the block, and more. For more detail on the data returned, check the Block object.

Block Height Endpoint

curl 'https://api.blockcypher.com/v1/btc/main/blocks/294322?txstart=1&limit=1'

{
"hash": "0000000000000000189bba3564a63772107b567...",
"height": 294322,
"chain": "BTC.main",
"total": 1146652915,
"fees": 130999,
"ver": 2,
"time": "2014-04-05T07:49:18Z",
"received_time": "2014-04-05T07:49:18Z",
"bits": 419486617,
"nonce": 1225187768,
"n_tx": 10,
"prev_block": "0000000000000000ced0958bd27720b71d3...",
"mrkl_root": "359d624d37aee1efa5662b7f5dbc390e996d...",
"txids": [
    "1579f716359ba1a207f70248135f5e5fadf539be1dcf53...",
],
"depth": 61793,
"prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0",
"tx_url": "https://api.blockcypher.com/v1/btc/main/txs/"
}
$.get('https://api.blockcypher.com/v1/btc/main/blocks/294322?txstart=1&limit=1')
  .then(function(d) {console.log(d)});
> {
> "hash": "0000000000000000189bba3564a63772107b567...",
> "height": 294322,
> "chain": "BTC.main",
> "total": 1146652915,
> "fees": 130999,
> "ver": 2,
> "time": "2014-04-05T07:49:18Z",
> "received_time": "2014-04-05T07:49:18Z",
> "bits": 419486617,
> "nonce": 1225187768,
> "n_tx": 10,
> "prev_block": "0000000000000000ced0958bd27720b71d3...",
> "mrkl_root": "359d624d37aee1efa5662b7f5dbc390e996d...",
> "txids": [
>   "1579f716359ba1a207f70248135f5e5fadf539be1dcf53...",
> ],
> "depth": 61793,
> "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0",
> "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/"
> }
> block_cypher.blockchain_block("294322", {"txstart"=>1,"limit"=>1})
=> {"hash"=>"0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412",
 "height"=>294322,
 "chain"=>"BTC.main",
 "total"=>1146652915,
 "fees"=>130999,
 "ver"=>2,
 "time"=>"2014-04-05T07:49:18Z",
 "received_time"=>"2014-04-05T07:49:18Z",
 "bits"=>419486617,
 "nonce"=>1225187768,
 "n_tx"=>10,
 "prev_block"=>"0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0",
 "mrkl_root"=>"359d624d37aee1efa5662b7f5dbc390e996d561afc8148e8d716cf6ad765a952",
 "txids"=>["1579f716359ba1a207f70248135f5e5fadf539be1dcf5300613aedcb6577d287"],
 "depth"=>66905,
 "prev_block_url"=>"https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0",
 "tx_url"=>"https://api.blockcypher.com/v1/btc/main/txs/",
 "next_txids"=>"https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412?txstart=2&limit=1"}
>>> from blockcypher import get_block_overview
>>> get_block_overview('294322', txn_limit=1, txn_offset=1)
{
    "bits": 419486617, 
    "chain": "BTC.main", 
    "depth": 85574, 
    "fees": 130999, 
    "hash": "0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412", 
    "height": 294322, 
    "mrkl_root": "359d624d37aee1efa5662b7f5dbc390e996d561afc8148e8d716cf6ad765a952", 
    "n_tx": 10, 
    "next_txids": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412?txstart=2&limit=1", 
    "nonce": 1225187768, 
    "prev_block": "0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0", 
    "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0", 
    "received_time": "datetime.datetime(2014, 4, 5, 7, 49, 18, 0, tzinfo=tzutc())", 
    "relayed_by": "", 
    "time": "datetime.datetime(2014, 4, 5, 7, 49, 18, 0, tzinfo=tzutc())", 
    "total": 1146652915, 
    "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", 
    "txids": [
        "1579f716359ba1a207f70248135f5e5fadf539be1dcf5300613aedcb6577d287"
    ], 
    "ver": 2
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //setting txstart to 1 and limit to 1
    block, err := btc.GetBlockPage(294322, "", 1, 1)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", block)
}

//Result from `go run`:
//{Hash:0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412 Height:294322 Depth:84560 Chain:BTC.main Total:1146652915 Fees:130999 Ver:2 Time:2014-04-05 07:49:18 +0000 UTC ReceivedTime:2014-04-05 07:49:18 +0000 UTC RelayedBy: Bits:419486617 Nonce:1225187768 NumTX:10 PrevBlock:0000000000000000ced0958bd27720b71d32c5847e40660aaca39f33c298abb0 MerkleRoot:359d624d37aee1efa5662b7f5dbc390e996d561afc8148e8d716cf6ad765a952 TXids:[1579f716359ba1a207f70248135f5e5fadf539be1dcf5300613aedcb6577d287] NextTXs:https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412?txstart=2&limit=1}
<?php
// Run on console:
// php -f .\sample\block-api\BlockHeightEndpoint.php

$blockClient = new BlockClient($apiContext);
$params = array(
    'txstart' => 1,
    'limit' => 1,
);
$block = $blockClient->get('293000', $params);

{
  "hash":"0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328",
  "height":293000,
  "chain":"BTC.main",
  "total":288801092067,
  "fees":6635337,
  "ver":2,
  "time":"2014-03-29T01:29:19Z",
  "received_time":"2014-03-29T01:29:19Z",
  "bits":419486617,
  "nonce":704197304,
  "n_tx":373,
  "prev_block":"0000000000000000b358b3b54788547080f49ed52392c2ed32a241951e2c9d5f",
  "mrkl_root":"5edf6a7e92e65d32843a79227042c215b875675fb92ff9613c90d6964fb069cd",
  "txids":[
    "a90d9bc04a4e6be53e0ddc47b043625a0bdc849ef3bc05f551bc05336de3a87c"
  ],
  "depth":67602,
  "prev_block_url":"https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000b358b3b54788547080f49ed52392c2ed32a241951e2c9d5f",
  "tx_url":"https://api.blockcypher.com/v1/btc/main/txs/",
  "next_txids":"https://api.blockcypher.com/v1/btc/main/blocks/0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328?txstart=2\u0026limit=1"
}

You can also query for information on a block using its height, using the same resource but with a different variable type.

Resource Method Return Object
/blocks/$BLOCK_HEIGHT GET Block
Flag Type Effect
txstart integer Filters response to only include transaction hashes after txstart in the block.
limit integer Filters response to only include a maximum of limit transactions hashes in the block. Maximum value allowed is 500.

BLOCK_HEIGHT is an integer representing the height of the block you’re interested in querying, for example:

294322

As above, the returned object contains information about the block, including its hash, the total amount of satoshis transacted within it, the number of transactions in it, transaction hashes listed in the canonical order in which they appear in the block, and more. For more detail on the data returned, check the Block object.

Feature Endpoint

curl https://api.blockcypher.com/v1/btc/main/feature/bip65?token=YOURTOKEN

{
  "name": "bip65",
  "state": "EXCLUSIVE",
  "last_transition_height": 388380,
  "last_transition_hash": "000000000000000009f886db2c7c12a497603e86378bace3ead93d350be3f38c"
}
Resource Method
/feature/$NAME GET

If you’re curious about the adoption of upgrade features on a blockchain, you can use this endpoint to get some information about its state on the network. For example, for bip65 on bitcoin, you could check its state via this URL: https://api.blockcypher.com/v1/btc/main/feature/bip65?token=YOURTOKEN. Generally speaking, for bitcoin, this will follow the form of tracking bipXX (where XX = a number), but the list of features we’re tracking is always changing.

Address API

BlockCypher’s Address API allows you to look up information about public addresses on the blockchain, generate single-use, low-value key pairs with corresponding addresses, help generate multisig addresses, and collect multiple addresses into a single shortcut for address viewing, all based on the coin/chain resource you’ve selected for your endpoints.

If you’re new to blockchains, you can think of public addresses as similar to bank account numbers in a traditional ledger. The biggest differences:

Address Balance Endpoint

curl https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD/balance

{
"address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
"total_received": 4433416,
"total_sent": 0,
"balance": 4433416,
"unconfirmed_balance": 0,
"final_balance": 4433416,
"n_tx": 7,
"unconfirmed_n_tx": 0,
"final_n_tx": 7
}
$.get('https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD/balance')
  .then(function(d) {console.log(d)});
> {
>   "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
>   "total_received": 4433416,
>   "total_sent": 0,
>   "balance": 4433416,
>   "unconfirmed_balance": 0,
>   "final_balance": 4433416,
>   "n_tx": 7,
>   "unconfirmed_n_tx": 0,
>   "final_n_tx": 7
> }
# Full balance
> block_cypher.address_balance("1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD")
=> {"address"=>"1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
 "total_received"=>4433416,
 "total_sent"=>0,
 "balance"=>4433416,
 "unconfirmed_balance"=>0,
 "final_balance"=>4433416,
 "n_tx"=>7,
 "unconfirmed_n_tx"=>0,
 "final_n_tx"=>7}

# Just final balance
> block_cypher.address_final_balance("1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD")
=> 4433416
>>> from blockcypher import get_address_overview
>>> get_address_overview('1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD')
{
    "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", 
    "balance": 4433416, 
    "final_balance": 4433416, 
    "final_n_tx": 7, 
    "n_tx": 7, 
    "total_received": 4433416, 
    "total_sent": 0, 
    "unconfirmed_balance": 0, 
    "unconfirmed_n_tx": 0
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    addr, err := btc.GetAddrBal("1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", nil)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", addr)
}

//Result from `go run`:
//{Address:1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD Wallet:{Name: Addresses:[]} HDWallet:{Name: ExtPubKey: SubchainIndexes:[] Chains:[]} TotalReceived:4443378 TotalSent:0 Balance:4443378 UnconfirmedBalance:0 FinalBalance:4443378 NumTX:8 UnconfirmedNumTX:0 FinalNumTX:8 TXs:[] TXRefs:[] UnconfirmedTXRefs:[] HasMore:false}
<?php
// Run on console:
// php -f .\sample\address-api\AddressBalanceEndpoint.php

$addressClient = new AddressClient($apiContext);
$addressBalance = $addressClient->getBalance('1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD');

{
  "address":"1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
  "total_received":4433416,
  "total_sent":0,
  "balance":4433416,
  "unconfirmed_balance":0,
  "final_balance":4433416,
  "n_tx":7,
  "unconfirmed_n_tx":0,
  "final_n_tx":7
}

The Address Balance Endpoint is the simplest—and fastest—method to get a subset of information on a public address.

Resource Method Return Object
/addrs/$ADDRESS/balance GET Address
Flag Type Effect
omitWalletAddresses bool If omitWalletAddresses is true and you’re querying a Wallet or HDWallet, the response will omit address information (useful to speed up the API call for larger wallets).

ADDRESS is a string representing the public address (or wallet/HD wallet name) you’re interested in querying, for example:

1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD

The returned object contains information about the address, including its balance in satoshis and the number of transactions associated with it. The endpoint omits any detailed transaction information, but if that isn’t required by your application, then it’s the fastest and preferred way to get public address information.

Address Endpoint

curl https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD

{
"address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
"total_received": 4433416,
"total_sent": 0,
"balance": 4433416,
"unconfirmed_balance": 0,
"final_balance": 4433416,
"n_tx": 7,
"unconfirmed_n_tx": 0,
"final_n_tx": 7,
"txrefs": [
{
  "tx_hash": "14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e",
  "block_height": 302013,
  "tx_input_n": -1,
  "tx_output_n": 0,
  "value": 20213,
  "ref_balance": 4433416,
  "spent": false,
  "confirmations": 63066,
  "confirmed": "2014-05-22T03:46:25Z",
  "double_spend": false
},
{
  "tx_hash": "4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869",
  "block_height": 302002,
  "tx_input_n": -1,
  "tx_output_n": 0,
  "value": 40596,
  "ref_balance": 4413203,
  "spent": false,
  "confirmations": 63077,
  "confirmed": "2014-05-22T02:56:08Z",
  "double_spend": false
},
...
],
"tx_url": "https://api.blockcypher.com/v1/btc/main/txs/"
}
$.get('https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD')
  .then(function(d) {console.log(d)});
> {
> "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
> "total_received": 4433416,
> "total_sent": 0,
> "balance": 4433416,
> "unconfirmed_balance": 0,
> "final_balance": 4433416,
> "n_tx": 7,
> "unconfirmed_n_tx": 0,
> "final_n_tx": 7,
> "txrefs": [
>   {
>   "tx_hash": "14b1052855bbf6561bc4db8aa501762...",
>   "block_height": 302013,
>   "tx_input_n": -1,
>   "tx_output_n": 0,
>   "value": 20213,
>   "ref_balance": 4433416,
>   "spent": false,
>   "confirmations": 55061,
>   "confirmed": "2014-05-22T03:46:25Z",
>   "double_spend": false
>   },
>   {
>   "tx_hash": "4cff011ec53022f2ae47197d1a2fd4a6...",
>   "block_height": 302002,
>   "tx_input_n": -1,
>   "tx_output_n": 0,
>   "value": 40596,
>   "ref_balance": 4413203,
>   "spent": false,
>   "confirmations": 55072,
>   "confirmed": "2014-05-22T02:56:08Z",
>   "double_spend": false
>   },
> ...
> ],
> "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/"
> }
> block_cypher.address_details("1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD")
=> {"address"=>"1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
 "total_received"=>4433416,
 "total_sent"=>0,
 "balance"=>4433416,
 "unconfirmed_balance"=>0,
 "final_balance"=>4433416,
 "n_tx"=>7,
 "unconfirmed_n_tx"=>0,
 "final_n_tx"=>7,
 "txrefs"=> [
  {"tx_hash"=>"14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e",
     "block_height"=>302013,
     "tx_input_n"=>-1,
     "tx_output_n"=>0,
     "value"=>20213,
   "ref_balance"=>4433416,
     "spent"=>false,
     "confirmations"=>59220,
     "confirmed"=>"2014-05-22T03:46:25Z",
     "double_spend"=>false},
    {"tx_hash"=>"4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869",
     "block_height"=>302002,
     "tx_input_n"=>-1,
     "tx_output_n"=>0,
     "value"=>40596,
   "ref_balance"=>4413203,
     "spent"=>false,
     "confirmations"=>59231,
     "confirmed"=>"2014-05-22T02:56:08Z",
     "double_spend"=>false},
    ...],
 "tx_url"=>"https://api.blockcypher.com/v1/btc/main/txs/"}
>>> from blockcypher import get_address_details
>>> get_address_details('1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD')
{
    "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", 
    "balance": 4433416, 
    "final_balance": 4433416, 
    "final_n_tx": 7, 
    "n_tx": 7, 
    "total_received": 4433416, 
    "total_sent": 0, 
    "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", 
    "txrefs": [
        {
            "block_height": 302013, 
            "confirmations": 77809, 
            "confirmed": "datetime.datetime(2014, 5, 22, 3, 46, 25, 0, tzinfo=tzutc())", 
            "double_spend": False, 
            "ref_balance": 4433416, 
            "spent": False, 
            "tx_hash": "14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e", 
            "tx_input_n": -1, 
            "tx_output_n": 0, 
            "value": 20213
        }, 
        {
            "block_height": 302002, 
            "confirmations": 77820, 
            "confirmed": "datetime.datetime(2014, 5, 22, 2, 56, 8, 0, tzinfo=tzutc())", 
            "double_spend": False, 
            "ref_balance": 4413203, 
            "spent": False, 
            "tx_hash": "4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869", 
            "tx_input_n": -1, 
            "tx_output_n": 0, 
            "value": 40596
        }, 
        ...

    ], 
    "unconfirmed_balance": 0, 
    "unconfirmed_n_tx": 0, 
    "unconfirmed_txrefs": []
}

package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    addr, err := btc.GetAddr("1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", nil)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", addr)
}

//Result from `go run`:
//{Address:1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD Wallet:{Name: Addresses:[]} HDWallet:{Name: ExtPubKey: SubchainIndexes:[] Chains:[]} TotalReceived:4443378 TotalSent:0 Balance:4443378 UnconfirmedBalance:0 FinalBalance:4443378 NumTX:8 UnconfirmedNumTX:0 FinalNumTX:8 TXs:[] TXRefs:[{Address: BlockHeight:382021 TXHash:ce53a6ed8b8f6b39cf86d4f300c12a33b69816014cc7261f4ced8b0e23bd4aeb TXInputN:-1 TXOutputN:2 Value:9962 Pref: Spent:false DoubleSpend:false DoubleOf: Confirmations:39103 Script: RefBalance:4443378 Confidence:0 Confirmed:2015-11-04 14:28:14 +0000 UTC SpentBy: Received:0001-01-01 00:00:00 +0000 UTC ReceivedCount:0} {Address: BlockHeight:302013 TXHash:14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e TXInputN:-1 TXOutputN:0 Value:20213 Pref: Spent:false DoubleSpend:false DoubleOf: Confirmations:119111 Script: RefBalance:4433416 Confidence:0 Confirmed:2014-05-22 03:46:25 +0000 UTC SpentBy: Received:0001-01-01 00:00:00 +0000 UTC ReceivedCount:0} {Address: BlockHeight:302002 TXHash:4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869 TXInputN:-1 TXOutputN:0 Value:40596 Pref: Spent:false DoubleSpend:false DoubleOf: Confirmations:119122 Script: RefBalance:4413203 Confidence:0 Confirmed:2014-05-22 02:56:08 +0000 UTC SpentBy: Received:0001-01-01 00:00:00 +0000 UTC ReceivedCount:0} {Address: BlockHeight:302002 TXHash:ea1cbb874ed4e40add51b4d65b877dc4e8d69bb63f5b2220a79d673c413b778a TXInputN:-1 TXOutputN:0 Value:101491 Pref: Spent:false DoubleSpend:false DoubleOf: Confirmations:119122 Script: RefBalance:4372607 Confidence:0 Confirmed:2014-05-22 02:56:08 +0000 UTC SpentBy: Received:0001-01-01 00:00:00 +0000 UTC ReceivedCount:0} {Address: BlockHeight:292586 TXHash:b4735a0690dab16b8789fceaf81c511f3be484e319f684cc214380eaa2851030 TXInputN:-1 TXOutputN:0 Value:3500000 Pref: Spent:false DoubleSpend:false DoubleOf: Confirmations:128538 Script: RefBalance:4271116 Confidence:0 Confirmed:2014-03-26 17:08:04 +0000 UTC SpentBy: Received:0001-01-01 00:00:00 +0000 UTC ReceivedCount:0} {Address: BlockHeight:292505 TXHash:0416b8db5db4fa088437008aea7889e966e326f11c52c1da95161cd2ded95185 TXInputN:-1 TXOutputN:0 Value:100000 Pref: Spent:false DoubleSpend:false DoubleOf: Confirmations:128619 Script: RefBalance:771116 Confidence:0 Confirmed:2014-03-26 04:18:38 +0000 UTC SpentBy: Received:0001-01-01 00:00:00 +0000 UTC ReceivedCount:0} {Address: BlockHeight:292455 TXHash:995a50e05d197be88d4da74160b4bcd2c363ebb1a49f95e572667d580bc70aba TXInputN:-1 TXOutputN:0 Value:500000 Pref: Spent:false DoubleSpend:false DoubleOf: Confirmations:128669 Script: RefBalance:671116 Confidence:0 Confirmed:2014-03-25 21:32:08 +0000 UTC SpentBy: Received:0001-01-01 00:00:00 +0000 UTC ReceivedCount:0} {Address: BlockHeight:292325 TXHash:0c83c8321537a7c79dc6214788944ba6cd5ea76f0594453b6251fcf1856f2e4b TXInputN:-1 TXOutputN:0 Value:171116 Pref: Spent:false DoubleSpend:false DoubleOf: Confirmations:128799 Script: RefBalance:171116 Confidence:0 Confirmed:2014-03-25 00:07:31 +0000 UTC SpentBy: Received:0001-01-01 00:00:00 +0000 UTC ReceivedCount:0}] UnconfirmedTXRefs:[] HasMore:false}
<?php

// Run on console:
// php -f .\sample\address-api\AddressEndpoint.php

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

{
  "address":"1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
  "total_received":4433416,
  "total_sent":0,
  "balance":4433416,
  "unconfirmed_balance":0,
  "final_balance":4433416,
  "n_tx":7,
  "unconfirmed_n_tx":0,
  "final_n_tx":7,
  "txrefs":[
    {
      "tx_hash":"14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e",
      "block_height":302013,
      "tx_input_n":-1,
      "tx_output_n":0,
      "value":20213,
      "ref_balance": 4433416,
      "spent":false,
      "confirmations":58584,
      "confirmed":"2014-05-22T03:46:25Z",
      "double_spend":false
    },
    ...
  ],
  "tx_url":"https://api.blockcypher.com/v1/btc/main/txs/"
}

The default Address Endpoint strikes a balance between speed of response and data on Addresses. It returns more information about an address’ transactions than the Address Balance Endpoint but doesn’t return full transaction information (like the Address Full Endpoint).

Resource Method Return Object
/addrs/$ADDRESS GET Address
Flag Type Effect
unspentOnly bool If unspentOnly is true, filters response to only include unspent transaction outputs (UTXOs).
includeScript bool If includeScript is true, includes raw script of input or output within returned TXRefs.
includeConfidence bool If true, includes the confidence attribute (useful for unconfirmed transactions) within returned TXRefs. For more info about this figure, check the Confidence Factor documentation.
before integer Filters response to only include transactions below before height in the blockchain.
after integer Filters response to only include transactions above after height in the blockchain.
limit integer limit sets the minimum number of returned TXRefs; there can be less if there are less than limit TXRefs associated with this address, but there can be more in the rare case of more TXRefs in the block at the bottom of your call. This ensures paging by block height never misses TXRefs. Defaults to 200, maximum is 2000.
confirmations integer If set, only returns the balance and TXRefs that have at least this number of confirmations.
confidence integer Filters response to only include TXRefs above confidence in percent; e.g., if this is set to 99, will only return TXRefs with 99% confidence or above (including all confirmed TXRefs). For more detail on confidence, check the Confidence Factor documentation.
omitWalletAddresses bool If omitWalletAddresses is true and you’re querying a Wallet or HDWallet, the response will omit address information (useful to speed up the API call for larger wallets).

ADDRESS is a string representing the public address (or wallet/HD wallet name) you’re interested in querying, for example:

1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD

The returned object contains information about the address, including its balance in satoshis, the number of transactions associated with it, and transaction inputs/outputs in descending order by block height—and if multiple transaction inputs/outputs associated with this address exist within the same block, by descending block index (position in block).

Address Full Endpoint

curl https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD/full?before=300000

{
"address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
"total_received": 4433416,
"total_sent": 0,
"balance": 4433416,
"unconfirmed_balance": 0,
"final_balance": 4433416,
"n_tx": 7,
"unconfirmed_n_tx": 0,
"final_n_tx": 7,
"txs": [
    {
    "block_hash": "0000000000000000af64802c79...",
    "block_height": 292586,
    "hash": "b4735a0690dab16b8789fceaf81c511f...",
    "addresses": [
        "18KXZzuC3xvz6upUMQpsZzXrBwNPWZjdSa",
        "1AAuRETEcHDqL4VM3R97aZHP8DSUHxpkFV",
        "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
        "1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG"
    ],
    "total": 3537488,
    "fees": 20000,
    "size": 438,
    "preference": "medium",
    "relayed_by": "",
    "confirmed": "2014-03-26T17:08:04Z",
    "received": "2014-03-26T17:08:04Z",
    "ver": 1,
    "lock_time": 0,
    "double_spend": false,
    "vin_sz": 2,
    "vout_sz": 2,
    "confirmations": 64492,
    "confidence": 1,
    "inputs": [
        {
        "prev_hash": "729f6469b59fea5da7...",
        "output_index": 0,
        "script": "483045022100d06cdad1a...",
        "output_value": 3500000,
        "sequence": 4294967295,
        "addresses": [
            "1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG"
        ],
        "script_type": "pay-to-pubkey-hash"
        },
        ...
    ],
    "outputs": [
        {
        "value": 3500000,
        "script": "76a9148629647bd642a237...",
        "addresses": [
            "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD"
        ],
        "script_type": "pay-to-pubkey-hash"
        },
        {
        "value": 37488,
        "script": "76a9145049e2ad94ed9c68...",
        "spent_by": "3ebe4bb294beaed58aca83...",
        "addresses": [
            "18KXZzuC3xvz6upUMQpsZzXrBwNPWZjdSa"
        ],
        "script_type": "pay-to-pubkey-hash"
        }
    ]
    },
    ...,
]
}
$.get('https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD/full?before=300000')
  .then(function(d) {console.log(d)});
> {
> "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
> "total_received": 4433416,
> "total_sent": 0,
> "balance": 4433416,
> "unconfirmed_balance": 0,
> "final_balance": 4433416,
> "n_tx": 7,
> "unconfirmed_n_tx": 0,
> "final_n_tx": 7,
> "txs": [
>   {
>   "block_hash": "0000000000000000af64802c79...",
>   "block_height": 292586,
>   "hash": "b4735a0690dab16b8789fceaf81c511f...",
>   "addresses": [
>       "18KXZzuC3xvz6upUMQpsZzXrBwNPWZjdSa",
>       "1AAuRETEcHDqL4VM3R97aZHP8DSUHxpkFV",
>       "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
>       "1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG"
>   ],
>   "total": 3537488,
>   "fees": 20000,
>   "size": 438,
>   "preference": "medium",
>   "relayed_by": "",
>   "confirmed": "2014-03-26T17:08:04Z",
>   "received": "2014-03-26T17:08:04Z",
>   "ver": 1,
>   "lock_time": 0,
>   "double_spend": false,
>   "vin_sz": 2,
>   "vout_sz": 2,
>   "confirmations": 64492,
>   "confidence": 1,
>   "inputs": [
>       {
>       "prev_hash": "729f6469b59fea5da7...",
>       "output_index": 0,
>       "script": "483045022100d06cdad1a...",
>       "output_value": 3500000,
>       "sequence": 4294967295,
>       "addresses": [
>           "1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG"
>       ],
>       "script_type": "pay-to-pubkey-hash"
>       },
>       ...
>   ],
>   "outputs": [
>       {
>       "value": 3500000,
>       "script": "76a9148629647bd642a237...",
>       "addresses": [
>           "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD"
>       ],
>       "script_type": "pay-to-pubkey-hash"
>       },
>       {
>       "value": 37488,
>       "script": "76a9145049e2ad94ed9c68...",
>       "spent_by": "3ebe4bb294beaed58aca83...",
>       "addresses": [
>           "18KXZzuC3xvz6upUMQpsZzXrBwNPWZjdSa"
>       ],
>       "script_type": "pay-to-pubkey-hash"
>       }
>   ]
>   },
>   ...,
> ]
> }
> block_cypher.address_full_txs("1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD")
=> {"address"=>"1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
 "total_received"=>4433416,
 "total_sent"=>0,
 "balance"=>4433416,
 "unconfirmed_balance"=>0,
 "final_balance"=>4433416,
 "n_tx"=>7,
 "unconfirmed_n_tx"=>0,
 "final_n_tx"=>7,
 "txs"=>[
  {"block_hash"=>"00000000000000006548ac8dc283c97e8165023dc1fdbbca2eaa75f0143f4a8c",
  "block_height"=>302013,
  "hash"=>"14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e",
  "addresses"=>["17astdTmG8zzVmry8mV8A7at Ar3XefEgRX", "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD"],
  "total"=>8835413,
  "fees"=>10000,
  "size"=>258,
  "preference"=>"medium",
  "relayed_by"=>"",
  "confirmed"=>"2014-05-22T03:46:25Z",
  "received"=>"2014-05-22T03:46:25Z",
  "ver"=>1,
  "lock_time"=>0,
  "double_spend"=>false,
    "vin_sz"=>1,
    "vout_sz"=>2,
    "confirmations"=>59221,
    "confidence"=>1,
    "inputs"=>[
     {"prev_hash"=>"4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869",
     "output_index"=>1,
     "script" =>"483045022035695e3b237733c70a5...",
     "output_value"=> 8845413,
     "sequence"=>4294967295,
     "addresses"=>["17astdTmG8zzVmry8mV8A7atAr3XefEgRX"],
     "script_type"=>"pay-to-pubkey-hash"}],
    "outputs"=>[
     {"value"=>20213,
     "script"=>"76a9148629647bd642a2372d846a7660e210c8414f047c88ac",
     "addresses"=>["1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD"],
     "script_type"=>"pay-to-pubkey-hash"},
     ... ]},
  ...
 ]}
>>> from blockcypher import get_address_full
>>> get_address_full(address='1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD', before_bh=300000)
{
    "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", 
    "balance": 4433416, 
    "final_balance": 4433416, 
    "final_n_tx": 7, 
    "n_tx": 7, 
    "total_received": 4433416, 
    "total_sent": 0, 
    "txs": [
        {
            "addresses": [
                "18KXZzuC3xvz6upUMQpsZzXrBwNPWZjdSa", 
                "1AAuRETEcHDqL4VM3R97aZHP8DSUHxpkFV", 
                "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", 
                "1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG"
            ], 
            "block_hash": "0000000000000000af64802c79f9b22e9091eb5548b4b662d5e444e61885923b", 
            "block_height": 292586, 
            "confidence": 1, 
            "confirmations": 87238, 
            "confirmed": "datetime.datetime(2014, 3, 26, 17, 8, 4, 0, tzinfo=tzutc())", 
            "double_spend": False, 
            "fees": 20000, 
            "hash": "b4735a0690dab16b8789fceaf81c511f3be484e319f684cc214380eaa2851030", 
            "inputs": [
                {
                    "addresses": [
                        "1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG"
                    ], 
                    "output_index": 0, 
                    "output_value": 3500000, 
                    "prev_hash": "729f6469b59fea5da77457f3291e2623c2516e3e8e7afc782687c6d59f4c5e41", 
                    "script": "483045022100d06cdad1a54081e8499a4117f9f52d7fbc83c679dda7e3c22c08e964915b7354022010a2d6af1601d28d33a456dab2bccf3fbde35b2f3a9db82f72d675c90d015571014104672a00c8ee6fa23d68094dd98188ea1491848498554a10e13194851b614168b225b28b7f5a1c6ba98b5463438ef030c48b60533031ff2de84104e549d8d06ea9", 
                    "script_type": "pay-to-pubkey-hash", 
                    "sequence": 4294967295
                }, 
                ...,

            ], 
            "lock_time": 0, 
            "outputs": [
                {
                    "addresses": [
                        "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD"
                    ], 
                    "script": "76a9148629647bd642a2372d846a7660e210c8414f047c88ac", 
                    "script_type": "pay-to-pubkey-hash", 
                    "value": 3500000
                }, 
                ...,
            ], 
            "preference": "medium", 
            "received": "datetime.datetime(2014, 3, 26, 17, 8, 4, 0, tzinfo=tzutc())", 
            "relayed_by": "", 
            "size": 438, 
            "total": 3537488, 
            "ver": 1, 
            "vin_sz": 2, 
            "vout_sz": 2
        }, 
        ...,
    ], 
    "unconfirmed_balance": 0, 
    "unconfirmed_n_tx": 0
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    addr, err := btc.GetAddrFull("1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", nil)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", addr)
}

//Result from `go run`:
//{Address:1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD Wallet:{Name: Addresses:[]} HDWallet:{Name: ExtPubKey: SubchainIndexes:[] Chains:[]} TotalReceived:4443378 TotalSent:0 Balance:4443378 UnconfirmedBalance:0 FinalBalance:4443378 NumTX:8 UnconfirmedNumTX:0 FinalNumTX:8 TXs:[{BlockHash:000000000000000000768df6acbfc5b3bc18bcf3154a3e3ce02772b01d03de50 BlockHeight:382021 Hash:ce53a6ed8b8f6b39cf86d4f300c12a33b69816014cc7261f4ced8b0e23bd4aeb Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD 1FhCLQK2ZXtCUQDtG98p6fVH7S6mxAsEey 1LL74HS54ptRdWFUodXMceRbu5Ls4Q4Bhb 1Lj3WeRAmyN98jyiWE6AtnMKfzUzrPUL9z] Total:124916 Fees:10000 Size:505 Preference:low RelayedBy:107.170.13.184:8333 Received:2015-11-04 14:06:13.945 +0000 UTC Confirmed:2015-11-04 14:28:14 +0000 UTC Confirmations:39103 Confidence:1 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:2 VoutSize:4 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:c00be7265d1ffba6ca2b870e463b5b44829b5bcdfc72a785e1ba946c6dd6d6ae OutputIndex:0 OutputValue:127948 Addresses:[1LL74HS54ptRdWFUodXMceRbu5Ls4Q4Bhb] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:4730440220271259e739026dd93fff75775fee0ee990ff4de1421d256c8af2ae46f64361a30220689f19d354cba767e204802034e4053cd478d05806aee89583ef5ad4a2fe0044014104270a9e314b83bc2df501bd0ecfe21b521780be7ffc11f939395c9dade09a14a91e59d81889b0ccf76ce15f1be2eabe63774ee1b4268b07e6b930531bd0e6bc87 Age:0 WalletName:} {PrevHash:03f87b4c20d5283dd944404f2132fd616bac23cfe9c701caa27c65156ee56ec7 OutputIndex:0 OutputValue:6968 Addresses:[1LL74HS54ptRdWFUodXMceRbu5Ls4Q4Bhb] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:483045022100c1b4c608e2f33ad730aba6fe6c93f0d25d33af8509027457b81a0c91950f4d3c02201fc0fb2a43a66673680bc9027acda3a2174b80fa6d397b6a93d2293844d17cb6014104270a9e314b83bc2df501bd0ecfe21b521780be7ffc11f939395c9dade09a14a91e59d81889b0ccf76ce15f1be2eabe63774ee1b4268b07e6b930531bd0e6bc87 Age:0 WalletName:}] Outputs:[{SpentBy: Value:18056 Addresses:[1Lj3WeRAmyN98jyiWE6AtnMKfzUzrPUL9z] ScriptType:pay-to-pubkey-hash Script:76a914d85df4dafe54bea74b59c65bc594b0c3231d836e88ac DataHex: DataString:} {SpentBy: Value:11622 Addresses:[1FhCLQK2ZXtCUQDtG98p6fVH7S6mxAsEey] ScriptType:pay-to-pubkey-hash Script:76a914a12bdc6beab772eb7a6abacfd3ae5574fc1c8cc388ac DataHex: DataString:} {SpentBy: Value:9962 Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] ScriptType:pay-to-pubkey-hash Script:76a9148629647bd642a2372d846a7660e210c8414f047c88ac DataHex: DataString:} {SpentBy:83c1a2baf462e89831cb61309fb30051288a8eefb2d230464bfe6a8e4c316c61 Value:85276 Addresses:[1LL74HS54ptRdWFUodXMceRbu5Ls4Q4Bhb] ScriptType:pay-to-pubkey-hash Script:76a914d4075955fbad83455e88d6e7d737bb55fd60ebae88ac DataHex: DataString:}]} {BlockHash:00000000000000006548ac8dc283c97e8165023dc1fdbbca2eaa75f0143f4a8c BlockHeight:302013 Hash:14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e Addresses:[17astdTmG8zzVmry8mV8A7atAr3XefEgRX 1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] Total:8835413 Fees:10000 Size:258 Preference:medium RelayedBy: Received:2014-05-22 03:46:25 +0000 UTC Confirmed:2014-05-22 03:46:25 +0000 UTC Confirmations:119111 Confidence:1 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:1 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869 OutputIndex:1 OutputValue:8845413 Addresses:[17astdTmG8zzVmry8mV8A7atAr3XefEgRX] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:483045022035695e3b237733c70a56286eccd8df41b4d22cd103ed9b2df44010caa3bc71430221008f58461c937e8fe6cc6d37a9aaee3927762cce4565a4c386bbcd9d82915acfc50141047b1d511b8559a2003ca88715bc8331f057fa4ebf11f411142509a8ffd2f2d36d5a5e4b6019d6eb3e16878f24fd8d55676050c28b4bc5e4c44f39245beedae100 Age:0 WalletName:}] Outputs:[{SpentBy: Value:20213 Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] ScriptType:pay-to-pubkey-hash Script:76a9148629647bd642a2372d846a7660e210c8414f047c88ac DataHex: DataString:} {SpentBy:582a50f3a756c3261f8f085185e5975a762e239e95a30bcf1a4f2e31e0f834ab Value:8815200 Addresses:[17astdTmG8zzVmry8mV8A7atAr3XefEgRX] ScriptType:pay-to-pubkey-hash Script:76a9144838f65fc4e06c644423ad0430de11ca5785dcd088ac DataHex: DataString:}]} {BlockHash:00000000000000006d3bdfe1127d541110a18ce5b54bcdeb51e10399f6ec00b2 BlockHeight:302002 Hash:4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869 Addresses:[17astdTmG8zzVmry8mV8A7atAr3XefEgRX 1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] Total:8886009 Fees:10000 Size:258 Preference:medium RelayedBy: Received:2014-05-22 02:56:08 +0000 UTC Confirmed:2014-05-22 02:56:08 +0000 UTC Confirmations:119122 Confidence:1 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:1 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:ea1cbb874ed4e40add51b4d65b877dc4e8d69bb63f5b2220a79d673c413b778a OutputIndex:1 OutputValue:8896009 Addresses:[17astdTmG8zzVmry8mV8A7atAr3XefEgRX] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:483045022100f50d876c0f213f99319752d4381c1be341f187bf32c53e2e89fae0df34bce2a202206d1f73005cdd6dcaab3cd74ef3870950202623e976b737f75980e91447fea7cc0141047b1d511b8559a2003ca88715bc8331f057fa4ebf11f411142509a8ffd2f2d36d5a5e4b6019d6eb3e16878f24fd8d55676050c28b4bc5e4c44f39245beedae100 Age:0 WalletName:}] Outputs:[{SpentBy: Value:40596 Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] ScriptType:pay-to-pubkey-hash Script:76a9148629647bd642a2372d846a7660e210c8414f047c88ac DataHex: DataString:} {SpentBy:14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e Value:8845413 Addresses:[17astdTmG8zzVmry8mV8A7atAr3XefEgRX] ScriptType:pay-to-pubkey-hash Script:76a9144838f65fc4e06c644423ad0430de11ca5785dcd088ac DataHex: DataString:}]} {BlockHash:00000000000000006d3bdfe1127d541110a18ce5b54bcdeb51e10399f6ec00b2 BlockHeight:302002 Hash:ea1cbb874ed4e40add51b4d65b877dc4e8d69bb63f5b2220a79d673c413b778a Addresses:[17astdTmG8zzVmry8mV8A7atAr3XefEgRX 1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] Total:8997500 Fees:10000 Size:259 Preference:medium RelayedBy: Received:2014-05-22 02:56:08 +0000 UTC Confirmed:2014-05-22 02:56:08 +0000 UTC Confirmations:119122 Confidence:1 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:1 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:306541aa7848b9f909282eb5134d3aa3221feed8e8022b5bf7807cbb17a9191d OutputIndex:1 OutputValue:9007500 Addresses:[17astdTmG8zzVmry8mV8A7atAr3XefEgRX] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:493046022100fedde3515293f587c4dd9358fe7471ceef091bc0c9dcbedf1894c7caadbcf3d3022100aefa4608d4fe76270c02a8491f170fe30011e29e7235739d73c51d4c06247da00141047b1d511b8559a2003ca88715bc8331f057fa4ebf11f411142509a8ffd2f2d36d5a5e4b6019d6eb3e16878f24fd8d55676050c28b4bc5e4c44f39245beedae100 Age:0 WalletName:}] Outputs:[{SpentBy: Value:101491 Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] ScriptType:pay-to-pubkey-hash Script:76a9148629647bd642a2372d846a7660e210c8414f047c88ac DataHex: DataString:} {SpentBy:4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869 Value:8896009 Addresses:[17astdTmG8zzVmry8mV8A7atAr3XefEgRX] ScriptType:pay-to-pubkey-hash Script:76a9144838f65fc4e06c644423ad0430de11ca5785dcd088ac DataHex: DataString:}]} {BlockHash:0000000000000000af64802c79f9b22e9091eb5548b4b662d5e444e61885923b BlockHeight:292586 Hash:b4735a0690dab16b8789fceaf81c511f3be484e319f684cc214380eaa2851030 Addresses:[18KXZzuC3xvz6upUMQpsZzXrBwNPWZjdSa 1AAuRETEcHDqL4VM3R97aZHP8DSUHxpkFV 1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD 1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG] Total:3537488 Fees:20000 Size:438 Preference:medium RelayedBy: Received:2014-03-26 17:08:04 +0000 UTC Confirmed:2014-03-26 17:08:04 +0000 UTC Confirmations:128538 Confidence:1 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:2 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:729f6469b59fea5da77457f3291e2623c2516e3e8e7afc782687c6d59f4c5e41 OutputIndex:0 OutputValue:3500000 Addresses:[1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:483045022100d06cdad1a54081e8499a4117f9f52d7fbc83c679dda7e3c22c08e964915b7354022010a2d6af1601d28d33a456dab2bccf3fbde35b2f3a9db82f72d675c90d015571014104672a00c8ee6fa23d68094dd98188ea1491848498554a10e13194851b614168b225b28b7f5a1c6ba98b5463438ef030c48b60533031ff2de84104e549d8d06ea9 Age:0 WalletName:} {PrevHash:45b74e542799343fc5ae70b715b7dd402da3a50fec766a9ebeb0879153db10ff OutputIndex:1 OutputValue:57488 Addresses:[1AAuRETEcHDqL4VM3R97aZHP8DSUHxpkFV] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:48304502203deee40f705127eb57de0bb1bb998376e11f09bbde663c614d9cf746948f9b740221008715b8df9fa6c33fad7bfa2bb72875c8e30002a61843f430b9f0af268c136e2a0141046b29997ba1e1974f88d4513257ed4021205a94cc20ef7c1c6c7b8510becb68085220b213b8864ebfb465b614a4e7719b29d81c9849aea37343962cda47945a16 Age:0 WalletName:}] Outputs:[{SpentBy: Value:3500000 Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] ScriptType:pay-to-pubkey-hash Script:76a9148629647bd642a2372d846a7660e210c8414f047c88ac DataHex: DataString:} {SpentBy:3ebe4bb294beaed58aca834af5e8148248abd9c6c6b56d9c73c2f25eb6a4838f Value:37488 Addresses:[18KXZzuC3xvz6upUMQpsZzXrBwNPWZjdSa] ScriptType:pay-to-pubkey-hash Script:76a9145049e2ad94ed9c683b8f6ca67db33b979dd6d13a88ac DataHex: DataString:}]} {BlockHash:00000000000000001528e12ffb2bdfc46f739c864952d85258485511d3d0aba3 BlockHeight:292505 Hash:0416b8db5db4fa088437008aea7889e966e326f11c52c1da95161cd2ded95185 Addresses:[13UrVoMywxv9yaFBWvPfZ6kugWAZhLsnKo 1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD 1DUgQLCoJowWkcDCW13ZGSAELyr6jFG7AP 1NqW3Jk1w4RisMrBs53g9bK1Rnmi2zMcfC] Total:217176 Fees:20000 Size:438 Preference:medium RelayedBy: Received:2014-03-26 04:18:38 +0000 UTC Confirmed:2014-03-26 04:18:38 +0000 UTC Confirmations:128619 Confidence:1 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:2 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:df959bf4b6faa51aedde7de2d23309c147a1637e89afd36cb8f3f35149943a75 OutputIndex:0 OutputValue:100000 Addresses:[1DUgQLCoJowWkcDCW13ZGSAELyr6jFG7AP] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:49304602210087cfe517c22a4001230cffadf62a0e59d286b76c343f7dfa69daf4be3e4f3562022100d15fe4dc85428850af24789c50c43e95e96d3ff27ee066823ba4dbffb4e8f02f014104c40f18fab1dcc621e78e65b02f20d0e7413e95b9de60bb6c9f32dc3bc0f2ddc9b67ba1cc2e2fafc0ee14cdcd55c97c31501b4c6dde91c37135c50ff7fbec9e5a Age:0 WalletName:} {PrevHash:6b9f0e8f326bab57d56dc455dc10b00fbd5167a00475549759882b554d7217f7 OutputIndex:1 OutputValue:137176 Addresses:[13UrVoMywxv9yaFBWvPfZ6kugWAZhLsnKo] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:473044022051a83d1b8bcec5093652e51eb2d51f87572a0181c65d12b6f374ca06769b70100220447a771160387584da21a22e8d3a51ff8e2fc03538af64b6d88d23b8ea28fa99014104ac5249d12d65eb0062a13d722420f881b06c732f1a820a9962035d9f87992114bf14208552a293c2bf669c969676dfef3f36b16fff30e3deb0fb6b432092691d Age:0 WalletName:}] Outputs:[{SpentBy: Value:100000 Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] ScriptType:pay-to-pubkey-hash Script:76a9148629647bd642a2372d846a7660e210c8414f047c88ac DataHex: DataString:} {SpentBy:5c82a033cbfa9149836840036a392566a8c7b4dfcb0c2c4c0a20993f69b49340 Value:117176 Addresses:[1NqW3Jk1w4RisMrBs53g9bK1Rnmi2zMcfC] ScriptType:pay-to-pubkey-hash Script:76a914ef86d94a858cd446ba7f0cd78d32677ffcc436a988ac DataHex: DataString:}]} {BlockHash:0000000000000000651ba18b29a1a7543d8fb9f6240d57b9e740014f51053ebc BlockHeight:292455 Hash:995a50e05d197be88d4da74160b4bcd2c363ebb1a49f95e572667d580bc70aba Addresses:[1CzuqkzUg1ybSsVaR3NWrEoXLxYtXdG35V 1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] Total:299990000 Fees:10000 Size:226 Preference:medium RelayedBy: Received:2014-03-25 21:32:08 +0000 UTC Confirmed:2014-03-25 21:32:08 +0000 UTC Confirmations:128669 Confidence:1 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:1 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:7c72a7f748ad3d407b977ba1004855ed14367e1a9c9a3fdb916a24302f075421 OutputIndex:0 OutputValue:300000000 Addresses:[1CzuqkzUg1ybSsVaR3NWrEoXLxYtXdG35V] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:4830450221009336f886851ea3026f8d8836fc3c1a8d9d9456075ac440259410803767a4995a02202eee3c52aafa034d8058a236eabc3feaf80be5d8b3011bab192ee7856cee9d1b0121033a148923bf45432ab6cdbcb198abb8d23be28c5aa2ff3c6405837a9a9e4ef031 Age:0 WalletName:}] Outputs:[{SpentBy: Value:500000 Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] ScriptType:pay-to-pubkey-hash Script:76a9148629647bd642a2372d846a7660e210c8414f047c88ac DataHex: DataString:} {SpentBy:3743ba41fc279cda244ec1bb5a75fba1352968870b2957cd5508a7e5b64dc94f Value:299490000 Addresses:[1CzuqkzUg1ybSsVaR3NWrEoXLxYtXdG35V] ScriptType:pay-to-pubkey-hash Script:76a914839d33de1bbd7807a03bcadbacd135316351330788ac DataHex: DataString:}]} {BlockHash:00000000000000006caa894c02a7254475acaefd5adf50d97de97f85470620db BlockHeight:292325 Hash:0c83c8321537a7c79dc6214788944ba6cd5ea76f0594453b6251fcf1856f2e4b Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD 1HBB6wHbhHBmsNmoBzzKdq77LKQUcUhGp3] Total:2990000 Fees:10000 Size:259 Preference:medium RelayedBy: Received:2014-03-25 00:07:31 +0000 UTC Confirmed:2014-03-25 00:07:31 +0000 UTC Confirmations:128799 Confidence:1 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:1 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:ed21bb99e2df321c3e28d9ec5e11010d86a5dcf02412e989ae9dbc0f5b4ff3ff OutputIndex:0 OutputValue:3000000 Addresses:[1HBB6wHbhHBmsNmoBzzKdq77LKQUcUhGp3] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:493046022100c1eec2a231f42f0034d7c8cc479e20967214a4e9fc6da0b95ccdcc9de3e8d2e8022100a0f80d26f71dd625f262d74c9adc74412273df4e34aaacf33c44550ba545641c0141040f60c5ea2ba9bf92637083449caa13be32ebdcc55e94ddb2d1923cf704019d80e56f48800b9e6cb9d10835f10dd4426aeac8f410877a3a1f8a94caad45187c0e Age:0 WalletName:}] Outputs:[{SpentBy: Value:171116 Addresses:[1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD] ScriptType:pay-to-pubkey-hash Script:76a9148629647bd642a2372d846a7660e210c8414f047c88ac DataHex: DataString:} {SpentBy:d035e58aa0a1f174ff2c2a0d8213f6e95102c3448e122ce4b48fcd72c9af4c41 Value:2818884 Addresses:[1HBB6wHbhHBmsNmoBzzKdq77LKQUcUhGp3] ScriptType:pay-to-pubkey-hash Script:76a914b16e9aec76e2dcca9a64b5615f9f334e2250c6df88ac DataHex: DataString:}]}] TXRefs:[] UnconfirmedTXRefs:[] HasMore:false}
<?php
// Run on console:
// php -f .\sample\address-api\AddressFullEndpoint.php

$addressClient = new AddressClient($apiContext);
$fullAddress = $addressClient->getFullAddress('1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD');

{
  "address":"1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD",
  "total_received":4433416,
  "total_sent":0,
  "balance":4433416,
  "unconfirmed_balance":0,
  "final_balance":4433416,
  "n_tx":7,
  "unconfirmed_n_tx":0,
  "final_n_tx":7,
  "txs":[
    {
      "block_hash":"00000000000000006548ac8dc283c97e8165023dc1fdbbca2eaa75f0143f4a8c",
      "block_height":302013,
      "hash":"14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e",
      "addresses":[
        "17astdTmG8zzVmry8mV8A7atAr3XefEgRX",
        "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD"
      ],
      "total":8835413,
      "fees":10000,
      "size":258,
      "preference":"medium",
      "relayed_by":"",
      "confirmed":"2014-05-22T03:46:25Z",
      "received":"2014-05-22T03:46:25Z",
      "ver":1,
      "lock_time":0,
      "double_spend":false,
      "vin_sz":1,
      "vout_sz":2,
      "confirmations":58588,
      "confidence":1,
      "inputs":[
        {
          "prev_hash":"4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869",
          "output_index":1,
          "script":"483045022035695e3b237733c70a56286eccd8df41b4d22cd103ed9b2df44010caa3bc71430221008f58461c937e8fe6cc6d37a9aaee3927762cce4565a4c386bbcd9d82915acfc50141047b1d511b8559a2003ca88715bc8331f057fa4ebf11f411142509a8ffd2f2d36d5a5e4b6019d6eb3e16878f24fd8d55676050c28b4bc5e4c44f39245beedae100",
          "output_value":8845413,
          "sequence":4294967295,
          "addresses":[
            "17astdTmG8zzVmry8mV8A7atAr3XefEgRX"
          ],
          "script_type":"pay-to-pubkey-hash"
        }
      ],
      "outputs":[
        {
          "value":20213,
          "script":"76a9148629647bd642a2372d846a7660e210c8414f047c88ac",
          "addresses":[
            "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD"
          ],
          "script_type":"pay-to-pubkey-hash"
        },
        {
          "value":8815200,
          "script":"76a9144838f65fc4e06c644423ad0430de11ca5785dcd088ac",
          "spent_by":"582a50f3a756c3261f8f085185e5975a762e239e95a30bcf1a4f2e31e0f834ab",
          "addresses":[
            "17astdTmG8zzVmry8mV8A7atAr3XefEgRX"
          ],
          "script_type":"pay-to-pubkey-hash"
        }
      ]
    },
    ...
  ]
}

The Address Full Endpoint returns all information available about a particular address, including an array of complete transactions instead of just transaction inputs and outputs. Unfortunately, because of the amount of data returned, it is the slowest of the address endpoints, but it returns the most detailed data record.

Resource Method Return Object
/addrs/$ADDRESS/full GET Address
Flag Type Effect
before integer Filters response to only include transactions below before height in the blockchain.
after integer Filters response to only include transactions above after height in the blockchain.
limit integer limit sets the minimum number of returned TXs; there can be less if there are less than limit TXs associated with this address, but there can also be more in the rare case of more TXs in the block at the bottom of your call. This ensures paging by block height never misses TXs. Defaults to 10, maximum is 50.
txlimit integer This filters the TXInputs/TXOutputs within the returned TXs to include a maximum of txlimit items.
confirmations integer If set, only returns the balance and TXs that have at least this number of confirmations.
confidence integer Filters response to only include TXs above confidence in percent; e.g., if this is set to 99, will only return TXs with 99% confidence or above (including all confirmed TXs). For more detail on confidence, check the Confidence Factor documentation.
includeHex bool If true, includes hex-encoded raw transaction for each TX; false by default.
includeConfidence bool If true, includes the confidence attribute (useful for unconfirmed transactions) within returned TXs. For more info about this figure, check the Confidence Factor documentation.
omitWalletAddresses bool If omitWalletAddresses is true and you’re querying a Wallet or HDWallet, the response will omit address information (useful to speed up the API call for larger wallets).

ADDRESS is a string representing the public address (or wallet/HD wallet name) you’re interested in querying, for example:

1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD

The returned object contains information about the address, including its balance in satoshis, the number of transactions associated with it, and the corresponding full transaction records in descending order by block height—and if multiple transactions associated with this address exist within the same block, by descending block index (position in block).

Generate Address Endpoint

curl -X POST https://api.blockcypher.com/v1/btc/test3/addrs

{
"private": "81ee75559d37cbe4b7cbbfb9931ab1ba32172c5cdfc3ac2d020259b4c1104198",
"public": "0231ff9ec76820cb36b69061f6ffb125db3793b4aced468a1261b0680e1ef4883a",
"address": "mvpW7fMSi1nbZhJJDySNS2PUau8ppnu4kY",
"wif": "cRwGhRjCuuNtPgLcoYd1CuAqjFXCV5YNCQ1LB8RsFCvu61VfSsgR"
}
$.post('https://api.blockcypher.com/v1/btc/test3/addrs')
  .then(function(d) {console.log(d)});
> {
> "private": "81ee75559d37cbe4b7cbbfb9931ab1ba32172c5cdfc3ac2d020259b4c1104198",
> "public": "0231ff9ec76820cb36b69061f6ffb125db3793b4aced468a1261b0680e1ef4883a",
> "address": "mvpW7fMSi1nbZhJJDySNS2PUau8ppnu4kY",
> "wif": "cRwGhRjCuuNtPgLcoYd1CuAqjFXCV5YNCQ1LB8RsFCvu61VfSsgR"
> }
> block_cypher.address_generate
=> {"private"=>"39c8788ef9815d061a2a4528817b3c23730b1129e5ca60032138061f35483951",
 "public"=>"039dc801dd76a7fa03789e0fe8efdd7e0857e73fa4ae38a294a60002ef949e83c4",
 "address"=>"1FdQDEnHXibwMMMKaaNGrhrcujJNZyszUN",
 "wif"=>"KyA2uUUMZkiRcSTx3PE1pBeMFgyifpxswcJu3Q7fVwXXZmvh48JA"}
# Please use a python library such as https://github.com/sbuss/bitmerchant to securely generate an address client-side
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    addrKeys, err := btc.GenAddrKeychain()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", addrKeys)
}

//Result from `go run`:
//{Address:18P5PFbuevRn4G3X27LF9ZEcfW3pKgy1Yp Private:b833a204a295c26dd19e49a0cc9fbb2f6475a886b7dc5b47b78261aa0ce07d94 Public:03685bbf3756a89240e7fa2b1312c48dc7b0c455116b9cc3e463b53643716396d5 Wif:L3Pmu1ZnRMUWmDoiXecA4m1gPhVwFMgm7CirQxWxxb437nQhESbT PubKeys:[] ScriptType:}
<?php
// Run on console:
// php -f .\sample\address-api\GenerateAddressEndpoint.php

$addressClient = new AddressClient($apiContext);
$addressKeyChain = $addressClient->generateAddress();

{
  "private":"3f3cea5a7373011d6f51844bf986abe6950d7a30eaaab247fc951c3ea9f13705",
  "public":"02d1c8ccc7131a3c39b9e7001741f68d339e5d6941caf31fe9f43b15d6cf09dcb9",
  "address":"1rA7AB93qziWzHfTFXn5n3GYJ1mhkG8tn",
  "wif":"KyLdumvGqB86v3D9sKqAMGhNXB1UtYSsxb9deH1nxpooskVF7Rgz"
}

The Generate Address endpoint allows you to generate private-public key-pairs along with an associated public address. No information is required with this POST request.

Resource Method Request Object Return Object
/addrs POST nil AddressKeychain

The returned object contains a private key in hex-encoded and wif-encoded format, a public key, and a public address.

Generate Multisig Address Endpoint

curl -d '{"pubkeys": ["02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3", "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea", "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"], "script_type": "multisig-2-of-3"}' https://api.blockcypher.com/v1/btc/main/addrs

{
"private": "",
"public": "",
"address": "3BF1M1PnTge94QewuWh3B8mRVw8U4SVnb4",
"wif": "",
"pubkeys": [
    "02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3",
    "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea",
    "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"
],
"script_type": "multisig-2-of-3"
}
var data = {
  "pubkeys": [
    "02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3",
    "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea",
    "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"
  ],
  "script_type": "multisig-2-of-3"
};
$.post('https://api.blockcypher.com/v1/btc/test3/addrs', JSON.stringify(data))
  .then(function(d) {console.log(d)});
> {
> "private": "",
> "public": "",
> "address": "3BF1M1PnTge94QewuWh3B8mRVw8U4SVnb4",
> "wif": "",
> "pubkeys": [
>   "02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3",
>   "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea",
>   "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"
> ],
> "script_type": "multisig-2-of-3"
> }
> block_cypher.address_generate_multi(["02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3", "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea", "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"], "multisig-2-of-3")
=> {"private"=>"",
 "public"=>"",
 "address"=>"3BF1M1PnTge94QewuWh3B8mRVw8U4SVnb4",
 "wif"=>"",
 "pubkeys"=>
  ["02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3",
   "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea",
   "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"],
 "script_type"=>"multisig-2-of-3"}
>>> from blockcypher import generate_multisig_address
>>> pubkey_list = ['02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3', '033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea', '022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca']
>>> generate_multisig_address(pubkey_list=pubkey_list, script_type='multisig-2-of-3')
{
    "address": "3BF1M1PnTge94QewuWh3B8mRVw8U4SVnb4", 
    "private": "", 
    "pubkeys": [
        "02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3", 
        "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea", 
        "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"
    ], 
    "public": "", 
    "script_type": "multisig-2-of-3", 
    "wif": ""
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    addrKeys, err := btc.GenAddrMultisig(gobcy.AddrKeychain{PubKeys: []string{"02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3", "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea", "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"}, ScriptType: "multisig-2-of-3"})
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", addrKeys)
}

//Result from `go run`:
//{Address:3BF1M1PnTge94QewuWh3B8mRVw8U4SVnb4 Private: Public: Wif: PubKeys:[02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3 033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea 022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca] ScriptType:multisig-2-of-3}
<?php
// Run on console:
// php -f .\sample\address-api\GenerateMultisigAddressEndpoint.php

$addressClient = new AddressClient($apiContext);
$pubkeys = array(
    "02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3",
    "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea",
    "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"
);
$addressKeyChain = $addressClient->generateMultisigAddress($pubkeys, 'multisig-2-of-3');

{
  "pubkeys":[
    "02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3",
    "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea",
    "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"
  ],
  "script_type":"multisig-2-of-3",
  "private":"",
  "public":"",
  "address":"3BF1M1PnTge94QewuWh3B8mRVw8U4SVnb4",
  "wif":""
}

The Generate Multisig Address Endpoint is a convenience method to help you generate multisig addresses from multiple public keys. After supplying a partially filled-out AddressKeychain object (including only an array of hex-encoded public keys and the script type), the returned object includes the computed public address.

Resource Method Request Object Return Object
/addrs POST AddressKeychain AddressKeychain

Wallet API

The Wallet API allows you to group multiple addresses under a single name. It only holds public address information and never requires any private keys.

A normal Wallet can be created, deleted, and have addresses added and removed. The Wallet itself can have any custom name as long as it does not start with the standard address prefix (1 or 3 for Bitcoin).

Hierarchical Deterministic (HD) Wallets

We also offer support for HD Wallets, which make it easy to manage multiple addresses under a single name. All HD wallet addresses are derived from a single seed. Please see BIP32 for more background on HD wallets.

HD Wallets can be created, deleted, and have new addresses generated. However, unlike normal Wallets, addresses cannot be removed.

When creating a wallet, one can optionally include one or more “subchain” indexes. These subchains can later be referenced when generating new addresses or sending txs. If none are provided in wallet creation, the wallet will derive & use addresses straight from the given extended pubkey. If no index is given when using the wallet with other APIs, it defaults to using the wallet’s first (sub) chain.

In BIP32 notation, the wallet layout is m/0, m/1, … and m/i/0, m/i/1, … for each subchain i if the wallet has subchains. For example, the path of the fourth address generated is m/3 for a non-subchain wallet. The path of the fourth address at subchain index two is m/2/3. Note that this is different from the default BIP32 wallet layout.

If you want to use BIP32 default wallet layout you can submit the extended public key of m/0’ (which can only be derived from your master private key) with subchain indexes = [0, 1]. Subchain index 0 represents the external chain (of account 0) and will discover all k keypairs that look like: m/0’/0/k. Subchain index 1 represents the internal chain (of account 0) and will discover all k keypairs in m/0’/1/k.

If you want to use BIP 44 layout (for BTC), you can submit the extended public key of m/44’/0’/0’. (which can only be derived from your master private key) with subchain indexes = [0, 1]. Subchain index 0 represents the external chain (of account 0) and will discover all k keypairs in m/44’/0’/0’/0/k. Subchain index 1 represents the internal chain (of account 0) and will discover all k keypairs in m/44’/0’/0’/1/k.

If an address ahead of current addresses listed in an HD Wallet receives a transaction, it will be added, along with any addresses between the new address and the last used one. We limit looking ahead to 20 addresses; if more than 20 addresses are skipped for the next payment to an HD Wallet, it won’t be detected/added to the HD Wallet.

Using Wallets

Both HD Wallets and normal Wallets can be leveraged by the Address API, just by using their $NAME instead of $ADDRESS. They can also be used with Events and with the Transaction API. In general, using a wallet instead of an address in an API will have the effect of batching the set of addresses contained in the wallet.

The following code examples should be considered serially; that is to say, the results will appear as if each API call were done sequentially. Also, $NAME is a string representing the name of your wallet, for example:

alice

As you’ll see in the examples, if you’re using HD Wallets, take care to use the appropriate resource (e.g. /wallets/hd instead of /wallets ).

Create Wallet Endpoint

# normal wallet
curl -d '{"name": "alice","addresses": ["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]}' https://api.blockcypher.com/v1/btc/main/wallets?token=YOURTOKEN

{"token": "YOURTOKEN",
"name": "alice",
"addresses": [
    "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
]}

# hd wallet
curl -d '{"name": "bob", "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"}' https://api.blockcypher.com/v1/btc/main/wallets/hd?token=YOURTOKEN

{"token": "YOURTOKEN",
"name": "bob",
"hd": true,
"extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
"chains": [
    {"chain_addresses": [
        {
            "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
            "path": "m/0"
        },
        {
            "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
            "path": "m/1"
        },
        {
            "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
            "path": "m/2"
        }
    ]}
]}

# hd wallet with subchains
curl -d '{"name": "catheryne", "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", "subchain_indexes": [1, 3]}' https://api.blockcypher.com/v1/btc/main/wallets/hd?token=YOURTOKEN

{"token": "YOURTOKEN",
"name": "catheryne",
"hd": true,
"extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
"subchain_indexes": [ 1, 3 ],
"chains": [
    {
        "index": 1,
        "chain_addresses": []
    },
    {
        "index": 3,
        "chain_addresses": []
    }
]}
//normal wallet
var data = {"name": "alice","addresses": ["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]};
$.post('https://api.blockcypher.com/v1/btc/main/wallets?token=USERTOKEN', JSON.stringify(data))
  .then(function(d) {console.log(d)});
> {"token": "USERTOKEN",
> "name": "alice",
> "addresses": [
>   "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
> ]}

//hd wallet
var data = {"name": "bob", "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8" };
$.post('https://api.blockcypher.com/v1/btc/main/wallets/hd?token=USERTOKEN', JSON.stringify(data))
  .then(function(d) {console.log(d)});
> {"token": "YOURTOKEN",
> "name": "bob",
> "hd": true,
> "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
> "chains": [
>   {"chain_addresses": [
>       {
>           "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
>           "path": "m/0"
>       },
>       {
>           "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
>           "path": "m/1"
>       },
>       {
>           "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
>           "path": "m/2"
>       }
>   ]}
> ]}
> block_cypher.wallet_create("alice",["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"])
=> {"token"=>"YOURTOKEN", "name"=>"alice", "addresses"=>["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]}

# TODO: ruby hd wallet example
# Regular wallet
>>> from blockcypher import create_wallet_from_address
>>> create_wallet_from_address(wallet_name='alice', address='1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e', api_key='YOUR_TOKEN')
{
    "addresses": [
        "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
    ], 
    "name": "alice", 
    "token": "YOUR_TOKEN"
}

# HD wallet
>>> from blockcypher import create_hd_wallet
>>> create_hd_wallet(wallet_name='bob', xpubkey='xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8', api_key='YOUR_TOKEN')
{
    "chains": [
        {
            "chain_addresses": [
                {
                    "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc", 
                    "path": "m/0"
                }, 
                {
                    "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT", 
                    "path": "m/1"
                }, 
                {
                    "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb", 
                    "path": "m/2"
                }
            ]
        }
    ], 
    "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", 
    "hd": True, 
    "name": "bob", 
    "token": "YOUR_TOKEN"
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //normal wallet
    alice, err := btc.CreateWallet(gobcy.Wallet{"alice", []string{"1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"}})
    //hdwallet
    bob, err := btc.CreateHDWallet(gobcy.HDWallet{Name: "bob", ExtPubKey: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"})
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("Normal Wallet:%+v\nHDWallet: %+v\n", alice, bob)
}

//Result from `go run`:
//Normal Wallet:{Name:alice Addresses:[1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e]}
//HDWallet: {Name:bob ExtPubKey:xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8 SubchainIndexes:[] Chains:[{ChainAddr:[{Address:1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc Path:m/0 Public:} {Address:1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT Path:m/1 Public:} {Address:1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb Path:m/2 Public:}] Index:0}]}
<?php
// normal wallet
// Run on console:
// php -f .\sample\wallet-api\CreateWalletEndpoint.php

// Create a new instance of Wallet object
$wallet = new Wallet();
$wallet->setName('alice');
$wallet->setAddresses(array(
    "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
));

$walletClient = new WalletClient($apiContext);
$createdWallet = $walletClient->create($wallet);

{
  "token":"c0afcccdde5081d6429de37d16166ead",
  "name":"alice",
  "addresses":[
    "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
  ]
}

// hd wallet
// Run on console:
// php -f .\sample\wallet-api\CreateHDWalletEndpoint.php

// Create a new instance of HDWallet object
$wallet = new HDWallet();
$wallet->setName('bob');
$wallet->setExtendedPublicKey('xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8');

$walletClient = new HDWalletClient($apiContext);
$createdWallet = $walletClient->create($wallet);

{"token": "c0afcccdde5081d6429de37d16166ead",
"name": "bob",
"hd": true,
"extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
"chains": [
    {"chain_addresses": [
        {
            "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
            "path": "m/0"
        },
        {
            "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
            "path": "m/1"
        },
        {
            "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
            "path": "m/2"
        }
    ]}
]}
Resource Method Request Object Return Object
/wallets POST Wallet Wallet
/wallets/hd POST HDWallet HDWallet

This endpoint allows you to create a new wallet, by POSTing a partially filled out Wallet or HDWallet object, depending on the endpoint.

For normal wallets, at minimum, you must include the name attribute and at least one public address in the addresses array.

For HD wallets, at minimum, you must include the name and the extended_public_key attributes. The encoding of the key is documented here. You can optionally include subchain_indexes to initialize the wallet with one or more subchains. If not given, the wallet will derive address straight from the given extended pubkey. See BIP32 for more info.

If successful, it will return the same Wallet or HDWallet object you requested, appended with your user token.

List Wallets Endpoint

curl https://api.blockcypher.com/v1/btc/main/wallets?token=YOURTOKEN
{
"wallet_names": [
        "alice",
        "bob",
        "catheryne"
    ]
}
$.get('https://api.blockcypher.com/v1/btc/main/wallets?token=YOURTOKEN')
  .then(function(d) {console.log(d)});
> {
> "wallet_names": [
>       "alice"
>       "bob",
>       "catheryne"
>   ]
> }
# TODO: ruby examples
>>> from blockcypher import list_wallet_names
>>> list_wallet_names('YOUR_TOKEN')
{
    "wallet_names": [
        "alice",
        "bob",
        "catheryne"
    ]
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    walletNames, err := btc.ListWallets()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("Wallets:%v\n", walletNames)
}

//Result from `go run`:
//Wallets: [alice catheryne bob]
<?php
//TODO: php examples
Resource Method Return Object
/wallets GET {“wallet_names”:$NAMEARRAY}

This endpoint returns a string array ($NAMEARRAY) of active wallet names (both normal and HD) under the token you queried. You can then query detailed information on individual wallets (via their names) by leveraging the Get Wallet Endpoint.

Get Wallet Endpoint

# normal wallet
curl https://api.blockcypher.com/v1/btc/main/wallets/alice?token=YOURTOKEN

{"token":"YOURTOKEN",
"name":"alice",
"addresses": [ "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]}

# hd wallet
curl https://api.blockcypher.com/v1/btc/main/wallets/hd/bob?token=YOURTOKEN

{"token": "YOURTOKEN",
"name": "bob",
"hd": true,
"extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
"chains": [{
    "chain_addresses": [
        {
            "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
            "path": "m/0"
        },
        {
            "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
            "path": "m/1"
        },
        {
            "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
            "path": "m/2"
        }
    ]}
]}
$.get('https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=YOURTOKEN')
  .then(function(d) {console.log(d)});
> {
> "token":"YOURTOKEN",
> "name":"alice",
> "addresses": [
>   "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
> ]}

//hd wallet
$.get('https://api.blockcypher.com/v1/btc/main/wallets/hd/bob?token=USERTOKEN')
  .then(function(d) {console.log(d)});
> {"token": "YOURTOKEN",
> "name": "bob",
> "hd": true,
> "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
> "chains": [
>   {"chain_addresses": [
>       {
>           "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
>           "path": "m/0"
>       },
>       {
>           "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
>           "path": "m/1"
>       },
>       {
>           "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
>           "path": "m/2"
>       }
>   ]}
> ]}
> block_cypher.wallet_get("alice")
=> {"token"=>"YOURTOKEN", "name"=>"alice", "addresses"=>["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]}

//TODO: hd wallet example
# Regular wallet
>>> from blockcypher import get_wallet_addresses
>>> get_wallet_addresses(wallet_name='alice', api_key='YOUR_TOKEN')
{
    "addresses": [
        "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
    ], 
    "name": "alice", 
    "token": "YOUR_TOKEN"
}

# HD wallet
>>> from blockcypher import get_wallet_addresses
>>> get_wallet_addresses(wallet_name='bob', api_key='YOUR_TOKEN', is_hd_wallet=True)
{
    "chains": [
        {
            "chain_addresses": [
                {
                    "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc", 
                    "path": "m/0"
                }, 
                {
                    "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT", 
                    "path": "m/1"
                }, 
                {
                    "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb", 
                    "path": "m/2"
                }
            ]
        }
    ], 
    "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", 
    "hd": True, 
    "name": "bob", 
    "token": "YOUR_TOKEN"
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //normal wallet
    alice, err := btc.GetWallet("alice")
    //hdwallet
    bob, err := btc.GetHDWallet("bob")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("Normal Wallet: %v\nHDWallet: %v\n", alice, bob)
}

//Result from `go run`:
//Normal Wallet: {alice [1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e]}
//HDWallet: {bob xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8 [] [{[{1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc m/0 } {1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT m/1 } {1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb m/2 }] 0}]}
<?php
// normal wallet
// Run on console:
// php -f .\sample\wallet-api\GetWalletEndpoint.php

$walletClient = new WalletClient($apiContext);
$wallet = $walletClient->get('alice');

{
  "token":"c0afcccdde5081d6429de37d16166ead",
  "name":"alice",
  "addresses":[
    "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
  ]
}

// hd wallet
// Run on console:
// php -f .\sample\wallet-api\GetHDWalletEndpoint.php

$walletClient = new HDWalletClient($apiContext);
$wallet = $walletClient->get('bob');

{"token": "c0afcccdde5081d6429de37d16166ead",
"name": "bob",
"hd": true,
"extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
"chains": [
    {"chain_addresses": [
        {
            "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
            "path": "m/0"
        },
        {
            "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
            "path": "m/1"
        },
        {
            "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
            "path": "m/2"
        }
    ]}
]}
Resource Method Return Object
/wallets/$NAME GET Wallet
/wallets/hd/$NAME GET HDWallet

This endpoint returns a Wallet or HDWallet based on its $NAME.

Add Addresses to Wallet Endpoint

curl -d '{"addresses": ["13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"]}' https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=YOURTOKEN

{"token": "YOURTOKEN",
"name": "alice",
"addresses": [
    "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e",
    "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"
]}
var data = {"addresses": ["13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"]};
$.post('https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=USERTOKEN', JSON.stringify(data))
  .then(function(d) {console.log(d)});
> {
>   "token": "USERTOKEN",
>   "name": "alice",
>   "addresses": [
>       "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e",
>       "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"
> ]}
> block_cypher.wallet_add_addr("alice",["13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"])
=> {"token"=>"YOURTOKEN", "name"=>"alice", "addresses"=>["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e", "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"]}
>>> from blockcypher import add_address_to_wallet
>>> add_address_to_wallet(wallet_name='alice', address='13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j', api_key='YOUR_TOKEN')
{
    "addresses": [
        "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e", 
        "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"
    ], 
    "name": "alice", 
    "token": "YOUR_TOKEN"
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //normal wallet
    alice, err := btc.AddAddrWallet("alice", []string{"13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"}, false)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", alice)
}

//Result from `go run`:
//{Name:alice Addresses:[13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j 1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e]}
<?php
// Run on console:
// php -f .\sample\wallet-api\AddAddressesToWalletEndpoint.php

$walletClient = new WalletClient($apiContext);
$addressList = AddressList::fromAddressesArray(array(
    "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"
));
$wallet = $walletClient->addAddresses('alice', $addressList);

{
  "token":"c0afcccdde5081d6429de37d16166ead",
  "name":"alice",
  "addresses":[
    "1jr1rHMthQVMNSYswB9ExSvYn339fWMzn",
    "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"
  ]
}
Resource Method Request Object Return Object
/wallets/$NAME/addresses POST Wallet Wallet
Flag Type Effect
omitWalletAddresses bool If omitWalletAddresses is true, the response will omit address information (useful to speed up the API call for larger wallets).

This endpoint allows you to add public addresses to the $NAME wallet, by POSTing a partially filled out Wallet object. You only need to include the additional addresses in a new addresses array in the object. If successful, it will return the newly modified Wallet, including an up-to-date, complete listing of addresses.

Get Wallet Addresses Endpoint

#normal wallet
curl https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=YOURTOKEN

{"addresses": [
    "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j",
    "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
]}

#hd wallet
curl https://api.blockcypher.com/v1/btc/main/wallets/hd/bob/addresses?token=YOURTOKEN

{"chains": [
    {"chain_addresses": [
        {
            "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
            "path": "m/0"
        },
        {
            "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
            "path": "m/1"
        },
        {
            "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
            "path": "m/2"
        }]
    }
]}
//normal wallet
$.get('https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=USERTOKEN')
  .then(function(d) {console.log(d)});
> {
> "addresses": [
>   "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j",
>   "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
> ]}

//hd wallet
$.get('https://api.blockcypher.com/v1/btc/main/wallets/hd/bob/addresses?token=USERTOKEN')
  .then(function(d) {console.log(d)});
> {"chains": [
>   {"chain_addresses": [
>       {
>           "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
>           "path": "m/0"
>       },
>       {
>           "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
>           "path": "m/1"
>       },
>       {
>           "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
>           "path": "m/2"
>       }]
>   }
> ]}
> block_cypher.wallet_get_addr("alice")
=> {"addresses"=>["13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j", "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]}

# TODO: ruby hd example
# Regular wallet
>>> from blockcypher import get_wallet_addresses
>>> get_wallet_addresses(wallet_name='alice', api_key='YOUR_TOKEN')
{
    "addresses": [
        "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j", 
        "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"
    ]
}

# HD wallet
>>> from blockcypher import get_wallet_addresses
>>> get_wallet_addresses(wallet_name='alice', api_key='YOUR_TOKEN', is_hd_wallet=True)
{
    "chains": [
        {
            "chain_addresses": [
                {
                    "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc", 
                    "path": "m/0"
                }, 
                {
                    "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT", 
                    "path": "m/1"
                }, 
                {
                    "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb", 
                    "path": "m/2"
                }
            ]
        }
    ]
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //normal wallet
    alice, err := btc.GetAddrWallet("alice", false, false, false, false)
    //hdwallet
    bob, err := btc.GetAddrHDWallet("bob", false, false, false, false)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("Normal Wallet: %+v\nHD Wallet: %+v\n", alice, bob)
}

//Result from `go run`:
//Normal Wallet: [13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j 1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e]
//HD Wallet: {Name: ExtPubKey: SubchainIndexes:[] Chains:[{ChainAddr:[{Address:1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc Path:m/0 Public:} {Address:1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT Path:m/1 Public:} {Address:1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb Path:m/2 Public:}] Index:0}]}
<?php
// normal wallet
// Run on console:
// php -f .\sample\wallet-api\WalletAddressesEndpoint.php

$walletClient = new WalletClient($apiContext);
$addressList = $walletClient->getWalletAddresses('alice');

{"addresses":[
    "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j",
    "1jr1rHMthQVMNSYswB9ExSvYn339fWMzn"
]}

// hd wallet
// Run on console:
// php -f .\sample\wallet-api\GetHDWalletAddressesEndpoint.php

$walletClient = new HDWalletClient($apiContext);
$addressList = $walletClient->getWalletAddresses('bob');

{"chains": [
    {"chain_addresses": [
        {
            "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc",
            "path": "m/0"
        },
        {
            "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT",
            "path": "m/1"
        },
        {
            "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb",
            "path": "m/2"
        }]
    }
]}
Resource Method Return Object
/wallets/$NAME/addresses GET Wallet
/wallets/hd/$NAME/addresses GET HDChain
Flag Type Effect
used bool Returns only used addresses if set to true and only unused if false. Only valid on HD wallets.
zerobalance bool Returns only addresses with zero balance if set to true and only addresses with non-zero balance if false. Only valid on HD wallets.

This endpoint returns a list of the addresses associated with the $NAME wallet. It returns the addresses in a partially filled out Wallet which you’ll find under the addresses attribute. For HD wallets it returns an HDChain object.

Remove Addresses from Wallet Endpoint

#pipe to grep to check status code
$ curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=USERTOKEN&address=1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e | grep "HTTP/1.1"

HTTP/1.1 204 OK
$.ajax({
  url: "https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=USERTOKEN&address=1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e",
  method: "DELETE"
})
> block_cypher.wallet_delete_addr("alice",["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"])
=> nil
>>> from blockcypher import remove_address_from_wallet
>>> remove_address_from_wallet(wallet_name='alice', address='1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e', api_key='YOUR_TOKEN')
True
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //normal wallet only
    err := btc.DeleteAddrWallet("alice", []string{"1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"})
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Printf("Address deleted")
    }
}

//Result from `go run`:
//Address deleted
<?php
// Run on console:
// php -f .\sample\wallet-api\RemoveAddressesFromWalletEndpoint.php

$walletClient = new WalletClient($apiContext);
// List of addresses to be removed from the wallet
$addressList = AddressList::fromAddressesArray(array(
    "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"
));
$wallet = $walletClient->removeAddresses('alice', $addressList);

{
  "token":"c0afcccdde5081d6429de37d16166ead",
  "name":"alice",
  "addresses":[
    "1jr1rHMthQVMNSYswB9ExSvYn339fWMzn"
  ]
}
Resource Method Return Object
/wallets/$NAME/addresses?address=$ADDRESS DELETE nil

This endpoint allows you to delete an $ADDRESS associated with the $NAME wallet. As a reminder, you can batch multiple addresses by appending them with semicolons within the $ADDRESS URL parameter. If successful, it will return an HTTP 204 status code with no return object.

Generate Address in Wallet Endpoint

curl -X POST https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses/generate?token=YOURTOKEN

{"token": "YOURTOKEN",
"name": "alice",
"addresses": [
    "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j",
    "14LcPtRSGjYb1s8kfxsVDbXvA7VYCmoFho"
],
"private": "6238efeb679d75ec3b1a43e76cc0ed33abdf56e30bb5bb95e4793134a7958609",
"public": "03e4f273521a30373a639f60da836f2308a5d53853ec18f903dd235c73e6e26e4a",
"address": "14LcPtRSGjYb1s8kfxsVDbXvA7VYCmoFho",
"wif": "KzWeDL7sysRay7pZUm6hQQLaDVjmN1jUZzeZuq6ru5FtN1RhPrLX"}
$.post('https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses/generate?token=USERTOKEN')
  .then(function(d) {console.log(d)});
> {
>   "token": "USERTOKEN",
>   "name": "alice",
>   "addresses": [
>       "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j",
>       "14LcPtRSGjYb1s8kfxsVDbXvA7VYCmoFho"
>   ],
>   "private": "6238efeb679d75ec3b1a43e76cc0ed33abdf56e30bb5bb95e4793134a7958609",
>   "public": "03e4f273521a30373a639f60da836f2308a5d53853ec18f903dd235c73e6e26e4a",
>   "address": "14LcPtRSGjYb1s8kfxsVDbXvA7VYCmoFho",
>   "wif": "KzWeDL7sysRay7pZUm6hQQLaDVjmN1jUZzeZuq6ru5FtN1RhPrLX"
> }
> block_cypher.wallet_gen_addr("alice")
=> {"token"=>"YOURTOKEN",
 "name"=>"alice",
 "addresses"=>["13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j", "1Bq7QRwfa36p5DGSe6UBy4PYmsEtQhpqC8"],
 "private"=>"f371f0a43f46a09ec2351fb1fc23450167d6031dbadef56f7174dc1e0285fed9",
 "public"=>"037318b43fc83f3af24b5d88c8e4e33ebbdea62c3a3f6eb3a9830e2bb1f6682108",
 "address"=>"1Bq7QRwfa36p5DGSe6UBy4PYmsEtQhpqC8",
 "wif"=>"L5NwFyFdHqfBYhaQDttym6b3tXeaKaH7cepgAJunWrkKY24NUCjb"}
# Please use a python library such as https://github.com/blockcypher/blockcypher-python to securely generate an address client-side
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //normal wallet only
    alice, addr, err := btc.GenAddrWallet("alice")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("Wallet: %+v\nNew Address: %+v\n", alice, addr)
}

//Result from `go run`:
//Wallet: {Name:alice Addresses:[13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j 14KLgDRAEHdk5ggRUDcqeZNfJHu2cCoU5D]}
//New Address: {Address:14KLgDRAEHdk5ggRUDcqeZNfJHu2cCoU5D Private:b8202b67710cef1990ca3dfe04e2bf5e3484e6d6a4725c46e86b7f8b3e4b3f20 Public:0226a990df828225f1fbb608313a4a08db75ddfbf73a5f9a5ed9da8d38c89923b2 Wif:L3PdKr1QRFD8uxfXrkTVUrd6LznocDpwgY1JQsFCpYTrzT4do3KJ PubKeys:[] ScriptType:}
<?php
// Run on console:
// php -f .\sample\wallet-api\GenerateAddressInWalletEndpoint.php

$walletClient = new WalletClient($apiContext);
$walletGenerateAddressResponse = $walletClient->generateAddress('alice');

{
  "token":"c0afcccdde5081d6429de37d16166ead",
  "name":"alice",
  "addresses":[
    "1jr1rHMthQVMNSYswB9ExSvYn339fWMzn",
    "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"
  ],
  "private":"0d42eb9fa80301aa3a5c4e91d2a5c892b4fb99b10bc1f0d636d46ecba32d37e6",
  "public":"030b4780c12784456291191318b231dcce64c93f8eb211fa78eb7e95663009e414",
  "address":"1GuPv187EEUi3BDypdpMS7cmMuaVpWy6PM",
  "wif":"KwfVLLsRSgSC6pkDLkEmMn8fH5VFceaYT9B58Cu8QHZtZzJvnpYZ"
}
Resource Method Request Object Return Object
/wallets/$NAME/addresses/generate POST nil Wallet + AddressKeychain

This endpoint allows you to generate a new address associated with the $NAME wallet, similar to the Generate Address Endpoint. If successful, it will returned the newly modified Wallet composed with an AddressKeychain.

Only works for regular Wallets; for HD Wallets, use the Derive Address endpoint specified below.

Derive Address in Wallet Endpoint

curl -X POST https://api.blockcypher.com/v1/btc/main/wallets/hd/bob/addresses/derive?token=YOURTOKEN

{
"chains": [
    {"chain_addresses": [
        {
            "address": "19urzZsoBNsomSfj68PUUGLXDz261tK5Jo",
            "public": "02c85080e00080aa933f93a2718bba9f01fd6fdc8e4712a155849f5ba588666471",
            "path": "m/3"
        }
    ]}
]}

#with subchain_index
curl -X POST 'https://api.blockcypher.com/v1/btc/main/wallets/hd/catheryne/addresses/derive?token=YOURTOKEN&subchain_index=1'

{
"chains": [
    {"index":1,
    "chain_addresses": [
    {
      "address": "1NwEtFZ6Td7cpKaJtYoeryS6avP2TUkSMh",
      "public": "029b393153a1ec68c7af3a98e88aecede3a409f27e698c090540098611c79e05b0",
      "path": "m/1/0"
    }
  ]}
]}
//todo: javascript hd derive examples
# todo: ruby hd derive examples
>>> from blockcypher import derive_hd_address
>>> derive_hd_address(api_key='YOUR_TOKEN', wallet_name='bob', coin_symbol='btc')
{
    "chains": [
        {
            "chain_addresses": [
                {
                    "address": "19urzZsoBNsomSfj68PUUGLXDz261tK5Jo", 
                    "path": "m/3", 
                    "public": "02c85080e00080aa933f93a2718bba9f01fd6fdc8e4712a155849f5ba588666471"
                }
            ]
        }
    ]
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //hdwallet only
    bob, err := btc.DeriveAddrHDWallet("bob", 1, false, 0)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("Parital HD Wallet: %+v\n", bob)
}

//Result from `go run`:
//Partial HD Wallet: {Name: ExtPubKey: SubchainIndexes:[] Chains:[{ChainAddr:[{Address:19urzZsoBNsomSfj68PUUGLXDz261tK5Jo Path:m/3 Public:02c85080e00080aa933f93a2718bba9f01fd6fdc8e4712a155849f5ba588666471}] Index:0}]}
// Run on console:
// php -f .\sample\wallet-api\GenerateAddressInHDWalletEndpoint.php

$walletClient = new HDWalletClient($apiContext);
$hdWalletGenerateAddressResponse = $walletClient->generateAddress('bob');

// with subchain_index
// Run on console:
// php -f .\sample\wallet-api\GenerateAddressInHDWalletWithSubchainIndexEndpoint.php

$walletClient = new HDWalletClient($apiContexts['BTC.main']);
$params = array('subchain_index' => 1);
$hdWalletGenerateAddressResponse = $walletClient->generateAddress('bob', $params);
Resource Method Request Object Return Object
/wallets/hd/$NAME/addresses/derive POST nil Partial HDWallet
Flag Type Effect
count integer Number of addresses to derive. If not set, default is one address.
subchain_index integer Derives address(es) on this specific subchain. If not set, address will be generated on the first chain in the HD wallet.

This endpoint allows you to derive a new address (or multiple addresses) associated with the $NAME HD Wallet. If successful, it will return an HDWallet but only with the newly derived address(es) represented in its chains field to limit the data transmitted; for the full address list after derivation, you can follow up this API call with the Get Wallet Addresses Endpoint.

Only works for HD Wallets; for regular wallets, use the Generate Address in Wallet endpoint specified above.

Delete Wallet Endpoint

# normal wallet, pipe to grep to check status code
curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/wallets/alice?token=YOURTOKEN | grep "HTTP/1.1"

HTTP/1.1 204 OK

# hd wallet
curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/wallets/hd/bob?token=YOURTOKEN | grep "HTTP/1.1"

HTTP/1.1 204 OK
//normal wallet
$.ajax({
  url: "https://api.blockcypher.com/v1/btc/main/wallets/alice?token=USERTOKEN",
  method: "DELETE"
});

//hd wallet
$.ajax({
  url: "https://api.blockcypher.com/v1/btc/main/wallets/hd/bob?token=USERTOKEN",
  method: "DELETE"
});
> block_cypher.wallet_delete("alice")
=> nil

# TODO: Ruby hd wallet example
# Regular wallet
>>> from blockcypher import delete_wallet
>>> delete_wallet(wallet_name='alice', api_key='YOUR_TOKEN')
True

# HD wallet
>>> from blockcypher import delete_wallet
>>> delete_wallet(wallet_name='bob', api_key='YOUR_TOKEN', is_hd_wallet=True)
True

package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //wallet
    err := btc.DeleteWallet("alice")
    //hdwallet
    err = btc.DeleteHDWallet("bob")
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println("Alice and Bob Deleted")
    }
}

//Result from `go run`:
//Alice and Bob Deleted
<?php
// normal wallet
// Run on console:
// php -f .\sample\wallet-api\DeleteWalletEndpoint.php

$walletClient = new WalletClient($apiContext);
$result = $walletClient->delete('alice');

// hd wallet
// Run on console:
// php -f .\sample\wallet-api\DeleteHDWalletEndpoint.php

$walletClient = new HDWalletClient($apiContext);
$result = $walletClient->delete('bob');
Resource Method Return Object
/wallets/$NAME DELETE nil
/wallets/hd/$NAME DELETE nil

This endpoint deletes the Wallet or HD Wallet with $NAME. If successful, it will return an HTTP 204 status code with no return object.

Transaction API

BlockCypher’s Transaction API allows you to look up information about unconfirmed transactions, query transactions based on hash, create and propagate your own transactions, including multisignature transactions, and embed data on the blockchain—all based on the coin/chain resource you’ve selected for your endpoints.

If you’re new to blockchains, the idea of transactions is relatively self-explanatory. Here’s what’s going on underneath the hood: a transaction takes previous “unspent transaction outputs” (also known as UTXOs) as “transaction inputs” and creates new “locking scripts” on those inputs such that they are “sent” to new addresses (to become new UTXOs). While most of these public addresses are reference points for single private keys that can “unlock” the newly created UTXOs, occasionally they are sent to more exotic addresses through pay-to-script-hash, typically multisignature addresses.

Generally speaking, UTXOs are generated from previous transactions (except for Coinbase inputs).

Transaction Hash Endpoint

curl https://api.blockcypher.com/v1/btc/main/txs/f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449

{
"block_hash": "0000000000000000c504bdea36e5...",
"block_height": 293000,
"hash": "f854aebae95150b379cc1187d848d58225f...",
"addresses": [
    "13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy",
    "19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L",
    "1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy",
    "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq",
    "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
],
"total": 70320221545,
"fees": 0,
"size": 636,
"preference": "low",
"relayed_by": "",
"confirmed": "2014-03-29T01:29:19Z",
"received": "2014-03-29T01:29:19Z",
"ver": 1,
"lock_time": 0,
"double_spend": false,
"vin_sz": 4,
"vout_sz": 1,
"confirmations": 64373,
"inputs": [
    {
    "prev_hash": "583910b7bf90ab802e22e5c25a89b59...",
    "output_index": 1,
    "script": "4830450220504b1ccfddf508422bdd8b0f...",
    "output_value": 16450000,
    "sequence": 4294967295,
    "addresses": [
        "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq"
    ],
    "script_type": "pay-to-pubkey-hash"
    },
    ...
],
"outputs": [
    {
    "value": 70320221545,
    "script": "76a914e6aad9d712c419ea8febf009a3f3...",
    "spent_by": "35832d6c70b98b54e9a53ab2d51176eb...",
    "addresses": [
        "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
    ],
    "script_type": "pay-to-pubkey-hash"
    }
]
}
$.get('https://api.blockcypher.com/v1/btc/main/txs/f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449').then(function(d) {console.log(d)});
> {
> "block_hash": "0000000000000000c504bdea36e5...",
> "block_height": 293000,
> "hash": "f854aebae95150b379cc1187d848d58225f...",
> "addresses": [
>   "13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy",
>   "19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L",
>   "1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy",
>   "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq",
>   "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
> ],
> "total": 70320221545,
> "fees": 0,
> "size": 636,
> "preference": "low",
> "relayed_by": "",
> "confirmed": "2014-03-29T01:29:19Z",
> "received": "2014-03-29T01:29:19Z",
> "ver": 1,
> "lock_time": 0,
> "double_spend": false,
> "vin_sz": 4,
> "vout_sz": 1,
> "confirmations": 64373,
> "inputs": [
>   {
>   "prev_hash": "583910b7bf90ab802e22e5c25a89b59...",
>   "output_index": 1,
>   "script": "4830450220504b1ccfddf508422bdd8b0f...",
>   "output_value": 16450000,
>   "sequence": 4294967295,
>   "addresses": [
>       "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq"
>   ],
>   "script_type": "pay-to-pubkey-hash"
>   },
>   ...
> ],
> "outputs": [
>   {
>   "value": 70320221545,
>   "script": "76a914e6aad9d712c419ea8febf009a3f3...",
>   "spent_by": "35832d6c70b98b54e9a53ab2d51176eb...",
>   "addresses": [
>       "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
>   ],
>   "script_type": "pay-to-pubkey-hash"
>   }
> ]
> }
> block_cypher.blockchain_transaction("f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449")
=> {"block_hash"=>"0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328",
 "block_height"=>293000,
 "hash"=>"f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449",
 "addresses"=>
  ["13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy",
   "19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L",
   "1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy",
   "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq",
   "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"],
 "total"=>70320221545,
 "fees"=>0,
 "size"=>636,
 "preference"=>"low",
 "relayed_by"=>"",
 "confirmed"=>"2014-03-29T01:29:19Z",
 "received"=>"2014-03-29T01:29:19Z",
 "ver"=>1,
 "lock_time"=>0,
 "double_spend"=>false,
 "vin_sz"=>4,
 "vout_sz"=>1,
 "confirmations"=>68362,
 "inputs"=>
  [{"prev_hash"=>"583910b7bf90ab802e22e5c25a89b59862b20c8c1aeb24dfb94e7a508a70f121",
    "output_index"=>1,
    "script"=>
     "4830450220504b1ccfddf508422bdd8b0fcda2b148...",
    "output_value"=>16450000,
    "sequence"=>4294967295,
    "addresses"=>["1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq"],
    "script_type"=>"pay-to-pubkey-hash"},...],
 "outputs"=>
  [{"value"=>70320221545,
    "script"=>"76a914e6aad9d712c419ea8febf009a3f3bfdd8d222fac88ac",
    "spent_by"=>"35832d6c70b98b54e9a53ab2d51176eb19ad11bc4505d6bb1ea6c51a68cb92ee",
    "addresses"=>["1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"],
    "script_type"=>"pay-to-pubkey-hash"}]}
>>> from blockcypher import get_transaction_details
>>> get_transaction_details('f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449')
{
    "addresses": [
        "13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy", 
        "19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L", 
        "1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy", 
        "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq", 
        "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
    ], 
    "block_hash": "0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328", 
    "block_height": 293000, 
    "confirmations": 86918, 
    "confirmed": "datetime.datetime(2014, 3, 29, 1, 29, 19, 0, tzinfo=tzutc())", 
    "double_spend": False, 
    "fees": 0, 
    "hash": "f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449", 
    "inputs": [
        {
            "addresses": [
                "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq"
            ], 
            "output_index": 1, 
            "output_value": 16450000, 
            "prev_hash": "583910b7bf90ab802e22e5c25a89b59862b20c8c1aeb24dfb94e7a508a70f121", 
            "script": "4830450220504b1ccfddf508422bdd8b0fcda2b1483e87aee1b486c0130bc29226bbce3b4e022100b5befcfcf0d3bf6ebf0ac2f93badb19e3042c7bed456c398e743b885e782466c012103b1feb40b99e8ff18469484a50e8b52cc478d5f4f773a341fbd920a4ceaedd4bf", 
            "script_type": "pay-to-pubkey-hash", 
            "sequence": 4294967295
        }, 
        ...,

    ], 
    "lock_time": 0, 
    "outputs": [
        {
            "addresses": [
                "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
            ], 
            "script": "76a914e6aad9d712c419ea8febf009a3f3bfdd8d222fac88ac", 
            "script_type": "pay-to-pubkey-hash", 
            "spent_by": "35832d6c70b98b54e9a53ab2d51176eb19ad11bc4505d6bb1ea6c51a68cb92ee", 
            "value": 70320221545
        }
    ], 
    "preference": "low", 
    "received": "datetime.datetime(2014, 3, 29, 1, 29, 19, 0, tzinfo=tzutc())", 
    "relayed_by": "", 
    "size": 636, 
    "total": 70320221545, 
    "ver": 1, 
    "vin_sz": 4, 
    "vout_sz": 1
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    tx, err := btc.GetTX("f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", tx)
}

//Result from `go run`:
//{BlockHash:0000000000000000c504bdea36e531d8089d324f2d936c86e3274f97f8a44328 BlockHeight:293000 Hash:f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449 Addresses:[13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy 19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L 1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy 1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq 1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV] Total:70320221545 Fees:0 Size:636 Preference:low RelayedBy: Received:2014-03-29 01:29:19 +0000 UTC Confirmed:2014-03-29 01:29:19 +0000 UTC Confirmations:86227 Confidence:1 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:4 VoutSize:1 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:583910b7bf90ab802e22e5c25a89b59862b20c8c1aeb24dfb94e7a508a70f121 OutputIndex:1 OutputValue:16450000 Addresses:[1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:4830450220504b1ccfddf508422bdd8b0fcda2b1483e87aee1b486c0130bc29226bbce3b4e022100b5befcfcf0d3bf6ebf0ac2f93badb19e3042c7bed456c398e743b885e782466c012103b1feb40b99e8ff18469484a50e8b52cc478d5f4f773a341fbd920a4ceaedd4bf Age:0 WalletName:} {PrevHash:f6966bb3d3ba0eb97fd11b223fb13c793c0b4a1b3deb575e8ae38d666c1d00d9 OutputIndex:36 OutputValue:10061545 Addresses:[19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:48304502210086de855e03008abcc49335c775973eab9ace2e16c3bfe6536218c1d029287fdb0220129ced657870af63f61cdd4b941996f9a243d1f306e774fc9c5f3dea0af8d581012103cbe40d1d790799a6494c07f844eaf05b4c6deab0b9dee2ee45c8decead12c5cd Age:0 WalletName:} {PrevHash:9ea2f9695e6694309fb0d8b966afb4678a77a59f160822e33819fada9e0c8288 OutputIndex:1 OutputValue:70000000000 Addresses:[1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:48304502201f1eb5b79279258a91c00dee09dff5d6f6ece7c01639e66a6bdd579136ecddee022100d4a9ed93183bf338e51ba80bc1dd10ff03e9e159bd8ea59db3a5c10aa0ccd3400121022667ee37e180c1ad2fef6f16aa52ed27799f629364dfe51e144dd683317dbbd2 Age:0 WalletName:} {PrevHash:279ccbbab8605390a85fe6f0e4fb04ec1946ee6033054b16fec72e1304742d5d OutputIndex:0 OutputValue:293710000 Addresses:[13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:483045022100baac0c25867855f62592872cfac522d59fddd590a6cc290c8ad3bbe6b1151b5802204f2713c565ce6b00e5ea00e955d35e3b0878af5474feda35ebbb73232122d5480121023ed3b44ad598e3834e561efed205c221b7bc2e577e752eeaa66e85e60d0381c9 Age:0 WalletName:}] Outputs:[{SpentBy:35832d6c70b98b54e9a53ab2d51176eb19ad11bc4505d6bb1ea6c51a68cb92ee Value:70320221545 Addresses:[1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV] ScriptType:pay-to-pubkey-hash Script:76a914e6aad9d712c419ea8febf009a3f3bfdd8d222fac88ac DataHex: DataString:}]}
<?php
// Run on console:
// php -f .\sample\transaction-api\TransactionHashEndpoint.php

$txClient = new TXClient($apiContext);
$transaction = $txClient->get('f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449');

{
"block_hash": "0000000000000000c504bdea36e531d80...",
"block_height": 293000,
"hash": "f854aebae95150b379cc1187d848d58225f3c41...",
"addresses": [
    "13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy",
    "19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L",
    "1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy",
    "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq",
    "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
],
"total": 70320221545,
"fees": 0,
"size": 636,
"preference": "low",
"relayed_by": "",
"confirmed": "2014-03-29T01:29:19Z",
"received": "2014-03-29T01:29:19Z",
"ver": 1,
"lock_time": 0,
"double_spend": false,
"vin_sz": 4,
"vout_sz": 1,
"confirmations": 63171,
"inputs": [
    {
        "prev_hash": "583910b7bf90ab802e22e5c25a89...",
        "output_index": 1,
        "script": "4830450220504b1ccfddf508422bdd8...",
        "output_value": 16450000,
        "sequence": 4294967295,
        "addresses": [
            "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq"
        ],
        "script_type": "pay-to-pubkey-hash"
    },
    ...,
    ...,
],
"outputs": [
    {
        "value": 70320221545,
        "script": "76a914e6aad9d712c419ea8febf009a...",
        "spent_by": "35832d6c70b98b54e9a53ab2d5117...",
        "addresses": [
            "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
        ],
        "script_type": "pay-to-pubkey-hash"
    }
]
}

The Transaction Hash Endpoint returns detailed information about a given transaction based on its hash.

Resource Method Return Object
/txs/$TXHASH GET TX
Flag Type Effect
limit integer Filters TXInputs/TXOutputs, if unset, default is 20.
instart integer Filters TX to only include TXInputs from this input index and above.
outstart integer Filters TX to only include TXOutputs from this output index and above.
includeHex bool If true, includes hex-encoded raw transaction; false by default.
includeConfidence bool If true, includes the confidence attribute (useful for unconfirmed transactions). For more info about this figure, check the Confidence Factor documentation.

TXHASH is a string representing the hex-encoded transaction hash you’re interested in querying, for example:

f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449

The returned object contains detailed information about the transaction, including the value transfered, date received, and a full listing of inputs and outputs.

Unconfirmed Transactions Endpoint

curl https://api.blockcypher.com/v1/btc/main/txs

[
    {
    "block_height": -1,
    "hash": "7f3af38d988e479f651520b13b85...",
    "addresses": [
        "19ZZonTmBD3VBhgFSWrtNis6Wo4aNRyjAV",
        "1GD2Gnt3Vk51FpUhZWrFpSa24KE2ZGPaWG",
        "1HEJiW8jxvUvVQ5cuButRmFj6ZzKzM9Fp6"
    ],
    "total": 46977000,
    "fees": 10000,
    "size": 225,
    "preference": "medium",
    "relayed_by": "54.209.56.58:8333",
    ...
    },
    {
    "block_height": -1,
    "hash": "7e2d8b4e95c8246e81f297539409...",
    "addresses": [
        "12u8EFJR6QJpNYbuQcYt2iMsAtPdnCFwQb",
        "1MUbYoqSadRSEipwcmKnH37NaKakDCmgwW"
    ],
    "total": 1070000,
    "fees": 10000,
    "size": 225,
    "preference": "medium",
    "relayed_by": "52.1.229.213:8333",
    "received": "2015-05-21T05:44:13.878Z",
    ...
    },
...
]
$.get('https://api.blockcypher.com/v1/btc/main/txs').then(function(d) {console.log(d)});
> [
>   {
>   "block_height": -1,
>   "hash": "7f3af38d988e479f651520b13b85...",
>   "addresses": [
>       "19ZZonTmBD3VBhgFSWrtNis6Wo4aNRyjAV",
>       "1GD2Gnt3Vk51FpUhZWrFpSa24KE2ZGPaWG",
>       "1HEJiW8jxvUvVQ5cuButRmFj6ZzKzM9Fp6"
>   ],
>   "total": 46977000,
>   "fees": 10000,
>   "size": 225,
>   "preference": "medium",
>   "relayed_by": "54.209.56.58:8333",
>   ...
>   },
>   {
>   "block_height": -1,
>   "hash": "7e2d8b4e95c8246e81f297539409...",
>   "addresses": [
>       "12u8EFJR6QJpNYbuQcYt2iMsAtPdnCFwQb",
>       "1MUbYoqSadRSEipwcmKnH37NaKakDCmgwW"
>   ],
>   "total": 1070000,
>   "fees": 10000,
>   "size": 225,
>   "preference": "medium",
>   "relayed_by": "52.1.229.213:8333",
>   "received": "2015-05-21T05:44:13.878Z",
>   ...
>   },
> ...
> ]
> block_cypher.blockchain_unconfirmed_tx
=> [{"block_height"=>-1,
  "hash"=>"125abd75941fb8fd499d514979a764b9bf4bf0b0208dcff2790a6b4d7c165911",
  "addresses"=>
   ["137REkr34fuwZY6Fu5Numz7DDNt14y4eNr",
    "1LoveUTs984niMqTqTZyDoRUuqpZV5VQ1K",
    "1PSGAQAHS5fE745a4pwD7NSxJ3Gt5e1vSU",
    "3FaskXUYNSdeczUt1e9c6eGnWj1ifEwm94"],
  "total"=>11357528,
  "fees"=>10000,
  "size"=>699,
  "preference"=>"low",
  "relayed_by"=>"198.27.97.172:8333",
  "received"=>"2015-06-17T20:28:04.298Z",
  "ver"=>1,
  "lock_time"=>0,
  "double_spend"=>false,...},
  {"block_height"=>-1,
     "hash"=>"125abd7...",
   ...},
  ...]
>>> from blockcypher import get_broadcast_transactions
>>> get_broadcast_transactions(limit=1)
[
    {
        "addresses": [
            "1CM6sSAT6jyGmkvx7zoEGs7cM8EvG39Cah", 
            "1GKfznPeMp7Ey1MYfCS3CyrZZV2sRdBGWs"
        ], 
        "block_height": -1, 
        "confirmations": 0, 
        "double_spend": False, 
        "fees": 90000, 
        "hash": "915b22630b74f6dd12ef723ab0e0f99931faa1c343d488118aa528542e99afb7", 
        "inputs": [
            {
                "addresses": [
                    "1CM6sSAT6jyGmkvx7zoEGs7cM8EvG39Cah"
                ], 
                "age": 6802, 
                "output_index": 1, 
                "output_value": 599559, 
                "prev_hash": "825f6f06241ef6e3bb94c7c39126f79e0a9af725fd185f28ff7f0c4d4fb1144c", 
                "script": "483045022100d549d7b6033081844b7b854055c76d87809ca9ba13ae5179310b3bcffaef2495022008f61a6b4f6a905ed84b05dfb9e21840d547cd409b8a4e713477444e79593792012103c95e6dd62dd842058568d31011d8a425b5209a6758ce45b210af095e78c158e2", 
                "script_type": "pay-to-pubkey-hash", 
                "sequence": 4294967295
            }
        ], 
        "lock_time": 0, 
        "next_inputs": "https://api.blockcypher.com/v1/btc/main/txs/915b22630b74f6dd12ef723ab0e0f99931faa1c343d488118aa528542e99afb7?instart=1&outstart=0&limit=1", 
        "next_outputs": "https://api.blockcypher.com/v1/btc/main/txs/915b22630b74f6dd12ef723ab0e0f99931faa1c343d488118aa528542e99afb7?instart=0&outstart=1&limit=1", 
        "outputs": [
            {
                "addresses": [
                    "1GKfznPeMp7Ey1MYfCS3CyrZZV2sRdBGWs"
                ], 
                "script": "76a914a811ed2f211a447ba18eb4f7f849a86c201427f388ac", 
                "script_type": "pay-to-pubkey-hash", 
                "value": 1000000
            }
        ], 
        "preference": "low", 
        "receive_count": 569, 
        "received": "datetime.datetime(2015, 10, 21, 19, 6, 25, 725000, tzinfo=tzutc())", 
        "relayed_by": "95.211.104.246:8333", 
        "size": 5837, 
        "total": 1117192, 
        "ver": 1, 
        "vin_sz": 39, 
        "vout_sz": 2
    }
]
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    txs, err := btc.GetUnTX()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", txs)
}

//Result from `go run`:
//[{BlockHash: BlockHeight:-1 Hash:f8928f4b57b4a419056d979de6c6daf1f8cf9e431b2d2e056d5122115bbf6e03 Addresses:[13m2zkhwfufunZj48C5yiCK5GyauoZASEK 1443nQwA3q5gRELUUrFFbsQ7wjfnzLKmNb 17QqqUkKsuGWF7EgftiY9HrXEPPYoLAmJ4 18WLk2MdxoJvkWewdYfZAUS7D5BitKWxrM 19Fkb6WcpT8xr2A9kggKJ1ogUQyDjGXGq7 1ApjvBUwNEt8kEvTn2XTDHqDQhPn8MApRq 1Ckk3HysYTTeTXrt4mAxa4wzP9WjLEBgKM 1DXEqjgC2QV7CsDiEjYdthmxvJEwEAEchB 1FuFEWK9Ms6YFfmBLQWeQxE5FUYcWHHdMf 1Gsp5Cz8xbxHdcKCBUL8eA8sWgTbs6pbVK 1JK6ANFKJvck3TArHfH8hxYXM69LLQi4Cd 1JpqxXp3WsDWru1HrC3jXKoiwstUMoGwE7 1KcTNQtGB2VkF8gHRcUP3LeKT4ipDWC3xz 1QJrogp9xSNMrEKH7eE74qy86baCsUnTFe] Total:14404949 Fees:18480 Size:1845 Preference:low RelayedBy:194.237.158.153:8333 Received:2015-10-16 23:12:50.822 +0000 UTC Confirmed:0001-01-01 00:00:00 +0000 UTC Confirmations:0 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:138 VinSize:12 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:de3e7627b5aaacc505901120a3c4cabebfee3d5d3c2b9349808fab8db26bd252 OutputIndex:0 OutputValue:1303094 Addresses:[1JpqxXp3WsDWru1HrC3jXKoiwstUMoGwE7] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:483045022100e5f613cbdc60d13614dc58a2bdb9c67f348933e478288bb2e08a58e63c22dffc02201dda42464b34fa1a24e954cfa05ac2936575a039f5eb18201fe96dfd020c9967012103f1fbbcd8f5e50dde03be77c153a416c370b4c14c0d2c27eac66a64e4a47bd3f6 Age:0 WalletName:} {PrevHash:ce86c754efeb48d3b78e56f344082e825a76b2bfcb670eef5968934cf7694f24 OutputIndex:1 OutputValue:1006641 Addresses:[1ApjvBUwNEt8kEvTn2XTDHqDQhPn8MApRq] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:483045022100a844dd4291fdd417cabaea58e9694c8e4d4ff6d3d80bbd7a3b703465b7be6cf102204ff0c4b5f2e904c4e06f086c4cba57b9bc40310f7bf463176f75eea8a117c8b8012102eb8c62ca2106a753fe5f0c1937729e1db551f15b0d202871c3f3cb1391ed4a1f Age:0 WalletName:} {PrevHash:f6a89efed192e3d9dabb9fae65ecf6780bae904bc17397ec69c898435e55ee41 OutputIndex:1 OutputValue:1146424 Addresses:[1FuFEWK9Ms6YFfmBLQWeQxE5FUYcWHHdMf] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:4730440220258aa6e1a1e0fd03ad55d2fefe512785609fe079faa284eaf9263ba36ed0027002207740057cd9ade642a972f3490289d0256f604c60c1cfdeef4fffc9fcb3973e130121023a778b5d5eb3b1e2c7394f441a21ab104df692ad8e8ad6a9838b8dac7318be6d Age:0 WalletName:} {PrevHash:1b1f154612323edbf9f1970a42a1c33fb0ab9f734a5f080fb04c0f26921640c3 OutputIndex:1 OutputValue:1001406 Addresses:[13m2zkhwfufunZj48C5yiCK5GyauoZASEK] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:483045022100a0e44c26c6f16e20c17f309bbf2b8fc4b89da36a46734aa82a7d72b4147a7703022024646da778e77bac3f9e76f5b34e8fc9d39225daea17f331da507e9116f64506012102a6fa3938b873686753bf48cc5551d1f5b9615481f87c67fe04d4f596088f01ef Age:0 WalletName:} {PrevHash:9a8935c75f8479c2a7149c6e26f52b32d07a35cf15c120a81a431b8024f2bff8 OutputIndex:0 OutputValue:1042321 Addresses:[1KcTNQtGB2VkF8gHRcUP3LeKT4ipDWC3xz] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:473044022011a7fe8be1b3d1bfdf0137e81b85dae50fd8fda81503ecd72b9b5d325bc5b9a1022069b7d1bf262818fa65fc109f5ea6f8cdd14df4de3e2b83562f353251d5d8821f01210303fa00593f969a7f419ee258f588d3d4d672717ea0e73c1a15b3eeff767de575 Age:0 WalletName:} {PrevHash:7c0017d41d61f44d25b216f4918d4e7037f0247cd5f0d270e8b44e097e8cb5d3 OutputIndex:1 OutputValue:1950455 Addresses:[1Ckk3HysYTTeTXrt4mAxa4wzP9WjLEBgKM] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:473044022063383285fe15f2afad8e2574a1545c60f098b749041c40a0241659a3d1bc616d022059e93d5a55cd10847d1fe233dc64ceefae8cd4f191306f6b0078b75c5a2de57801210276043ad0e0491dd2b1792db12e3e1f031b97574c316ea19e9331155a47659741 Age:0 WalletName:} {PrevHash:f3f3d69581b8f8bcee3243c0fcb812737ecc446e8f2a4b4e23eb564498643750 OutputIndex:1 OutputValue:1164682 Addresses:[1QJrogp9xSNMrEKH7eE74qy86baCsUnTFe] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:47304402200a96d273b08ba084151784edfd82eda23f3283a5871d92b455854bc4cdeb9d14022053a834acc49b5e7fd195136bf6f0ac52ea1da088f737a298f213f950718b31720121026ebc9ee90c3f61c7289785982385523b4085f0454aed5e259dbdd8c50c3cc552 Age:0 WalletName:} {PrevHash:83fc9cbe8f9e28de140fad9a64885c848ef112d988f7110d9518ca60837ec36a OutputIndex:1 OutputValue:1019486 Addresses:[1Gsp5Cz8xbxHdcKCBUL8eA8sWgTbs6pbVK] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:473044022046bff50b4b67a39cbc09537a6e4b43d6c4aff8aba48db142875692dc935d7b1c022031cf89787b71e27a8c6721874b76c47a2b38042f6885dbf217be1851820ab560012102b4643824e610792d544ceae83ba6d1b0e6bbe0deb4b07059c3e95d41243c877e Age:0 WalletName:} {PrevHash:1a599344c35a02a89a4e0adf385df1539afe83863cf63a3fcb02c922f2808a86 OutputIndex:1 OutputValue:1224402 Addresses:[17QqqUkKsuGWF7EgftiY9HrXEPPYoLAmJ4] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:47304402202facd04cdd448e71b505e254b4768bf765525e527fc14dae1a6b9baaab7abbb7022060ff7fe015c32cf27f99d43f910d891c7acefd355b0e0db177f0c10180e83f2c012103cf170047f6744b1a37652034610d2549129aaf94a9b8c2c97465d6e7c135d4fe Age:0 WalletName:} {PrevHash:69043a9c6675f7bfa5c56d6e1b523c6a7a615ab0e505c99856b168e47a44aa8c OutputIndex:1 OutputValue:1255773 Addresses:[19Fkb6WcpT8xr2A9kggKJ1ogUQyDjGXGq7] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:473044022013a74f574e6c787010064e395233a5404c64b42ddc1412e071290ae1c09a79100220763496a016227db16ff0537c131b9aa1a70ca58cade03a548d88e9272f3d9218012103efde06c3eba524a6f4b15bbf699f422d1cbc08d1127ef71da109d6be5e4ae7e9 Age:0 WalletName:} {PrevHash:a63907e2e843d142d8f6865b35e80ffbc16addaa3cd0c0d1c0c65eeb67bebe5c OutputIndex:0 OutputValue:1078122 Addresses:[1DXEqjgC2QV7CsDiEjYdthmxvJEwEAEchB] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:47304402205e8c41c90624444b533ed10ac4afa0039f5b16ab9fcf7c74ab8e01c65579706402207936add6ca8a6d35ee803bdfa57ade55aa6cd647d67ffddcd1dd8fb22bfcffce012103dfd1d1cbc043c91a1ae71d3e3a55156e94ecc9664c0e58b65f490b03fc0dcdb0 Age:0 WalletName:} {PrevHash:f758e79c071aa8ea136033ec1555c7381a46078a31f73a397b94be8427121848 OutputIndex:1 OutputValue:1230623 Addresses:[1JK6ANFKJvck3TArHfH8hxYXM69LLQi4Cd] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:47304402202488d537e1a97e0810423a2b39cc958ce00e63d724d565c579fc08db6e1d2c00022008baf16a0c15568aa54386e8f4b0017b0a544a90208e815bc491c6141ed5248c012102487efb8337132b593bec69020e4b8aee118c8046b842cc150023915c06dfb596 Age:0 WalletName:}] Outputs:[{SpentBy: Value:1000593 Addresses:[18WLk2MdxoJvkWewdYfZAUS7D5BitKWxrM] ScriptType:pay-to-pubkey-hash Script:76a91452556c48f68b7cd56ed997ca23e183fff8808ded88ac DataHex: DataString:} {SpentBy: Value:13404356 Addresses:[1443nQwA3q5gRELUUrFFbsQ7wjfnzLKmNb] ScriptType:pay-to-pubkey-hash Script:76a914217bf2c6fabaf36888c4ba7af725b54412d3716988ac DataHex: DataString:}]} {BlockHash: BlockHeight:-1 ...}]
<?php
// Run on console:
// php -f .\sample\transaction-api\UnconfirmedTransactionsEndpoint.php

$txClient = new TXClient($apiContext);
$txs = $txClient->getUnconfirmed(array(), $apiContext);

[{'received': '2015-06-10T23:10:31.534Z',
  'ver': 1,
  'double_spend': False,
  'outputs': [{'value': 131910000,
    'addresses': ['1Gb4TAU4GD73akvt4V7tg2WdqadcpQSvhH'],
    'script_type': 'pay-to-pubkey-hash',
    'script': '76a914aafae908428a1778d0e76f0dca4cb800f731873e88ac'},
    ...
    ],
  'block_height': -1,
  'receive_count': 109,
  'total': 131940196,
  'fees': 13754,
  'inputs': [{'output_value': 9467,
    'sequence': 4294967295,
    'prev_hash': '3c65f3bdec16c55fcedec8159ca8b7decf12393e3a7088febbfacfd752534ee0',
    'script': '47304402207510efc3ff2ed868478ef627c4fd53a27254874e61c1ff1be6fb5221844c08ac02204a8a50c35d3fac8ec0c15f468c98abb629cadf3ac898f7be5e6f464ba9e4fba00121035649100ba29d0b34df8a928c2ed7ab1389d017b4ed206f6df5c212a461a764f2',
    'age': 38,
    'addresses': ['1MBuZ5ZxhytsjRZmec5rLr1WhDWm9DgFUJ'],
    'output_index': 1,
    'script_type': 'pay-to-pubkey-hash'},
    ...
   ],
  'preference': 'medium',
  'vout_sz': 2,
  'vin_sz': 3,
  'relayed_by': '167.114.118.213:8333',
  'hash': '97f551c7d200f3acf322160d6ada87830d2ad8d935909630a35a87d61bc8fa74',
  'addresses': ['1DLDFKuAWGUJqZoYrevG8bHufuZCjCdSFZ',
   '1Gb4TAU4GD73akvt4V7tg2WdqadcpQSvhH',
   ...
   ]
  'lock_time': 0,
  'size': 521,
  'confirmations': 0},
 ...
]

The Unconfirmed Transactions Endpoint returns an array of the latest transactions relayed by nodes in a blockchain that haven’t been included in any blocks.

Resource Method Return Object
/txs GET Array[TX]

The returned object is an array of transactions that haven’t been included in blocks, arranged in reverse chronological order (latest is first, then older transactions follow).

Creating Transactions

Using BlockCypher’s API, you can push transactions to blockchains one of two ways:

In either case, for security reasons, we never take possession of your private keys. We do use private keys with our Microtransaction API, but they are for low-value transactions and we discard them immediately from our servers’ memory.

New Transaction Endpoint

# Note resource change to bcy/test instead of btc/main, makes sharing private keys easier :)
curl -d '{"inputs":[{"addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"]}],"outputs":[{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}]}' https://api.blockcypher.com/v1/bcy/test/txs/new

{
"tx": {
    "block_height": -1,
    "hash": "c2b350b273b3bf04791d8e59fc9c021fd91fa423c50c29473dc079150f5a778a",
    "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
        "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
    ],
    "total": 4988000,
    "fees": 12000,
    "size": 119,
    "preference": "high",
    ...,
    "confirmations": 0,
    "inputs": [
        {
        "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
        "output_value": 5000000,
        "addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
        "script": "",
        "script_type": "",
        ...
        }
    ],
    "outputs": [
        {
        "value": 1000000,
        "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
        "addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"],
        "script_type": "pay-to-pubkey-hash"
        },
        {
        "value": 3988000,
        "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
        "addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
        "script_type": "pay-to-pubkey-hash"
        }
    ]
},
"tosign": ["32b5ea64c253b6b466366647458cfd60de9cd29d7dc542293aa0b8b7300cd827"]
}
var newtx = {
  inputs: [{addresses: ['CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9']}],
  outputs: [{addresses: ['C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn'], value: 100000}]
};
$.post('https://api.blockcypher.com/v1/bcy/test/txs/new', JSON.stringify(newtx))
  .then(function(d) {console.log(d)});
> {
>   "tx": {
>     "block_height": -1,
>     "hash": "c2b350b273b3bf04791d8e59fc9c021fd91fa423c50c29473dc079150f5a778a",
>     "addresses": [
>       "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
>       "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
>     ],
>     "total": 4988000,
>     "fees": 12000,
>     "size": 119,
>     "preference": "high",
>     "relayed_by": "208.71.159.84",
>     "received": "2015-05-21T19:04:14.492743867Z",
>     "ver": 1,
>     "lock_time": 0,
>     "double_spend": false,
>     "vin_sz": 1,
>     "vout_sz": 2,
>     "confirmations": 0,
>     "inputs": [
>       {
>         "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
>         "output_index": 0,
>         "script": "",
>         "output_value": 5000000,
>         "sequence": 4294967295,
>         "addresses": [
>           "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
>         ],
>         "script_type": "",
>         "age": 4
>       }
>     ],
>     "outputs": [
>       {
>         "value": 1000000,
>         "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
>         "addresses": [
>           "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
>         ],
>         "script_type": "pay-to-pubkey-hash"
>       },
>       {
>         "value": 3988000,
>         "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
>         "addresses": [
>           "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
>         ],
>         "script_type": "pay-to-pubkey-hash"
>       }
>     ]
>   },
>   "tosign": [
>     "32b5ea64c253b6b466366647458cfd60de9cd29d7dc542293aa0b8b7300cd827"
>   ]
> }
# Using BlockCypher's Internal Testnet
> bc_test = BlockCypher::Api.new(api_token:"YOURTOKEN", currency:BlockCypher::BCY, network:BlockCypher::TEST_NET)
=> #<BlockCypher::Api:0x00000001a9ebf0 @api_token="YOURTOKEN", @currency="bcy", @network="test", @version="v1">

> txskel = bc_test.transaction_new(["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"], ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], 100000)
=> {"tx"=>
  {"block_height"=>-1,
   "hash"=>"2094c09f880f88dea1a1ff3a6e19c6af4892b4b26f8e6315fd76c6ddc369ffbf",
   "addresses"=>["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
   "total"=>3856000,
   "fees"=>12000,
   "size"=>119,
   "preference"=>"high",
   "relayed_by"=>"199.83.221.11",
   "received"=>"2015-06-17T20:41:22.818882286Z",
   "ver"=>1,
   "lock_time"=>0,
   "double_spend"=>false,
   "vin_sz"=>1,
   "vout_sz"=>2,
   "confirmations"=>0,
   "inputs"=>
    [{"prev_hash"=>"6b1c30cad97df956cfcb47b4cd471bb69112fb726b0fb129575337e3fb9f2c1a",
      "output_index"=>2,
      "script"=>"",
      "output_value"=>3868000,
      "sequence"=>4294967295,
      "addresses"=>["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
      "script_type"=>"",
      "age"=>9739}],
   "outputs"=>
    [{"value"=>100000,
      "script"=>"76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
      "addresses"=>["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"],
      "script_type"=>"pay-to-pubkey-hash"},
     {"value"=>3756000,
      "script"=>"76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
      "addresses"=>["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
      "script_type"=>"pay-to-pubkey-hash"}]},
 "tosign"=>["c24150bea2d3b50c852d1c5eaccd3b6e286623b516e255f876d2b7c0d93f200b"]}
# Creating transactions manually is very complicated.
# We recommend you look at blockcypher.simple_spend() for a full working example of building a transaction using the blockcypher API, verifying and signing that transactionally locally, and then broadcasting it to the network using blockypher's API
# With blockcypher.simple_spend(), this whole example would look like just the following:
>>> from blockcypher import simple_spend
>>> simple_spend(from_privkey='97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90', to_address='C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn', to_satoshis=1000000, coin_symbol='bcy')
'7981c7849294648c1e79dd16077a388b808fcf8c20035aec7cc5315b37dacfee'

# That said, here it is in parts
>>> from blockcypher import create_unsigned_tx
>>> inputs = [{'address': 'CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9'}, ]
>>> outputs = [{'address': 'C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn', 'value': 1000000}]
>>> unsigned_tx = create_unsigned_tx(inputs=inputs, outputs=outputs, coin_symbol='bcy')
>>> unsigned_tx
{
    "tosign": [
        "c55602559d9306c0932da726ceda788bdca7f7b82d989f0c76c99161941f1198", 
        "9b3fcf3d94fae6fe0cf4e8a82fa408c5e8c56ee1c03ae88962e3f03879f1ffdb", 
        "eb2beed1f015ec88714e1e2335af3a0d8e535397ce52a430f649b4f465677ed0", 
        ...,
    ], 
    "tx": {
        "addresses": [
            "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", 
            "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
        ], 
        "block_height": -1, 
        "confidence": 0, 
        "confirmations": 0, 
        "double_spend": False, 
        "fees": 142700, 
        "hash": "afceb017a0d280a746ad5ed5c18228e302ebc2aa71ec768454b9a768f73c24c1", 
        "inputs": [
            {
                "addresses": [
                    "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
                ], 
                "age": 163376, 
                "output_index": 0, 
                "output_value": 23455, 
                "prev_hash": "457a538479fb50f3e060702594ef92962c2570d592b8e7c089d7b13fc9b5b3dc", 
                "script": "", 
                "script_type": "", 
                "sequence": 4294967295
            }, 
            ...,
        ], 
        "lock_time": 0, 
        "outputs": [
            {
                "addresses": [
                    "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
                ], 
                "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac", 
                "script_type": "pay-to-pubkey-hash", 
                "value": 1000000
            },
            ...,
        ], 
        "preference": "high", 
        "received": "2015-10-21T19:11:35.774722671Z", 
        "relayed_by": "207.38.134.25, 127.0.0.1", 
        "size": 775, 
        "total": 3773210, 
        "ver": 1, 
        "vin_sz": 17, 
        "vout_sz": 2
    }
}
//this is the same example as below, demonstrates
//creating New TXSkels, signing, and Sending TXSkels
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    //note the change to BlockCypher Testnet
    bcy := gobcy.API{"YOURTOKEN", "bcy", "test"}
    //generate two addresses
    addr1, err := bcy.GenAddrKeychain()
    addr2, err := bcy.GenAddrKeychain()
    //use faucet to fund first
    _, err = bcy.Faucet(addr1, 3e5)
    if err != nil {
        fmt.Println(err)
    }
    //Post New TXSkeleton
    skel, err := bcy.NewTX(gobcy.TempNewTX(addr1.Address, addr2.Address, 2e5), false)
    //Sign it locally
    err = skel.Sign([]string{addr1.Private})
    if err != nil {
        fmt.Println(err)
    }
    //Send TXSkeleton
    skel, err = bcy.SendTX(skel)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", skel)
}

//Result from `go run`:
// {Trans:{BlockHash: BlockHeight:-1 Hash:55d6ef290774f5428b66a0a27e46a8c37032c33bc15abce4791d56a2f8adb773 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i ByaXmP5k14WRBFLXArfCcqcpAHrUQRy3vL] Total:287500 Fees:12500 Size:225 Preference:high RelayedBy:52.27.84.91, 127.0.0.1 Received:2015-10-16 23:38:09.536632402 +0000 UTC Confirmed:0001-01-01 00:00:00 +0000 UTC Confirmations:0 Confidence:0 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:1 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:50c4738cb29901dc1ae3ed2692a57751653a31192176019d85d3f3922969dd1f OutputIndex:0 OutputValue:300000 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:4730440220298915c785165233e2f19192bbbb9b8c3fed6d064279cb8968af6698c783b875022037287134f9f0aaf84429ba9bb50f1efcb4cedcfbd34407c285134e068234432c012102b17f04f5fa1bd44315ef33f8759822a302a2ba7fa28c56a50fac0441a341b96a Age:0 WalletName:}] Outputs:[{SpentBy: Value:200000 Addresses:[ByaXmP5k14WRBFLXArfCcqcpAHrUQRy3vL] ScriptType:pay-to-pubkey-hash Script:76a91446c7681dcacaee1ea3f57eced37755d1d09e070188ac DataHex: DataString:} {SpentBy: Value:87500 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i] ScriptType:pay-to-pubkey-hash Script:76a91490d969679032cc1af6a69b4161778f12e90cb13588ac DataHex: DataString:}]} ToSign:[] Signatures:[] PubKeys:[] ToSignTX:[] Errors:[]}
<?php
// Run on console:
// php -f .\sample\transaction-api\NewTransactionEndpoint.php

// Create a new instance of Transaction object
$tx = new Transaction();

// Tx inputs
$input = new \BlockCypher\Api\Input();
$input->addAddress("C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm");
$tx->addInput($input);
// Tx outputs
$output = new \BlockCypher\Api\Output();
$output->addAddress("C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi");
$tx->addOutput($output);
// Tx amount
$output->setValue(1000); // Satoshis

$txClient = new TXClient($apiContext);
$txSkeleton = $txClient->create($tx);

{
  "tx":{
    "block_height":-1,
    "hash":"edb785c310ea58c70245c9a89130efca8fb0a02d4bee47b18542986e7bf95806",
    "addresses":[
      "C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm",
      "C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi"
    ],
    "total":5420100,
    "fees":12000,
    "size":119,
    "preference":"high",
    "relayed_by":"88.7.90.149",
    "received":"2015-06-17T10:23:02.475392139Z",
    "ver":1,
    "lock_time":0,
    "double_spend":false,
    "vin_sz":1,
    "vout_sz":2,
    "confirmations":0,
    "inputs":[{ "prev_hash":"64e39fa5322ee604ad548dc5d4ae1a61b0a575278724d0df7e53dd334f5f13e3",
        "output_index":0,
        "script":"",
        "output_value":5432100,
        "sequence":4294967295,
        "addresses":["C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm"],
        "script_type":"",
        "age":0
      }
    ],
    "outputs":[{ "value":1000,
        "script":"76a9147b2b09ad46d95e177df6969a275db321c66cecf388ac",
        "addresses":["C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi"],
        "script_type":"pay-to-pubkey-hash"
      },
      { "value":5419100,
        "script":"76a9148c6f28c814116f1ae3d0940b2fb05a68a9507e8a88ac",
        "addresses":["C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm"],
        "script_type":"pay-to-pubkey-hash"
      }]
  },
  "tosign":["770af2c9a9b7b8b1998e36d4c1ce2b8fa3b9d4d6575679a513722d9f478177d2"]
}

To use BlockCypher’s two-endpoint transaction creation tool, first you need to provide the input address(es), output address, and value to transfer (in satoshis). Provide this in a partially-filled out TX request object.

Resource Method Request Object Return Object
/txs/new POST TX TXSkeleton
Flag Type Effect
includeToSignTx bool If true, includes tosign_tx array in TXSkeleton, useful for validating data to sign; false by default.

As you can see from the code example, you only need to provide a single public address within the addresses array of both the input and output of your TX request object. You also need to fill in the value with the amount you’d like to transfer from one address to another.

If you’d like, you can even use a Wallet instead of addresses as your input. You just need to use two non-standard fields (your wallet_name and wallet_token) within the inputs array in your transaction, instead of addresses:

{inputs:[{"wallet_name":"alice", "wallet_token":"YOURTOKEN"}], value: 5000000}

While this particular usage will differ between client libraries, the result is the same: the addresses within your wallet will be used as the inputs, as if all of them had been placed within the addresses array.

As a return object, you’ll receive a TXSkeleton containing a slightly-more complete TX alongside data you need to sign in the tosign array. You’ll need this object for the next steps of the transaction creation process.

Validating the Data to Sign

For the extra cautious, you can protect yourself from a potential malicious attack on BlockCypher by validating the data we’re asking you to sign. Unfortunately, it’s impossible to do so directly, as pre-signed signature data is hashed twice using SHA256. To get around this, set the includeToSignTx URL flag to true. The optional tosign_tx array will be returned within the TXSkeleton, which you can use in the following way:

# next, you sign the data returned in the tosign array locally
# here we're using our signer tool (https://github.com/blockcypher/btcutils/tree/master/signer), but any ECDSA secp256k1 signing tool should work
# $PRIVATEKEY here is a hex-encoded private key corresponding to the input from address CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9 

./signer 32b5ea64c253b6b466366647458cfd60de9cd29d7dc542293aa0b8b7300cd827 $PRIVATEKEY

3045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca
// next, you sign the data returned in the tosign array locally
// here we're using bitcoinjs built to expose bigi, buffer, and require
// you can get bitcoin.js here:
// http://bitcoinjs.org/

var bitcoin = require("bitcoinjs-lib");
var bigi    = require("bigi");
var buffer  = require('buffer');
var keys    = new bitcoin.ECPair(bigi.fromHex(my_hex_private_key));

var newtx = {
  inputs: [{addresses: ['CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9']}],
  outputs: [{addresses: ['C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn'], value: 100000}]
};
// calling the new endpoint, same as above
$.post('https://api.blockcypher.com/v1/bcy/test/txs/new', JSON.stringify(newtx))
  .then(function(tmptx) {
    // signing each of the hex-encoded string required to finalize the transaction
    tmptx.pubkeys = [];
    tmptx.signatures = tmptx.tosign.map(function(tosign, n) {
      tmptx.pubkeys.push(keys.getPublicKeyBuffer().toString("hex"));
      return keys.sign(new buffer.Buffer(tosign, "hex")).toDER().toString("hex");
    });
    // sending back the transaction with all the signatures to broadcast
    $.post('https://api.blockcypher.com/v1/bcy/test/txs/send', tmptx).then(function(finaltx) {
      console.log(finaltx);
    })
  });
>>> from blockcypher import make_tx_signatures
# Using our same unsigned_tx as before, iterate through unsigned_tx['tx']['inputs'] to find each address in order.
# Include duplicates as many times as they may appear:
>>> privkey_list = ['privkeyhex1', 'privkeyhex2', ...]
>>> pubkey_list = ['pubkeyhex1', 'pubkeyhex2', ,,,]
>>> tx_signatures = make_tx_signatures(txs_to_sign=unsigned_tx['tosign'], privkey_list=privkey_list, pubkey_list=pubkey_list)
# Signing is handled by our SDK in the next step
//signing handled in both examples
<?php
// Sign the transaction
// Private key for address: C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm
$privateKeys = array("2c2cc015519b79782bd9c5af66f442e808f573714e3c4dc6df7d79c183963cff");
$txSkeleton = $txClient->sign($txSkeleton, $privateKeys);

Locally Sign Your Transaction

With your TXSkeleton returned from the New Transaction Endpoint, you now need to use your private key(s) to sign the data provided in the tosign array.

Digital signing can be a difficult process, and is where the majority of issues arise when dealing with cryptocurrency transactions. We are working on integrating client-side signing solutions into our libraries to make this process easier. You can read more about signing here. In the mean time, if you want to experiment with client-side signing, consider using our signer tool.

# the request body is truncated because it's huge, but it's the same as the returned object from above plus the signatures and public keys
# remember, still using bcy/test instead of btc/main
curl -d '{"tx": {...}, "tosign": [ "32b5ea64c253b6b466366647458cfd60de9cd29d7dc542293aa0b8b7300cd827" ], "signatures": [ "3045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca" ], "pubkeys": [ "02152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044" ] }' https://api.blockcypher.com/v1/bcy/test/txs/send?token=YOURTOKEN

{
"tx": {
    "block_height": -1,
    "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
    "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
        "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
    ],
    "total": 4988000,
    "fees": 12000,
    "size": 226,
    "preference": "high",
    ...,
    "confirmations": 0,
    "inputs": [
        {
        "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
        "output_value": 5000000,
        "addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
        "script": "483045022100921fc36b911094280f...",
        "script_type": "pay-to-pubkey-hash",
        ...
        }
    ],
    "outputs": [
        {
        "value": 1000000,
        "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
        "addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"],
        "script_type": "pay-to-pubkey-hash"
        },
        {
        "value": 3988000,
        "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
        "addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
        "script_type": "pay-to-pubkey-hash"
        }
    ]
},
"tosign": [ "" ]
}
// this shows just the last step of sending your transaction, see the signing section
// for the fully integrated sample
// the request body is truncated because it's huge, but it's the same as the returned
// object from calling the new endpoint plus the signatures and public keys added in the
// signing section
var sendtx = {
  tx: {...},
  tosign: [
    "32b5ea64c253b6b466366647458cfd60de9cd29d7dc542293aa0b8b7300cd827"
  ],
  signatures: [
    "3045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca"
  ],
  pubkeys: [
    "02152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044"
  ]
};
$.post('https://api.blockcypher.com/v1/bcy/test/txs/send', JSON.stringify(sendtx))
  .then(function(d) {console.log(d)});
> {
>   "tx": {
>     "block_height": -1,
>     "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
>     "addresses": [
>       "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
>       "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
>     ],
>     "total": 4988000,
>     "fees": 12000,
>     "size": 226,
>     "preference": "high",
>     "relayed_by": "73.162.198.68",
>     "received": "2015-05-22T04:38:57.470017042Z",
>     "ver": 1,
>     "lock_time": 0,
>     "double_spend": false,
>     "vin_sz": 1,
>     "vout_sz": 2,
>     "confirmations": 0,
>     "inputs": [
>       {
>         "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
>         "output_index": 0,
>         "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",
>         "output_value": 5000000,
>         "sequence": 4294967295,
>         "addresses": [
>           "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
>         ],
>         "script_type": "pay-to-pubkey-hash",
>         "age": 546
>       }
>     ],
>     "outputs": [
>       {
>         "value": 1000000,
>         "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
>         "addresses": [
>           "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
>         ],
>         "script_type": "pay-to-pubkey-hash"
>       },
>       {
>         "value": 3988000,
>         "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
>         "addresses": [
>           "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
>         ],
>         "script_type": "pay-to-pubkey-hash"
>       }
>     ]
>   },
>   "tosign": [
>     ""
>   ]
> }
> bc_test.transaction_sign_and_send(txskel, "YOURCOMPRESSEDPRIVATEKEYINHEX")
=> {"tx"=>
  {"block_height"=>-1,
   "hash"=>"620f484194eca649ccd48501bff1c8046fed4a1b28bee9f6b0db8c93ced672be",
   "addresses"=>["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"],
   "total"=>3856000,
   "fees"=>12000,
   "size"=>226,
   "preference"=>"high",
   "relayed_by"=>"199.83.221.11",
   "received"=>"2015-06-17T20:47:36.092834184Z",
   "ver"=>1,
   "lock_time"=>0,
   "double_spend"=>false,
   "vin_sz"=>1,
   "vout_sz"=>2,
   "confirmations"=>0,
   "inputs"=>
    [{"prev_hash"=>"6b1c30cad97df956cfcb47b4cd471bb69112fb726b0fb129575337e3fb9f2c1a",
      "output_index"=>2,
      "script"=>
       "483045022100803c8b097d0653cc094362f772e687da00aa263f22ccc6a203b0e0234e096fbd022068d3a0ef0306ee9698313bdac044cfb32f2cf63b7c29dbf43568721f040c7b80012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",
      "output_value"=>3868000,
      "sequence"=>4294967295,
      "addresses"=>["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
      "script_type"=>"pay-to-pubkey-hash",
      "age"=>9745}],
   "outputs"=>
    [{"value"=>100000,
      "script"=>"76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
      "addresses"=>["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"],
      "script_type"=>"pay-to-pubkey-hash"},
     {"value"=>3756000,
      "script"=>"76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
      "addresses"=>["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
      "script_type"=>"pay-to-pubkey-hash"}]},
 "tosign"=>[""]}
//this is the same example as above, demonstrates
//creating New TXSkels, signing, and Sending TXSkels
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    //note the change to BlockCypher Testnet
    bcy := gobcy.API{"YOURTOKEN", "bcy", "test"}
    //generate two addresses
    addr1, err := bcy.GenAddrKeychain()
    addr2, err := bcy.GenAddrKeychain()
    //use faucet to fund first
    _, err = bcy.Faucet(addr1, 3e5)
    if err != nil {
        fmt.Println(err)
    }
    //Post New TXSkeleton
    skel, err := bcy.NewTX(gobcy.TempNewTX(addr1.Address, addr2.Address, 2e5), false)
    //Sign it locally
    err = skel.Sign([]string{addr1.Private})
    if err != nil {
        fmt.Println(err)
    }
    //Send TXSkeleton
    skel, err = bcy.SendTX(skel)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", skel)
}

//Result from `go run`:
// {Trans:{BlockHash: BlockHeight:-1 Hash:55d6ef290774f5428b66a0a27e46a8c37032c33bc15abce4791d56a2f8adb773 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i ByaXmP5k14WRBFLXArfCcqcpAHrUQRy3vL] Total:287500 Fees:12500 Size:225 Preference:high RelayedBy:52.27.84.91, 127.0.0.1 Received:2015-10-16 23:38:09.536632402 +0000 UTC Confirmed:0001-01-01 00:00:00 +0000 UTC Confirmations:0 Confidence:0 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:1 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:50c4738cb29901dc1ae3ed2692a57751653a31192176019d85d3f3922969dd1f OutputIndex:0 OutputValue:300000 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:4730440220298915c785165233e2f19192bbbb9b8c3fed6d064279cb8968af6698c783b875022037287134f9f0aaf84429ba9bb50f1efcb4cedcfbd34407c285134e068234432c012102b17f04f5fa1bd44315ef33f8759822a302a2ba7fa28c56a50fac0441a341b96a Age:0 WalletName:}] Outputs:[{SpentBy: Value:200000 Addresses:[ByaXmP5k14WRBFLXArfCcqcpAHrUQRy3vL] ScriptType:pay-to-pubkey-hash Script:76a91446c7681dcacaee1ea3f57eced37755d1d09e070188ac DataHex: DataString:} {SpentBy: Value:87500 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i] ScriptType:pay-to-pubkey-hash Script:76a91490d969679032cc1af6a69b4161778f12e90cb13588ac DataHex: DataString:}]} ToSign:[] Signatures:[] PubKeys:[] ToSignTX:[] Errors:[]}
>>> from blockcypher import broadcast_signed_transaction
>>> broadcast_signed_transaction(unsigned_tx=unsigned_tx, signatures=tx_signatures, pubkeys=pubkey_list)
{
    "tosign": [
        ""
    ], 
    "tx": {
        "addresses": [
            "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", 
            "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
        ], 
        "block_height": -1, 
        "confidence": 0, 
        "confirmations": 0, 
        "double_spend": False, 
        "fees": 142700, 
        "hash": "afceb017a0d280a746ad5ed5c18228e302ebc2aa71ec768454b9a768f73c24c1", 
        "inputs": [
            {
                "addresses": [
                    "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
                ], 
                "age": 163376, 
                "output_index": 0, 
                "output_value": 23455, 
                "prev_hash": "457a538479fb50f3e060702594ef92962c2570d592b8e7c089d7b13fc9b5b3dc", 
                "script": "", 
                "script_type": "", 
                "sequence": 4294967295
            },
            ...,
        ], 
        "lock_time": 0, 
        "outputs": [
            {
                "addresses": [
                    "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
                ], 
                "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac", 
                "script_type": "pay-to-pubkey-hash", 
                "value": 1000000
            }
        ], 
        "preference": "high", 
        "received": datetime.datetime(2015, 10, 21, 19, 11, 35, 774722, tzinfo=tzutc()), 
        "relayed_by": "207.38.134.25, 127.0.0.1", 
        "size": 192, 
        "total": 10000, 
        "ver": 1, 
        "vin_sz": 1, 
        "vout_sz": 1
    }
}

<?php
// Send the transaction
$txSkeleton = $txClient->send($txSkeleton);

{
  "tx":{
    "block_height":-1,
    "hash":"edb785c310ea58c70245c9a89130efca8fb0a02d4bee47b18542986e7bf95806",
    "addresses":[
      "C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm",
      "C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi"
    ],
    "total":5420100,
    "fees":12000,
    "size":119,
    "preference":"high",
    "relayed_by":"88.7.90.149",
    "received":"2015-06-17T10:23:02.475392139Z",
    "ver":1,
    "lock_time":0,
    "double_spend":false,
    "vin_sz":1,
    "vout_sz":2,
    "confirmations":0,
    "inputs":[{
        "prev_hash":"64e39fa5322ee604ad548dc5d4ae1a61b0a575278724d0df7e53dd334f5f13e3",
        "output_index":0,
        "script":"",
        "output_value":5432100,
        "sequence":4294967295,
        "addresses":["C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm"],
        "script_type":"",
        "age":0
      }
    ],
    "outputs":[
      {"value":1000,
        "script":"76a9147b2b09ad46d95e177df6969a275db321c66cecf388ac",
        "addresses":["C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi"],
        "script_type":"pay-to-pubkey-hash"
      },
      { "value":5419100,
        "script":"76a9148c6f28c814116f1ae3d0940b2fb05a68a9507e8a88ac",
        "addresses":["C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm"],
        "script_type":"pay-to-pubkey-hash"
      }]
  },
  "tosign":[]
}

Send Transaction Endpoint

Once you’ve finished signing the tosign array locally, put that (hex-encoded) data into the signatures array of the TXSkeleton. You also need to include the corresponding (hex-encoded) public key(s) in the pubkeys array, in the order of the addresses/inputs provided. Signature and public key order matters, so make sure they are returned in the same order as the inputs you provided.

Resource Method Request Object Return Object
/txs/send POST TXSkeleton TXSkeleton

If the transaction was successful, you’ll receive a TXSkeleton with the completed TX (which contains its final hash) and an HTTP Status Code 201.

Dealing with Errors

Signing and creating transactions can be one of the trickiest parts of using blockchains in your applications. Consequently, when an error is encountered when Creating Transactions, we send back an HTTP Status Code 400 alongside a descriptive array of errors within the TXSkeleton.

Customizing Transaction Requests

# here are some example request objects for `/txs/new`
# simplest posssible case, with input address, output address and value
'{
"inputs":
    [{"addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"]}],
"outputs":
  [{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}]
}'

# let's add confirmation field to only allow UTXOs, and set fee preference to medium
'{
"inputs":
    [{"addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"]}],
"outputs":
  [{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}],
"confirmations": 1,
"preference": "medium"
}'

# instead of providing an address, let's specify a particular UTXO via prev_hash and output_index, and add a different change_address
'{
"inputs":
    [{"prev_hash":"a238c817bea2d54dad4cdde38a1cfeb2aa5592313bc49514f3cd0d9db71c69c8", "output_index":0}],
"outputs":
  [{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}],
"confirmations": 1,
"preference": "medium",
"change_address": "CFr99841LyMkyX5ZTGepY58rjXJhyNGXHf"
}'

While we demonstrated the simplest use of our two-endpoint process to create transactions, you can have finer-grain control by modifying the TX request object before sending to /txs/new.

By default, we allow unconfirmed UTXOs as inputs when creating transactions. If you only want to allow confirmed UTXOs, set the confirmations value in your TX request object to 1.

Instead of providing addresses, you can use prev_hash and output_index within the inputs array of your request object, in which case, we’ll use the inputs as provided and not attempt to generate them from a list of addresses. We will compute change and fees the same way.

BlockCypher will set the change address to the first transaction input/address listed in the transaction. To redirect this default behavior, you can set an optional change_address field within the TX request object.

Fees in cryptocurrencies can be complex. We provide 2 different ways for you to control the fees included in your transactions:

  1. Set the preference property in your TX request object to “high”, “medium”, or “low”. This will calculate and include appropriate fees for your transaction to be included in the next 1-2 blocks, 3-6 blocks or 7 or more blocks respectively. You can see the explicit estimates per kilobyte for these high, medium, and low ranges by calling your base resource through the Chain Endpoint. The default fee calculation is based on a “high” preference. A preference set to “zero” will set no fee.
  2. Manually set the fee to a desired amount by setting the fees property in your TX request object. Note that a fee too low may result in an error for some transactions that would require it.

To learn more about fees, bitcoinfees.com is a good resource.

For even more control, you can also change the script_type in the outputs of your partially filled TX. You’ll notice this used to powerful effect in the section on Multisig Transactions. These are the possible script types:

  1. pay-to-pubkey-hash (most common transaction transferring to a public key hash, and the default behavior if no out)
  2. pay-to-multi-pubkey-hash (multi-signatures transaction, now actually less used than pay-to-script-hash for this purpose)
  3. pay-to-pubkey (used for mining transactions)
  4. pay-to-script-hash (used for transactions relying on arbitrary scripts, now used primarily for multi-sig transactions)
  5. multisig-m-of-n (not present in blockchain, but used by BlockCypher to construct P2SH multisig transactions; see Multisig Transactions for more info)
  6. null-data (sometimes called op-return; used to embed small chunks of data in the blockchain)
  7. empty (no script present, mostly used for mining transaction inputs)
  8. unknown (non-standard script)

Push Raw Transaction Endpoint

# Note resource change to bcy/test instead of btc/main
curl -d '{"tx":"01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000"}' https://api.blockcypher.com/v1/bcy/test/txs/push?token=YOURTOKEN

{
  "block_height": -1,
  "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
  "addresses": [
    "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
    "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
  ],
  "total": 4988000,
  "fees": 12000,
  "size": 226,
  "preference": "high",
  "relayed_by": "73.162.198.68",
  "received": "2015-05-22T05:10:00.305308666Z",
  "ver": 1,
  "lock_time": 0,
  "double_spend": false,
  "vin_sz": 1,
  "vout_sz": 2,
  "confirmations": 0,
  "inputs": [
    {
      "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
      "output_index": 0,
      "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",
      "output_value": 5000000,
      "sequence": 4294967295,
      "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
      ],
      "script_type": "pay-to-pubkey-hash",
      "age": 576
    }
  ],
  "outputs": [
    {
      "value": 1000000,
      "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
      "addresses": [
        "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
      ],
      "script_type": "pay-to-pubkey-hash"
    },
    {
      "value": 3988000,
      "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
      "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
      ],
      "script_type": "pay-to-pubkey-hash"
    }
  ]
}
var pushtx = {
  tx: "01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000"
};
$.post('https://api.blockcypher.com/v1/bcy/test/txs/push', JSON.stringify(pushtx))
  .then(function(d) {console.log(d)});
> {
>   "block_height": -1,
>   "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
>   "addresses": [
>     "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
>     "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
>   ],
>   "total": 4988000,
>   "fees": 12000,
>   "size": 226,
>   "preference": "high",
>   "relayed_by": "73.162.198.68",
>   "received": "2015-05-22T05:10:00.305308666Z",
>   "ver": 1,
>   "lock_time": 0,
>   "double_spend": false,
>   "vin_sz": 1,
>   "vout_sz": 2,
>   "confirmations": 0,
>   "inputs": [
>     {
>       "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
>       "output_index": 0,
>       "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",
>       "output_value": 5000000,
>       "sequence": 4294967295,
>       "addresses": [
>         "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
>       ],
>       "script_type": "pay-to-pubkey-hash",
>       "age": 576
>     }
>   ],
>   "outputs": [
>     {
>       "value": 1000000,
>       "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
>       "addresses": [
>         "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
>       ],
>       "script_type": "pay-to-pubkey-hash"
>     },
>     {
>       "value": 3988000,
>       "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
>       "addresses": [
>         "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
>       ],
>       "script_type": "pay-to-pubkey-hash"
>     }
>   ]
> }
> bc_test.push_hex("01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000")
=> {"block_height"=>-1,
 "hash"=>"4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
 "addresses"=>["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
 "total"=>4988000,
 "fees"=>12000,
 "size"=>226,
 "preference"=>"high",
 "relayed_by"=>"199.83.221.11",
 "received"=>"2015-06-17T21:01:54.319930181Z",
 "ver"=>1,
 "lock_time"=>0,
 "double_spend"=>false,
 "vin_sz"=>1,
 "vout_sz"=>2,
 "confirmations"=>0,
 "inputs"=>
  [{"prev_hash"=>"c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
    "output_index"=>0,
    "script"=>
     "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",                                                                              
    "output_value"=>5000000,
    "sequence"=>4294967295,
    "addresses"=>["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
    "script_type"=>"pay-to-pubkey-hash",
    "age"=>37633}],
 "outputs"=>
  [{"value"=>1000000,
    "script"=>"76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
    "addresses"=>["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"],
    "script_type"=>"pay-to-pubkey-hash"},
   {"value"=>3988000,
    "script"=>"76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
    "spent_by"=>"892fd7b36c1c3a2e5edb9b4a5d4ffd9ba74d78d3acf3b249991bd8d10a287dbd",
    "addresses"=>["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
    "script_type"=>"pay-to-pubkey-hash"}]}
>>> from blockcypher import pushtx
>>> pushtx(tx_hex='01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000')
{
    "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", 
        "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
    ], 
    "block_height": -1, 
    "confirmations": 0, 
    "double_spend": False, 
    "fees": 12000, 
    "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50", 
    "inputs": [
        {
            "addresses": [
                "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
            ], 
            "age": 576, 
            "output_index": 0, 
            "output_value": 5000000, 
            "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519", 
            "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044", 
            "script_type": "pay-to-pubkey-hash", 
            "sequence": 4294967295
        }
    ], 
    "lock_time": 0, 
    "outputs": [
        {
            "addresses": [
                "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
            ], 
            "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac", 
            "script_type": "pay-to-pubkey-hash", 
            "value": 1000000
        }, 
        {
            "addresses": [
                "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
            ], 
            "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac", 
            "script_type": "pay-to-pubkey-hash", 
            "value": 3988000
        }
    ], 
    "preference": "high", 
    "received": "2015-05-22T05:10:00.305308666Z", 
    "relayed_by": "73.162.198.68", 
    "size": 226, 
    "total": 4988000, 
    "ver": 1, 
    "vin_sz": 1, 
    "vout_sz": 2
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    //note the change to BlockCypher Testnet
    bcy := gobcy.API{"YOURTOKEN", "bcy", "test"}
    skel, err := bcy.PushTX("01000000011fdd692992f3d3859d01762119313a655177a59226ede31adc0199b28c73c450000000006a4730440220298915c785165233e2f19192bbbb9b8c3fed6d064279cb8968af6698c783b875022037287134f9f0aaf84429ba9bb50f1efcb4cedcfbd34407c285134e068234432c012102b17f04f5fa1bd44315ef33f8759822a302a2ba7fa28c56a50fac0441a341b96affffffff02400d0300000000001976a91446c7681dcacaee1ea3f57eced37755d1d09e070188accc550100000000001976a91490d969679032cc1af6a69b4161778f12e90cb13588ac00000000")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", skel)
}

//Result from `go run`:
// {Trans:{BlockHash: BlockHeight:-1 Hash:55d6ef290774f5428b66a0a27e46a8c37032c33bc15abce4791d56a2f8adb773 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i ByaXmP5k14WRBFLXArfCcqcpAHrUQRy3vL] Total:287500 Fees:12500 Size:225 Preference:high RelayedBy:52.27.84.91, 127.0.0.1 Received:2015-10-16 23:38:09.536632402 +0000 UTC Confirmed:0001-01-01 00:00:00 +0000 UTC Confirmations:0 Confidence:0 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:1 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:50c4738cb29901dc1ae3ed2692a57751653a31192176019d85d3f3922969dd1f OutputIndex:0 OutputValue:300000 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:4730440220298915c785165233e2f19192bbbb9b8c3fed6d064279cb8968af6698c783b875022037287134f9f0aaf84429ba9bb50f1efcb4cedcfbd34407c285134e068234432c012102b17f04f5fa1bd44315ef33f8759822a302a2ba7fa28c56a50fac0441a341b96a Age:0 WalletName:}] Outputs:[{SpentBy: Value:200000 Addresses:[ByaXmP5k14WRBFLXArfCcqcpAHrUQRy3vL] ScriptType:pay-to-pubkey-hash Script:76a91446c7681dcacaee1ea3f57eced37755d1d09e070188ac DataHex: DataString:} {SpentBy: Value:87500 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i] ScriptType:pay-to-pubkey-hash Script:76a91490d969679032cc1af6a69b4161778f12e90cb13588ac DataHex: DataString:}]} ToSign:[] Signatures:[] PubKeys:[] ToSignTX:[] Errors:[]}
<?php
// Run on console:
// php -f .\sample\transaction-api\PushRawTransactionEndpoint.php

$txClient = new TXClient($apiContext);
$hexRawTx = "01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000";
$tx = $txClient->push($hexRawTx);

{
  "block_height": -1,
  "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
  "addresses": [
    "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
    "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
  ],
  "total": 4988000,
  "fees": 12000,
  "size": 226,
  "preference": "high",
  "relayed_by": "73.162.198.68",
  "received": "2015-05-22T05:10:00.305308666Z",
  "ver": 1,
  "lock_time": 0,
  "double_spend": false,
  "vin_sz": 1,
  "vout_sz": 2,
  "confirmations": 0,
  "inputs": [
    {
      "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
      "output_index": 0,
      "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",
      "output_value": 5000000,
      "sequence": 4294967295,
      "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
      ],
      "script_type": "pay-to-pubkey-hash",
      "age": 576
    }
  ],
  "outputs": [
    {
      "value": 1000000,
      "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
      "addresses": [
        "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
      ],
      "script_type": "pay-to-pubkey-hash"
    },
    {
      "value": 3988000,
      "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
      "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
      ],
      "script_type": "pay-to-pubkey-hash"
    }
  ]
}

If you’d prefer to use your own transaction library instead of the recommended path of our two-endpoint transaction generation we’re still happy to help you propagate your raw transactions. Simply send your raw hex-encoded transaction to this endpoint and we’ll leverage our huge network of nodes to propagate your transaction faster than anywhere else.

Resource Method Request Object Return Object
/txs/push POST {“tx”:$TXHEX} TX

$TXHEX is a hex-encoded raw representation of your transaction, for example:

01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000

If it succeeds, you’ll receive a decoded TX object and an HTTP Status Code 201. If you’d like, you can use the decoded transaction hash alongside an Event to track its progress in the network.

Decode Raw Transaction Endpoint

# Note resource change to bcy/test instead of btc/main
curl -d '{"tx":"01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000"}' https://api.blockcypher.com/v1/bcy/test/txs/decode?token=YOURTOKEN

{
  "block_height": -1,
  "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
  "addresses": [
    "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
    "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
  ],
  "total": 4988000,
  "fees": 12000,
  "size": 226,
  "preference": "high",
  "relayed_by": "73.162.198.68",
  "received": "2015-05-22T05:10:00.305308666Z",
  "ver": 1,
  "lock_time": 0,
  "double_spend": false,
  "vin_sz": 1,
  "vout_sz": 2,
  "confirmations": 0,
  "inputs": [
    {
      "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
      "output_index": 0,
      "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",
      "output_value": 5000000,
      "sequence": 4294967295,
      "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
      ],
      "script_type": "pay-to-pubkey-hash",
      "age": 576
    }
  ],
  "outputs": [
    {
      "value": 1000000,
      "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
      "addresses": [
        "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
      ],
      "script_type": "pay-to-pubkey-hash"
    },
    {
      "value": 3988000,
      "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
      "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
      ],
      "script_type": "pay-to-pubkey-hash"
    }
  ]
}
var decodetx = {
  tx: "01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000"
};
$.post('https://api.blockcypher.com/v1/bcy/test/txs/decode', JSON.stringify(decodetx))
  .then(function(d) {console.log(d)});
> {
>   "block_height": -1,
>   "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
>   "addresses": [
>     "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9",
>     "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
>   ],
>   "total": 4988000,
>   "fees": 12000,
>   "size": 226,
>   "preference": "high",
>   "relayed_by": "73.162.198.68",
>   "received": "2015-05-22T05:10:00.305308666Z",
>   "ver": 1,
>   "lock_time": 0,
>   "double_spend": false,
>   "vin_sz": 1,
>   "vout_sz": 2,
>   "confirmations": 0,
>   "inputs": [
>     {
>       "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
>       "output_index": 0,
>       "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",
>       "output_value": 5000000,
>       "sequence": 4294967295,
>       "addresses": [
>         "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
>       ],
>       "script_type": "pay-to-pubkey-hash",
>       "age": 576
>     }
>   ],
>   "outputs": [
>     {
>       "value": 1000000,
>       "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
>       "addresses": [
>         "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
>       ],
>       "script_type": "pay-to-pubkey-hash"
>     },
>     {
>       "value": 3988000,
>       "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
>       "addresses": [
>         "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
>       ],
>       "script_type": "pay-to-pubkey-hash"
>     }
>   ]
> }
> bc_test.decode_hex("01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000")
=> {"block_height"=>-1,
 "hash"=>"4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
 "addresses"=>["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
 "total"=>4988000,
 "fees"=>12000,
 "size"=>226,
 "preference"=>"high",
 "relayed_by"=>"199.83.221.11",
 "received"=>"2015-06-17T21:01:54.319930181Z",
 "ver"=>1,
 "lock_time"=>0,
 "double_spend"=>false,
 "vin_sz"=>1,
 "vout_sz"=>2,
 "confirmations"=>0,
 "inputs"=>
  [{"prev_hash"=>"c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
    "output_index"=>0,
    "script"=>
     "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",                                                                              
    "output_value"=>5000000,
    "sequence"=>4294967295,
    "addresses"=>["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
    "script_type"=>"pay-to-pubkey-hash",
    "age"=>37633}],
 "outputs"=>
  [{"value"=>1000000,
    "script"=>"76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
    "addresses"=>["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"],
    "script_type"=>"pay-to-pubkey-hash"},
   {"value"=>3988000,
    "script"=>"76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
    "spent_by"=>"892fd7b36c1c3a2e5edb9b4a5d4ffd9ba74d78d3acf3b249991bd8d10a287dbd",
    "addresses"=>["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"],
    "script_type"=>"pay-to-pubkey-hash"}]}
>>> from blockcypher import decodetx
>>> tx_hex = '01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000'}
>>> decodetx(tx_hex=tx_hex, coin_symbol='bcy')
{
    "addresses": [
        "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", 
        "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
    ], 
    "block_height": -1, 
    "confirmations": 0, 
    "double_spend": False, 
    "fees": 12000, 
    "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50", 
    "inputs": [
        {
            "addresses": [
                "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
            ], 
            "age": 28188, 
            "output_index": 0, 
            "output_value": 5000000, 
            "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519", 
            "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044", 
            "script_type": "pay-to-pubkey-hash", 
            "sequence": 4294967295
        }
    ], 
    "lock_time": 0, 
    "outputs": [
        {
            "addresses": [
                "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"
            ], 
            "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac", 
            "script_type": "pay-to-pubkey-hash", 
            "value": 1000000
        }, 
        {
            "addresses": [
                "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"
            ], 
            "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac", 
            "script_type": "pay-to-pubkey-hash", 
            "spent_by": "892fd7b36c1c3a2e5edb9b4a5d4ffd9ba74d78d3acf3b249991bd8d10a287dbd", 
            "value": 3988000
        }
    ], 
    "preference": "high", 
    "received": "2015-06-10T23:37:05.211843254Z", 
    "relayed_by": "207.38.134.25", 
    "size": 226, 
    "total": 4988000, 
    "ver": 1, 
    "vin_sz": 1, 
    "vout_sz": 2
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    //note the change to BlockCypher Testnet
    bcy := gobcy.API{"YOURTOKEN", "bcy", "test"}
    skel, err := bcy.DecodeTX("01000000011fdd692992f3d3859d01762119313a655177a59226ede31adc0199b28c73c450000000006a4730440220298915c785165233e2f19192bbbb9b8c3fed6d064279cb8968af6698c783b875022037287134f9f0aaf84429ba9bb50f1efcb4cedcfbd34407c285134e068234432c012102b17f04f5fa1bd44315ef33f8759822a302a2ba7fa28c56a50fac0441a341b96affffffff02400d0300000000001976a91446c7681dcacaee1ea3f57eced37755d1d09e070188accc550100000000001976a91490d969679032cc1af6a69b4161778f12e90cb13588ac00000000")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", skel)
}

//Result from `go run`:
// {Trans:{BlockHash: BlockHeight:-1 Hash:55d6ef290774f5428b66a0a27e46a8c37032c33bc15abce4791d56a2f8adb773 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i ByaXmP5k14WRBFLXArfCcqcpAHrUQRy3vL] Total:287500 Fees:12500 Size:225 Preference:high RelayedBy:52.27.84.91, 127.0.0.1 Received:2015-10-16 23:38:09.536632402 +0000 UTC Confirmed:0001-01-01 00:00:00 +0000 UTC Confirmations:0 Confidence:0 Ver:1 LockTime:0 DoubleSpend:false DoubleOf: ReceiveCount:0 VinSize:1 VoutSize:2 Hex: DataProtocol: ChangeAddress: NextInputs: NextOutputs: Inputs:[{PrevHash:50c4738cb29901dc1ae3ed2692a57751653a31192176019d85d3f3922969dd1f OutputIndex:0 OutputValue:300000 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i] Sequence:4294967295 ScriptType:pay-to-pubkey-hash Script:4730440220298915c785165233e2f19192bbbb9b8c3fed6d064279cb8968af6698c783b875022037287134f9f0aaf84429ba9bb50f1efcb4cedcfbd34407c285134e068234432c012102b17f04f5fa1bd44315ef33f8759822a302a2ba7fa28c56a50fac0441a341b96a Age:0 WalletName:}] Outputs:[{SpentBy: Value:200000 Addresses:[ByaXmP5k14WRBFLXArfCcqcpAHrUQRy3vL] ScriptType:pay-to-pubkey-hash Script:76a91446c7681dcacaee1ea3f57eced37755d1d09e070188ac DataHex: DataString:} {SpentBy: Value:87500 Addresses:[C6LBLb668ZTS4okXhjtzapFWAdnFjH7A4i] ScriptType:pay-to-pubkey-hash Script:76a91490d969679032cc1af6a69b4161778f12e90cb13588ac DataHex: DataString:}]} ToSign:[] Signatures:[] PubKeys:[] ToSignTX:[] Errors:[]}
<?php
// Run on console:
// php -f .\sample\transaction-api\DecodeRawTransactionEndpoint.php

$txClient = new TXClient($apiContext);
$hexRawTx = "01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000";
$tx = $txClient->decode($hexRawTx);

{
  "block_height":-1,
  "hash":"4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50",
  "addresses":[
    "1NsbjF7mCvxa9sdCwRyeZ8qqvWMWuAyjtg",
    "19iz3x4d4Wm4rgav33KmbuRjots6r1K9Wg"
  ],
  "total":4988000,
  "fees":0,
  "size":226,
  "preference":"low",
  "relayed_by":"",
  "received":"0001-01-01T00:00:00Z",
  "ver":1,
  "lock_time":0,
  "double_spend":false,
  "vin_sz":1,
  "vout_sz":2,
  "confirmations":0,
  "inputs":[
    {
      "prev_hash":"c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519",
      "output_index":0,
      "script":"483045022100921fc36b9110942...44f5ab0bc940c105045e2cc77e618044",
      "output_value":0,
      "sequence":4294967295,
      "script_type":"empty",
      "age":0
    }
  ],
  "outputs":[
    {
      "value":1000000,
      "script":"76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac",
      "addresses":[
        "19iz3x4d4Wm4rgav33KmbuRjots6r1K9Wg"
      ],
      "script_type":"pay-to-pubkey-hash"
    },
    {
      "value":3988000,
      "script":"76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac",
      "addresses":[
        "1NsbjF7mCvxa9sdCwRyeZ8qqvWMWuAyjtg"
      ],
      "script_type":"pay-to-pubkey-hash"
    }
  ]
}

We also offer the ability to decode raw transactions without sending propagating them to the network; perhaps you want to double-check another client library or confirm that another service is sending proper transactions.

Resource Method Request Object Return Object
/txs/decode POST {“tx”:$TXHEX} TX

$TXHEX is a hex-encoded raw representation of your transaction, for example:

01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000

If it succeeds, you’ll receive your decoded TX object.

Multisig Transactions

{
    "inputs": [{"addresses": [sourceAddr]}],
    "outputs": [{
        "addresses"   : [pubkey1, pubkey2, pubkey3],
        "script_type" : "multisig-2-of-3",
        "value"       : 250000
    }]
}
{
    "inputs": [{"addresses": [sourceAddr]}],
    "outputs": [{
        "addresses"   : [pubkey1, pubkey2, pubkey3],
        "script_type" : "multisig-2-of-3",
        "value"       : 250000
    }]
}
# Create a custom payload, then use the function:
# BlockCypher.transaction_new_custom(payload)
# Sign your data in the returned TXSkeleton, then use:
# BlockCypher.transaction_send_custom(your_signed_tx_skeleton)
require 'JSON'
payload = JSON.parse('{ "inputs": [{"addresses": [sourceAddr]}],
    "outputs": [{
        "addresses"   : [pubkey1, pubkey2, pubkey3],
        "script_type" : "multisig-2-of-3",
        "value"       : 250000
    }]
}')
package main

import "github.com/blockcypher/gobcy"

func main() {
    //note the change to BlockCypher Testnet
    bcy := gobcy.API{"YOURTOKEN", "bcy", "test"}
    //use TempMultiTX to set up multisig
    temptx := gobcy.TempMultiTX("sourceAddr", "", 25000, 2, []string{"pubkey1", "pubkey2", "pubkey3"})
    //Then follow the New/Send two-step process with this temptx as the input
}
<?php
// Run on console:
// php -f .\sample\transaction-api\CreateTxToFundMultisigAddrWithBuilderEndpoint.php
// Builder classes are optional, see CreateTxToFundMultisigAddrEndpoint.php to see a sample using only base API classes.

$input = TXInputBuilder::aTXInput()
    ->addAddress("n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4")
    ->build();

$output = TXOutputBuilder::aTXOutput()
    ->withScryptType("multisig-2-of-3")
    ->withValue(1000)
    ->addAddress("03798be8162d7d6bc5c4e3b236100fcc0dfee899130f84c97d3a49faf83450fd81")
    ->addAddress("03dd9f1d4a39951013b4305bf61887ada66439ab84a9a2f8aca9dc736041f815f1")
    ->addAddress("03c8e6e99c1d0b42120d5cf40c963e5e8048fd2d2a184758784a041a9d101f1f02")
    ->build();

$tx = TXBuilder::aTX()
    ->addTXInput($input)
    ->addTXOutput($output)
    ->build();

$txClient = new TXClient($apiContext);
$txSkeleton = $txClient->create($tx);

Multisignature transactions are made simple by the method described in the Creating Transactions section, but they deserve special mention. In order to use them, you first need to fund a multisignature address. You use the /txs/new endpoint as before, but instead of the outputs addresses array containing public addresses, it instead contains the public keys associated with the new address. In addition, you must select a script_type of mutlisig-n-of-m, where n and m are numbers (e.g., multisig-2-of-3). The code example demonstrates how the partially filled TX request object would appear.

After you’ve set up your request object, you send to /txs/new and receive a partially filled TXSkeleton as before, but with data to sign from the source address. Sign this data and include the public key(s) of the source address—as demonstrated in the Creating Transactions—then send along to the /txs/send endpoint. If it returns with an HTTP Status Code 201, then your multisignature address (via a pay-to-script-hash address) is funded.

Spending Multisig Funds

{
    "inputs": [{
        "addresses"   : [pubkey1, pubkey2, pubkey3],
        "script_type" : "multisig-2-of-3"
    }],
    "outputs": [{
        "addresses" : [destAddr],
        "value"     : 150000
    }]
}
{
    "inputs": [{
        "addresses"   : [pubkey1, pubkey2, pubkey3],
        "script_type" : "multisig-2-of-3"
    }],
    "outputs": [{
        "addresses" : [destAddr],
        "value"     : 150000
    }]
}
# Create a custom payload, then use the function:
# BlockCypher.transaction_new_custom(payload)
# Sign your data in the returned TXSkeleton, then use:
# BlockCypher.transaction_send_custom(your_signed_tx_skeleton)
require 'JSON'
payload = JSON.parse('{ "inputs": [{
        "addresses"   : [pubkey1, pubkey2, pubkey3],
        "script_type" : "multisig-2-of-3"
    }],
    "outputs": [{
        "addresses" : [destAddr],
        "value"     : 150000
    }] }')
package main

import "github.com/blockcypher/gobcy"

func main() {
    //note the change to BlockCypher Testnet
    bcy := gobcy.API{"YOURTOKEN", "bcy", "test"}
    //use TempMultiTX to set up multisig
    temptx := gobcy.TempMultiTX("", "destAddr", 25000, 2, []string{"pubkey1", "pubkey2", "pubkey3"})
    //Then follow the New/Send two-step process with this temptx as the input
}
<?php
// Run on console:
// php -f .\sample\transaction-api\CreateTxToSpendMultisigFundsWithBuilderEndpoint.php
// Builder classes are optional, see CreateTxToSpendMultisigFunds.php to see a sample using only base API classes.

$input = TXInputBuilder::aTXInput()
    ->addAddress("03798be8162d7d6bc5c4e3b236100fcc0dfee899130f84c97d3a49faf83450fd81")
    ->addAddress("03dd9f1d4a39951013b4305bf61887ada66439ab84a9a2f8aca9dc736041f815f1")
    ->addAddress("03c8e6e99c1d0b42120d5cf40c963e5e8048fd2d2a184758784a041a9d101f1f02")
    ->withScryptType("multisig-2-of-3")
    ->build();

$output = TXOutputBuilder::aTXOutput()
    ->addAddress("n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4")
    ->withValue(1000)
    ->build();

$tx = TXBuilder::aTX()
    ->addTXInput($input)
    ->addTXOutput($output)
    ->build();

$txClient = new TXClient($apiContext);
$txSkeleton = $txClient->create($tx);

Once funded, you might want to programmatically spend the money in the address at some point. Here the process is similar, but with the inputs and outputs reversed. As you can see in the code sample, you need to provide the public keys within the inputs addresses array, and the corresponding script_type of multisig-n-of-m (e.g., multisig-2-of-3). Then you follow the same process of sending to /txs/new and getting an array of data to be signed.

Each party can send their signed data individually to /txs/send and we can correlate the signatures to the public keys; once we have enough signatures we’ll propagate the transaction. Or you can send all needed signatures alongside ordered public keys with a single call to /txs/send.

If you send all signatures in a single call, and you’re spending inputs locked by a multisig-n-of-m script_type, remember that you’ll need n signatures for every element in the TXSkeleton’s tosign array. For example, let’s say /txs/new returns two elements in the tosign array, corresponding to two multisig-2-of-3 inputs locked by pubkey1, pubkey2, and pubkey3:

{...,"tosign":[data1,data2],...}

Then you’d need to return each piece of data signed twice, preserving order between signatures and pubkeys, resulting in four elements for the signatures and pubkeys arrays:

{...,"tosign":[data1,data2], "signatures":[data1sig1,data1sig2,data2sig1,data2sig2], "pubkeys":[pubkey1,pubkey2,pubkey1,pubkey2],...}

Data Endpoint

# Embedding (Hash) Data
curl -d '{"data":"6cbe5d6c75bc36879b5fd32e29b325e288599d31edc76327c7889d407985e2aa"}' https://api.blockcypher.com/v1/btc/main/txs/data?token=YOURTOKEN

{
  "data": "6cbe5d6c75bc36879b5fd32e29b325e288599d31edc76327c7889d407985e2aa",
  "encoding": "hex",
  "token": "YOURTOKEN",
  "hash": "87d494918559a14ea6238ba0e25fb07bffb08716f4a55e25f32ea95a148c85d1"
}

# Embedding String Data
curl -d '{"data":"I am the walrus", "encoding":"string"}' https://api.blockcypher.com/v1/btc/main/txs/data?token=YOURTOKEN

{
  "data": "I am the walrus",
  "encoding": "string",
  "token": "YOURTOKEN",
  "hash": "cb6974e0fd57c91b70403e85ef48c840eecdca4804dfc4897b1321d5328e4f18"
}
# Embedding (Hash) Data
>>> from blockcypher import embed_data
>>> embed_data(to_embed='6cbe5d6c75bc36879b5fd32e29b325e288599d31edc76327c7889d407985e2aa', api_key='YOUR_TOKEN')
{
  "data": "6cbe5d6c75bc36879b5fd32e29b325e288599d31edc76327c7889d407985e2aa",
  "encoding": "hex",
  "token": "YOUR_TOKEN",
  "hash": "87d494918559a14ea6238ba0e25fb07bffb08716f4a55e25f32ea95a148c85d1"
}

# Embedding String Data
>>> from blockcypher import embed_data
>>> embed_data(to_embed='I am the walrus', api_key='YOUR_TOKEN', data_is_hex=False)
{
  "data": "I am the walrus",
  "encoding": "string",
  "token": "YOUR_TOKEN",
  "hash": "cb6974e0fd57c91b70403e85ef48c840eecdca4804dfc4897b1321d5328e4f18"
}
<?php
// Run on console:
// php -f .\sample\transaction-api\DataEndpoint.php

$nullDataClient = new NullDataClient($apiContext);
$nullData = $nullDataClient->embedString('***BlockCypher Data Endpoint Test***'); // max 40 bytes

{
  "data": "***BlockCypher Data Endpoint Test***",
  "encoding": "string",
  "token": "c0afcccdde5081d6429de37d16166ead",
  "hash": "cb6974e0fd57c91b70403e85ef48c840eecdca4804dfc4897b1321d5328e4f18"
}

Some of the most interesting blockchain applications involve embedding data through null-data (also known as OP_RETURN) output scripts with transactions. While you can certainly use our guided transaction process and customize your script output, there’s a simpler way: through our Data Endpoint. All you need is the data you want to embed (up to 40 bytes, inclusive) and we’ll handle the rest.

Resource Method Request Object Return Object
/txs/data POST NullData NullData

In your request object, simply include the data you want to embed. By default, you needn’t set an encoding if your data is hex-encoded (like a hash, the typical use case for null-data). That said, if you want to embed plaintext messages in the blockchain, you can set encoding to string. If successful, the return object will include your original request along with the hash of the transaction containing your data as a null-data output.

To view the data output on the blockchain, simply query the transaction via the hash returned, and check the null-data output within the returned transaction. Please keep in mind that it will always be represented by hex-encoding on the blockchain, even if you selected string as your data encoding; to see it as your original plaintext, you have to convert it client-side.

Microtransaction API

In addition to our normal Transaction API, we offer a unique, on-chain microtransaction endpoint that makes it easy to propagate smaller, nearly-instantly guaranteed, more frequent transactions that are still publicly auditable and trusted through their existence on the blockchain. How can we do what others claim require off-chain, centralized services?

Simple. We leverage our own infrastructure; in particular, our Confidence Factor. When we reach 98% confidence that a microtransaction will reach the next block (usually ~8 seconds), we guarantee its value and return the completed microtransaction. As of this writing, we haven’t had a single failed mictrotransaction, and we’re improving our confidence data all the time.

We also pay for the mining fees for your first 8,000 microtransactions. After which, we automatically optimize fee structure to achieve a balance between guaranteeing confidence it will be in the next block and minimizing cost. If there isn’t enough value in your microtransaction for the fee, we’ll return an error.

Microtransaction Endpoint

The endpoint is simple to employ, and uses a slightly pared down transaction object, appropriately called a MicroTX. For low value source addresses and testing, we support directly sending private keys—we’ll construct, sign, and send the transaction for you. We never store the private key, and remove it from server memory as soon as its used. That said, where your application model supports it and/or when dealing with higher-value source addresses, we encourage you to send public keys and sign the data yourself—a two-step process similar to using /tx/new and /tx/send with normal Transactions.

In either case, you use the same endpoint.

Resource Method Request Object Return Object
/txs/micro POST MicroTX MicroTX

The request object is a partially filled out MicroTX, whose format differs depending on whether you’re sending a private key or public key for the source address. In either case, there are two options you can set:

# Note resource change to bcy/test instead of btc/main, makes it easier to share private keys :)
curl -d '{ "from_private": "97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90", "to_address": "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", "value_satoshis": 10000 }' https://api.blockcypher.com/v1/bcy/test/txs/micro?token=YOURTOKEN

{
"from_private": "97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90",
"to_address": "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn",
"value_satoshis": 10000,
"hash": "892fd7b36c1c3a2e5edb9b4a5d4ffd9ba74d78d3acf3b249991bd8d10a287dbd"
}
var microtx = {
  from_private: "97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90",
  to_address: "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn",
  value_satoshis: 10000
}
var url = 'https://api.blockcypher.com/v1/bcy/test/txs/micro?token='+TOKEN;
$.post(url, JSON.stringify(microtx))
  .then(function(d) {console.log(d)});
> {
> "from_private": "97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90",
> "to_address": "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn",
> "value_satoshis": 10000,
> "hash": "892fd7b36c1c3a2e5edb9b4a5d4ffd9ba74d78d3acf3b249991bd8d10a287dbd"
> }
> bc_test.microtx_from_priv("97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90", "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", 20000)
=> {"from_private"=>"97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90",
 "to_address"=>"C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn",
 "value_satoshis"=>20000,
 "hash"=>"5d618233bccbeaa570072d719ff4718ae02eebffb748210166d9b6180ea8da59"}
# The python library includes a method that will sign and verify a transaction client-side, so your private key never leaves your computer. It should be used instead for security:
>>> from blockcypher import simple_spend
>>> simple_spend(from_privkey='97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90', to_address='C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn', to_satoshis=10000, coin_symbol='bcy')
'7981c7849294648c1e79dd16077a388b808fcf8c20035aec7cc5315b37dacfee'

# If you prefer to use the MicroTX endpoint (say for the wait_guarantee), here's how to do that:
>>> import requests, json
>>> data = {'from_private': '97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90', 'to_address': 'C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn', 'value_satoshis': 10000}
>>> params = {'token': 'YOUR_TOKEN'}
>>> r = requests.post('https://api.blockcypher.com/v1/bcy/test/txs/micro', data=data, params=params)
>>> r.json()
{
    "from_private": "97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90", 
    "hash": "fadfc54f69297e12c17d18ad519e636d96b3c7f0638ca2b011baedaff7cac378", 
    "to_address": "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", 
    "value_satoshis": 10000
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    //note the change to BlockCypher Testnet
    bcy := gobcy.API{"YOURTOKEN", "bcy", "test"}
    micro, err := bcy.SendMicro(gobcy.MicroTX{Priv: "5e4e8495f90a7d2e7091ec60a6586fdfb57b3108823ecfd955732aab1e3c18d7", ToAddr: "CBXcmktjHSwqtHsC8cgRPYT7Mpq9VT7ASp", Value: 200000})
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", micro)
}

//Result from `go run`:
//{Pubkey: Priv:5e4e8495f90a7d2e7091ec60a6586fdfb57b3108823ecfd955732aab1e3c18d7 Wif: ToAddr:CBXcmktjHSwqtHsC8cgRPYT7Mpq9VT7ASp Value:200000 ChangeAddr: Wait:false ToSign:[] Signatures:[] Hash:f3ef51a0d595e5c42a7599335adbb88c03b2fc104376c942dd2201139fe968f7 Inputs:[] Outputs:[] Fees:0}
<?php
// Run on console:
// php -f .\sample\microtransaction-api\CreateMicroTXFromPrivateDocsSample.php

$microTXClient = new MicroTXClient($apiContext);
$microTX = $microTXClient->sendWithPrivateKey(
    "2c2cc015519b79782bd9c5af66f442e808f573714e3c4dc6df7d79c183963cff", // private key
    "C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi", // to address
    10000 // value (satoshis)
);

{
  "from_private":"2c2cc015519b79782bd9c5af66f442e808f573714e3c4dc6df7d79c183963cff",
  "to_address":"C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi",
  "value_satoshis":10000,
  "hash":"6886c3b2f48e410d83eb0ea4ef18396a699aba453a3210bc39bc7af99f061854"
}

Via Private Keys

The simplest way to send a Microtransaction is by using a private key. Within the request object you must include from_private (or the equivalent from_wif), to_address, and value_satoshis. You can read more descriptions about these fields within MicroTX object description, although they should be self-explanatory.

The call will hold until the Confidence Factor reaches 98% (usually about 8 seconds). If successful thereafter, a completed MicroTX object will be returned (which will include the transaction’s hash for future queries), along with an HTTP Status Code 201.

# Note resource change to bcy/test instead of btc/main
curl -d '{ "from_pubkey": "02152e2bb5b273561ece7bbe8b1df...", "to_address": "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", "value_satoshis": 20000 }' https://api.blockcypher.com/v1/bcy/test/txs/micro?token=YOURTOKEN

{
  "from_pubkey": "02152e2bb5b273561ece7bbe...",
  "to_address": "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn",
  "value_satoshis": 20000,
  "tosign": [
    "0f804bef755e623ba3f2c89795814ffa3a0dc53a376ad3deb3c7d3e91957cf12"
  ],
  "token": "YOURTOKEN",
  "inputs": [
        ...
  ],
  "outputs": [
    ...
  ],
  "fees": 735
}

# Using our CLI signer tool...
./signer 0f804bef755e623ba3f2c89795814ffa3a0dc53a376ad3deb3c7d3e91957cf12 $YOURPRIVATEKEY

30450221009050c3c966d1f895b6d6f6ab544113b88b3ce6908083a58170ef1e32da415e2f022037cb5dae353165f505d18a12c50b318c826b2c3552e41f70f7ade186e0434388

#request object is same as return object above, but + signature
curl -d '{ ..., "signatures": ["30450221009050c3c966d1f895b6d6f6ab544113b88b3ce6908083a58170ef1e32da415e2f022037cb5dae353165f505d18a12c50b318c826b2c3552e41f70f7ade186e0434388"],...}' https://api.blockcypher.com/v1/bcy/test/txs/micro?token=YOURTOKEN

{
  "from_pubkey": "02152e2bb5b273561ece7bbe8b1...",
  "to_address": "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn",
  "value_satoshis": 20000,
  "hash": "ce8b3a2d5bb1f552c9d526559dd892b4ee...",
  "inputs": [
    ...
  ],
  "outputs": [
    ...
  ],
  "fees": 735
}
// here we're using bitcoinjs built to expose bigi, buffer, and require
// you can use this library here:
// http://bitcoinjs.org/

var bitcoin = require("bitcoinjs-lib");
var bigi    = require("bigi");
var buffer  = require('buffer');
var key     = new bitcoin.ECPair(bigi.fromHex(my_hex_private_key), true);

var microtx = {
  from_pubkey: "02152e2bb5b273561ece7bbe...",
  to_address: "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn",
  value_satoshis: 20000
}
var url = 'https://api.blockcypher.com/v1/bcy/test/txs/micro?token='+TOKEN;

$.post(url, JSON.stringify(microtx)).then(function(tmptx) {
  // signing each of the hex-encoded string required to finalize the transaction
  tmptx.signatures = tmptx.tosign.map(function(tosign) {
    return key.sign(new buffer.Buffer(tosign, "hex")).toDER().toString("hex");
  });
  // sending back the transaction with all the signatures to broadcast
  $.post(url, tmptx).then(function(finaltx) {
    console.log(finaltx);
  })
});

> {
>   "from_pubkey": "02152e2bb5b273561ece7bbe8b1...",
>   "to_address": "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn",
>   "value_satoshis": 20000,
>   "hash": "ce8b3a2d5bb1f552c9d526559dd892b4ee...",
>   "inputs": [
>   ...
>   ],
>   "outputs": [
>   ...
>   ],
>   "fees": 735
> }
# Our official Ruby SDK can generate the public key from your private key
# But this function signs locally instead of sending to the server
> bc_test.microtx_from_pub("97838249d77bfa65f97be02b63fd1b7bb6a58474c7c22784a0da63993d1c2f90", "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", 20000)
=> {"from_pubkey"=>"02152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044",
 "to_address"=>"C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn",
 "value_satoshis"=>20000,
 "hash"=>"52330171c634e9094bb919e7e5bdaf73ca615d317fb5243224bec30b0f125eb4",
 "inputs"=>
  [{"prev_hash"=>"5d618233bccbeaa570072d719ff4718ae02eebffb748210166d9b6180ea8da59", "output_index"=>2},
   {"prev_hash"=>"ce8b3a2d5bb1f552c9d526559dd892b4eeee9a694fe885bf03c660fb304cd828", "output_index"=>1}],
 "outputs"=>
  [{"address"=>"C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", "value"=>20000},
   {"address"=>"CEyQhiXPtWk8q7hMkv2Kg728i4PYDM9qxf", "value"=>9997795},
   {"address"=>"CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", "value"=>3716000}],
 "fees"=>735}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    //note the change to BlockCypher Testnet
    bcy := gobcy.API{"YOURTOKEN", "bcy", "test"}
    keychain := gobcy.AddrKeychain{Private: "5e4e8495f90a7d2e7091ec60a6586fdfb57b3108823ecfd955732aab1e3c18d7", Public: "03daabc0502d41f52358690a65a7001a2a22df432706cce52a3c98da2c47229a51", Address: "CBXcmktjHSwqtHsC8cgRPYT7Mpq9VT7ASp"}
    //Send MicroTX with Public Key instead of Private Key
    micro, err := bcy.SendMicro(gobcy.MicroTX{Pubkey: keychain.Public, ToAddr: "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn", Value: 300000})
    //Sign result locally with associated Private Key
    err = micro.Sign(keychain.Private)
    //Send signed MicroTX
    micro, err = bcy.SendMicro(micro)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", micro)
}

//Result from `go run`:
//{Pubkey:03daabc0502d41f52358690a65a7001a2a22df432706cce52a3c98da2c47229a51 Priv: Wif: ToAddr:C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn Value:300000 ChangeAddr: Wait:false ToSign:[] Signatures:[] Hash:934dfdaae9269ed7cf33f2484b3b3e8a7e5c1be12b9ea010e4bf95a2d11e59c7 Inputs:[{PrevHash:f3ef51a0d595e5c42a7599335adbb88c03b2fc104376c942dd2201139fe968f7 OutputIndex:0} {PrevHash:f3ef51a0d595e5c42a7599335adbb88c03b2fc104376c942dd2201139fe968f7 OutputIndex:2} {PrevHash:3332e1b220d0584f54a3cc8f8d1c6eafe2767b4f0f017379e8ca514ca4823c32 OutputIndex:1}] Outputs:[{Value:300000 Address:C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn} {Value:9958400 Address:BxeGtkPZM6qUsfkZ4pzaq4TF1RHNoqdZHT} {Value:700000 Address:CBXcmktjHSwqtHsC8cgRPYT7Mpq9VT7ASp}] Fees:3400}
<?php
// Run on console:
// php -f .\sample\microtransaction-api\CreateMicroTXFromPubkeyDocsSample.php

$microTXClient = new MicroTXClient($apiContext);
$microTX = $microTXClient->sendSigned(
    "2c2cc015519b79782bd9c5af66f442e808f573714e3c4dc6df7d79c183963cff", // private key
    "C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi", // to address
    10000 // value (satoshis)
);

{
  "from_pubkey":"02d4e3404e175923adf89c932fab96758716f6a0a896890f2494c5d9141eb3f543",
  "to_address":"C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi",
  "value_satoshis":10000,
  "tosign":[
    "488e6defc3f3d26a20505730a1c64b8a3499e225f1bbd8a0e1b51b38251eed0a"
  ],
  "token":"c0afcccdde5081d6429de37d16166ead",
  "inputs":[
    ...
  ],
  "outputs":[
    ...
  ],
  "fees":735,
  "signatures":[
    "3045022100f99bef2add7d1fd9c...d6d64d8ae19ec090373"
  ],
  "hash":"7fc9e41e6ef29486bc4478ff063934ea9a1ecd08bbfb0a207b39ad92fe55bebf"
}

Via Public Keys and Client-side Signing

If your security/application model allows it, we strongly recommend using public keys instead. Much like creating normal transactions the process requires two endpoint calls; the first is similar to the private key method, but with public keys. E.g., your required object must contain from_pubkey (instead of private keys), to_address, and value_satoshis.

After POSTing this to /txs/micro you’ll receive another partially filled out MicroTX object, but one containing a tosign array. You must then sign the data in this array with your locally-stored private key; signing can be a tricky process, but you can use our signer tool as a baseline. Once that data is signed, it must be inserted to a signatures within the previously returned MicroTX object. Then, you send this completed MicroTX to /txs/micro.

As with the private key method, the call will hold until the Confidence Factor reaches 98% (usually about 8 seconds). If successful thereafter, a completed MicroTX object will be returned (which will include the transaction’s hash for future queries), along with an HTTP Status Code 201.

Security vs Convenience

In general, sending any private key to an outside service is bad security practice. However, security and convenience are often in opposition. In terms of deciding whether passing private keys for microtransactions is a reasonable tradeoff, consider the following:

Finally, we only offer the option of passing private keys because we understand that signing on the client side can be difficult, depending on the environment. We hope that by fully understanding the tradeoffs and risks, you’ll make the right choice for your situation.

Confidence Factor

One of the things that makes BlockCypher’s API uniquely powerful is our ability to accurately predict the likelihood of an attempted double-spend succeeding against a transaction; this percentage probability is optionally included within the confidence attribute on any unconfirmed transaction returned by the Transaction Hash Endpoint when using the includeConfidence flag, in addition to the explicit Transaction Confidence Endpoint detailed below.

So what does that confidence attribute actually mean? In simpler terms, if an unconfirmed transaction returns a confidence factor of 99.9%, then our data says there’s a 0.1% chance that an attempted double-spend will succeed. By design, we’re conservative. Even when we return 90% confidence, the likelihood of a successful double-spend is significantly lower than 10%.

As you may have gathered from the frequency of links to this feature in these docs, we’re exceptionally proud of the work we’ve done to build this feature and provide it to our users. And that pride extends to our own confidence in our confidence product. We’ve leveraged this product internally on two major features:

How does it work?

There are a host of factors that go into our confidence calculation, but you can broadly organize them into two categories. The shape of transactions refers to aspects of transactions that don’t vary with time (time-invariant) in our model. The behavior of transactions refers to aspects of transactions that do vary with time (time-variant) in our model.

On the shape side of our model, we ask a number of questions about a transaction: How is it structured? What are its inputs and outputs? What’s its signature type? Broadly speaking, without knowing anything about the network, does it look like this transaction will be confirmed soon?

The behavior part of our model primarily focuses on how a transaction propagates through the network. In order to model this correctly, you need both a great connection to the network and a lot of past data, which we have. As BlockCypher pools resources for many users, we’re always connected to a statistically significant number of nodes on the network—we target anywhere between 10 to 20% of the active nodes on any given blockchain—and offer connections in return. By monitoring transaction propagation, the number of nodes that have received it, and how quickly they received it, we can calculate its probability to be the “winning” transaction at any given point in time, if a double-spend was attempted. (As an aside, you can always see if a double spend was attempted by checking the double_spend and double_spend_tx attributes on an unconfirmed transaction)

The result is a robust and reliable metric for judging unconfirmed transaction confidence, especially when used in concert with webhooks and websockets. Our work here is based on several public research results in addition to our own in-depth follow-up research, which you can read about here. We are constantly improving our confidence model, and we always publish our findings when we do.

Transaction Confidence Endpoint

curl https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9/confidence

{
"age_millis": 12725,
"receive_count": 666,
"confidence": 0.9901509730004237,
"txhash": "43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9",
"txurl": "https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9"
}
> block_cypher.tx_confidence("4153fddf43c5fd6aa7834bda643619e6dd7d8bf55206bcedb216296881a07830")
=> {"age_millis"=>114659,
 "receive_count"=>783,
 "confidence"=>0.9999808966243114,
 "txhash"=>"4153fddf43c5fd6aa7834bda643619e6dd7d8bf55206bcedb216296881a07830",
 "txurl"=>"https://api.blockcypher.com/v1/btc/main/txs/4153fddf43c5fd6aa7834bda643619e6dd7d8bf55206bcedb216296881a07830"}
>>> from blockcypher import get_transaction_details
>>> get_transaction_details('43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9', confidence_only=True))
{
    "age_millis": 12725, 
    "confidence": 0.9901509730004237, 
    "receive_count": 666, 
    "txhash": "43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9", 
    "txurl": "https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9"
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    //querying a recent TX hash detected on BTC network
    conf, err := btc.GetTXConf("bb01beea75683be16b5d59dd3e084d167f41a6866b6880b3070eefff392fdd2a")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", conf)
}

//Result from `go run`:
//{Age:21112 ReceiveCount:756 Confidence:0.9995223691726662 TXHash:bb01beea75683be16b5d59dd3e084d167f41a6866b6880b3070eefff392fdd2a}
<?php
// Run on console:
// php -f .\sample\confidence-factor\TransactionConfidenceEndpoint.php

$txClient = new TXClient($apiContext);
$txConfidence = $txClient->getConfidence('43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9');

{
  "age_millis":2188284017,
  "receive_count":-1,
  "confidence":1,
  "txhash":"43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9",
  "txurl":"https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9"
}

Our confidence interval is automatically included in any unconfirmed transaction, but you can retrieve it through a specific endpoint too.

Resource Method Return Object
/txs/$TXHASH/confidence GET TXConfidence

TXHASH is a string representing the hex-encoded transaction hash you’re interested in querying, for example:

43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9

The returned TXConfidence object contains the all-important confidence percentage, receive count and more.

You can find an unconfirmed transaction hash from our block explorer here.

Metadata API

Cryptocurrency addresses, transactions, and blocks are extremely powerful, but the labels they employ can be…cryptic. That’s why we have a Metadata API, allowing both public and private key-value storage against addresses, transactions, and blocks.

Private vs Public Metadata

The Metadata API supports both public and private key-value storage. In both cases, setting metadata requires use of a token (if you haven’t already, you can register for one here). Public metadata is immutable; once set, it cannot be modified or deleted. If you accidentally set public metadata and need it deleted, contact us. Also, as implied by the name, it’s openly accessible to the whole world—regardless of whether they have a token or not. Consequently, private metadata is associated and only accessible with your user token. The methods for interacting with metadata are outlined below.

Get Metadata Endpoint

# Get Public Metadata (set by you or anyone else)
curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN

{"name":"silkroad","owner":"dpr"}

# Get Private Metadata (none set yet, returns empty)
curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true

{}
//todo: JS examples
#todo: ruby examples
>>> from blockcypher import get_metadata

# Get Private Metadata (none set yet, returns empty)
>>> get_metadata(address='1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp', api_key='YOUR_TOKEN', private=True)
{}

# Get Public Metadata (set by you or anyone else)
>>> get_metadata(address='1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp', api_key='YOUR_TOKEN')
{
    "name": "silkroad", 
    "owner": "dpr"
}

# Note: get_metadata also accepts 'tx_hash' and 'block_hash' as arguments (instead of 'address')
<?php
//todo: php examples
Resource Method Return Object
/addrs/$ADDRESS/meta GET {“$KEY”:“$VALUE”,…}
/txs/$TXHASH/meta GET {“$KEY”:“$VALUE”,…}
/blocks/$BLOCKHASH/meta GET {“$KEY”:“$VALUE”,…}
Flag Type Effect
private bool If private is true, it will return privately stored metadata under your token. Otherwise, returns public metadata. If not set, it defaults to false, returning public data.

This endpoint retrieves metadata associated with a given $ADDRESS, $TXHASH, or $BLOCKHASH.

Put Metadata Endpoint

# Put Private Metadata, piping to grep to check 204 status code
curl -X PUT -d '{"satoshi":"nakamoto", "alice":"bob"}' -is 'https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true' | grep "HTTP/1.1"

HTTP/1.1 204 No Content

# Get Metadata Again
curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true

{"satoshi":"nakamoto", "alice":"bob"}

# Modify/Add Private Metadata 
curl -X PUT -d '{"satoshi":"moto", "charlie":"tango"}' -is 'https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true' | grep "HTTP/1.1"

HTTP/1.1 204 No Content

# Get Metadata Again
curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true

{"satoshi":"moto", "alice":"bob", "charlie":"tango"}
//todo: JS examples
#todo: ruby examples
>>> from blockcypher import put_metadata

# Put Private Metadata
>>> put_metadata(metadata_dict={"satoshi":"nakamoto", "alice":"bob"}, address='1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp', api_key='YOUR_TOKEN', private=True)
True

# Get Metadata Again
>>> get_metadata(address='1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp', api_key='YOUR_TOKEN', private=True)
{
    "alice": "bob", 
    "satoshi": "nakamoto"
}

# Modify/Add Private Metadata 
>>> put_metadata(metadata_dict={"satoshi":"moto", "charlie":"tango"}, address='1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp', api_key='YOUR_TOKEN', private=True)
True

# Get Metadata Again
>>> get_metadata(address='1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp', api_key='YOUR_TOKEN', private=True)

{
    "alice": "bob", 
    "charlie": "tango", 
    "satoshi": "moto"
}

# Note: put_metadata also accepts 'tx_hash' and 'block_hash' as arguments (instead of 'address')
<?php
//todo: php examples
Resource Method Request Object Return Object
/addrs/$ADDRESS/meta PUT {“$KEY”:“$VALUE”,…} nil
/txs/$TXHASH/meta PUT {“$KEY”:“$VALUE”,…} nil
/blocks/$BLOCKHASH/meta PUT {“$KEY”:“$VALUE”,…} nil
Flag Type Effect
private bool If private is true, it will set/update privately stored metadata under your token. Otherwise, sets public metadata. If not set, it defaults to false, setting public metadata.

This endpoint sets or updates metadata (of the form {“$KEY1:$VALUE1,$KEY2:$VALUE2,…}”) associated with a given $ADDRESS, $TXHASH, or $BLOCKHASH. If another key with the same name already exists under your private metadata store, supplying a new value will replace it. New key-value pairs will be added without replacing prexisting key-value pairs. If successful, it will return an HTTP Status Code 204 with no return object.

Delete Metadata Endpoint

# Delete Private Metadata, pipes to grep to check for 204 status code
curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN | grep "HTTP/1.1"

HTTP/1.1 204 No Content

# Get Private Metadata Again to Confirm Deletion
curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true

{}
//todo: JS examples
#todo: ruby examples
>>> from blockcypher import delete_metadata
>>> delete_metadata(address='1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp', api_key='YOUR_TOKEN')
True

# Get Private Metadata Again to Confirm Deletion
>>> get_metadata(address='1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp', api_key='YOUR_TOKEN', private=True)
{}

# Note: delete_metadata also accepts 'tx_hash' and 'block_hash' as arguments (instead of 'address')
<?php
//todo: php examples
Resource Method Return Object
/addrs/$ADDRESS/meta DELETE nil
/txs/$TXHASH/meta DELETE nil
/blocks/$BLOCKHASH/meta DELETE nil

This endpoint deletes all private metadata associated with a given $ADDRESS, $TXHASH, or $BLOCKHASH and your token.

Analytics API

Blockchains contain a wealth of data, but much of it is inscrutable without arduous effort. Our Analytics API makes uncovering these patterns easy, enabling you to discover insights efficiently and programmatically.

The publicly accessible Analytics API is a set of preconfigured tools and pipelines built against our flexible analytics backend. It serves as both a useful tool for one-off analysis and a live demonstration for custom implementations. If you’re interested in a custom Analytics solution at enterprise scale—or have any ideas for general purpose analytics queries to benefit the community!—please reach out to analytics@blockcypher.com.

The API is asynchronous; here’s the high level general workflow:

  1. Create an analytics job, based on the engine types listed below.
  2. Review its status/check to see if it’s complete.
  3. Fetch the results.

Each engine has its own request parameters—listed below—but all are described in detail on the JobArgs object page.

Analytics Engines and Parameters

The following engines can power your analytics jobs. The resource below represents the URL you’d POST to create an analytics job based on the engine you’re interested in using, along with the required and optional JobArgs parameters for searching.

Paying Addresses

Resource Required JobArgs Optional JobArgs
/analytics/payingaddresses address value_threshold

Returns the list of addresses (along with their associated transaction hashes) and amounts that have paid the target address. Optionally restricted by only returning value_transfer (in satoshis) transfers and above.

Payee Addresses

Resource Required JobArgs Optional JobArgs
/analytics/payeeaddresses address value_threshold

Returns the list of addresses (along with their associated transaction hashes) and amounts that have been paid by the target address. Optionally restricted by only returning value_transfer (in satoshis) transfers and above.

Top Addresses

Resource Required JobArgs Optional JobArgs
/analytics/topaddresses limit, start, end

Returns the most active limit number of addresses, optionally within a certain bounded time range denoted by start and end.

Address Activity

Resource Required JobArgs Optional JobArgs
/analytics/addressactivity address, start, end

Returns the outputs this address generated within a certain bounded time range denoted by start and end.

Address Connectivity

Resource Required JobArgs Optional JobArgs
/analytics/addressconnectivity address, degree limit

N-degree address connectivity query. Currently only examines addresses that generate outputs in the same transaction as the target address.

Source Lookup

Resource Required JobArgs Optional JobArgs
/analytics/sourcelookup source start, end, limit

Returns transactions relayed by a given source (IP address and port) within the given time range denoted by start and end. Note that the max limit is 1000 for this engine.

Create Analytics Job

# let's see who paid a ton of bones into satoshi bones
curl -sd '{"address" : "1bones5gF1HJeiexQus6UtvhU4EUD4qfj", "value_threshold" : 100000000}' https://api.blockcypher.com/v1/btc/main/analytics/payeeaddresses?token=YOURTOKEN

{
    "token": "YOURTOKEN",
    "analytics_engine": "payeeaddresses",
    "created_at": "2016-07-11T19:33:35.518605498Z",
    "completed_at": "0001-01-01T00:00:00Z",
    "finished": false,
    "started": false,
    "ticket": "50b77697-ff13-4a50-8a2b-cee605bc3000",
    "args": {
        "address": "1bones5gF1HJeiexQus6UtvhU4EUD4qfj",
        "value_threshold": 100000000
    }
}

Resource Method Request Object Return Object
/analytics/$ENGINENAME POST JobArgs Job

This creates an analytics job asynchronously, taking in appropriate JobArgs based on the engine as described above. Returns a Job; take special note of the ticket which is the unique identifier you’ll use to get results and query job status.

Get Analytics Job

#let's check the status of our job
curl -s https://api.blockcypher.com/v1/btc/main/analytics/job/50b7697-ff13-4a50-8a2b-cee605bc3000?token=YOURTOKEN
{
    "token": "YOURTOKEN",
    "analytics_engine": "payeeaddresses",
    "created_at": "2016-07-11T19:33:35.518605498Z",
    "completed_at": "2016-07-11T19:35:25.539002964Z",
    "finished": true,
    "started": true,
    "ticket": "50b77697-ff13-4a50-8a2b-cee605bc3000",
    "result_path": "https://api.blockcypher.com/v1/btc/main/analytics/job/50b77697-ff13-4a50-8a2b-cee605bc3000/results",
    "args": {
        "address": "1bones5gF1HJeiexQus6UtvhU4EUD4qfj",
        "value_threshold": 100000000
    }
}
Resource Method Return Object
/analytics/job/$TICKET GET Job

You can check the status of your job with this endpoint, using the ticket returned in the Job object from creating an analytics job. If it’s finished, it will include a result_path with the URL you can follow to get your results.

Get Analytics Job Results

curl -s https://api.blockcypher.com/v1/btc/main/analytics/job/50b77697-ff13-4a50-8a2b-cee605bc3000/results
{
    "page": 0,
    "more": true,
    "next_page": "https://api.blockcypher.com/v1/btc/main/analytics/job/50b77697-ff13-4a50-8a2b-cee605bc3000/results?page=1",
    "results": [
        {
            "DstAddr": "1changemCPo732F6oYUyhbyGtFcNVjprq",
            "SrcAddr": "1bones5gF1HJeiexQus6UtvhU4EUD4qfj",
            "TxHash": "0x3b06b1e9d70217d5e02644703fe79f54355b0ea05cd535787f5a6c627f1c
            43ef",
            "Value": 1e+08
        },
        ....
    ]
}
Resource Method Return Object
/analytics/job/$TICKET/results GET JobResults
Flag Type Effect
page integer Returns page of results.

Returns the results of a ticketed job. The results themselves may be an array of JSON objects or an array of strings, depending on the engine used.

Asset API

Blockchains are about transferring value and ownership, so why can’t that value extend beyond a blockchain’s native token? Thanks to the possibility of embedding arbitrary data through null-data outputs, a blockchain can!

However, the act of creating these alternate forms of value—and choosing a format that was universally readable—can be fraught with difficulty. We built our Asset API to simplify that process. Now instead of spelunking through a blockchain’s native transactions and interpreting them yourself, you can utilize this set of APIs to easily issue, check, and transfer assets. This set of endpoints currently leverages the Open Assets Protocol, a simple, robust method of embedding assets across any blockchain that supports null-data outputs.

The endpoints (and code examples) are ordered below to demonstrate how to create asset addresses, issue assets, transfer them, then query the assets/asset addresses you initially created.

Generate Asset Address Endpoint

# generate on bitcoin mainnet
curl -X POST https://api.blockcypher.com/v1/btc/main/oap/addrs?token=YOURTOKEN

{
  "private": "c0e09905fddb1b4a42d297cae1a5f20ca4cbe813e92a7dc4035ffc54561c05de",
  "public": "02e9431a3ba8d756a26c03c07ffda2a7e28a17b62051f77ea3944c21dc090ba45b",
  "oap_address": "akFjrBkcu9QQoJeBkwWeH54jnymaGVSUBAs",
  "original_address": "15mxwaoZfvX7SQ2PttY6RCqDeAQ6UqVjuM",
  "wif": "L3ge2aRsGReaBtYVYg9Lau2LxDkRW4Cak1dQsuttShEnRXcA1Vfy"
}

# generate on blockcypher testnet
curl -X POST https://api.blockcypher.com/v1/bcy/test/oap/addrs?token=YOURTOKEN

{
  "private": "0eb369746401c3369517239314a6bc0f2bda6124a4dda15643887f86dc0590cf",
  "public": "026b9f2786b96f7f1aae011a08f5aaccc70f2249606fac4c400d6aa35f50bf7373",
  "oap_address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP",
  "original_address": "ByJUiocpifLPaYVTALpA7JYa9DxpLQwte4",
  "wif": "BopcB66fRGgKkwiT2fKyxcawQBJ57DgNyvFq65XuVQdTboxsBkRm"
}

# generate another oap_address to use in examples below
curl -X POST https://api.blockcypher.com/v1/bcy/test/oap/addrs?token=YOURTOKEN

{
  "private": "442abd64783a6411d9e6eb0ed9575c6676bb51824aa3ad4b53577e3d344910c6",
  "public": "03121e17e0996513813c504c63016cea9a7cf9689025e33f9157bccea67ba60846",
  "oap_address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK",
  "original_address": "C3nrGhUDxBbr393u2Wq4PiE8T6oEYU9At1",
  "wif": "BqcYBWUvXszsRi1A5cD6t21CT7sbBoJQEkRSnFuoznJDn4hw5aGg"
}
Resource Method Request Object Return Object
/oap/addrs POST nil AddressKeychain

The Generate Asset Address Endpoint returns a private/public keypair and the associated oap_address (the asset address) and original_address (native address on parent blockchain). Asset addresses are just like regular bitcoin addresses, and are generated from a private-public keypair. They only differ by a prefix (ex: ‘a’ for instead of '1’) to distinguish them.

Issue Asset Endpoint

# Since this is a new address, I need to fund underlying bcy original_address 
# to enable issuance transaction (otherwise no money available for mining fees)

# Going to use a faucet thanks to testnet
curl -d '{"address": "ByJUiocpifLPaYVTALpA7JYa9DxpLQwte4", "amount": 1000000}' https://api.blockcypher.com/v1/bcy/test/faucet?token=YOURTOKEN
{"tx_ref": "e7ca58724100f20b81e82ac24cb83cc112627be9cbfd2d09b96a87fbafe9e636"}

# using same underlying (now-funded address) to issue 1000 assets
# also could have used a different, funded bcy address to issue assets to a new oap_address
curl -d '{"from_private": "0eb369746401c3369517239314a6bc0f2bda6124a4dda15643887f86dc0590cf", "to_address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP", "amount": 1000, "metadata": "1a2b3c4d5e6f"}' https://api.blockcypher.com/v1/bcy/test/oap/issue?token=YOURTOKEN

{
  "ver": 1,
  "assetid": "1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui",
  "hash": "56253cffa1b3508d106391da3646cda2aee0bd080db427321c77ad11739e4239",
  "received": "2015-10-25T05:41:45.092075094Z",
  "double_spend": false,
  "oap_meta": "1a2b3c4d5e6f",
  "inputs": [],
  "outputs": [
    {
      "address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP",
      "value": 1000,
      "original_output_index": 0
    }
  ]
}
Resource Method Request Object Return Object
/oap/issue POST OAPIssue OAPTX

The Issue Asset Endpoint issues new assets onto an OAP to_address, using your private key. Notice that an issuance returns an OAPTX with no inputs, since it is the original issue.

Transfer Asset Endpoint

# using assetid in endpoint as issued above
# from private key
curl -d '{"from_private": "0eb369746401c3369517239314a6bc0f2bda6124a4dda15643887f86dc0590cf", "to_address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK", "amount": 200, "metadata": "1a2b3c4d5e6f"}' https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/transfer?token=YOURTOKEN

{
  "ver": 1,
  "assetid": "1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui",
  "hash": "022e05bdfa2e148bc1882cb7a81506b8316fee6957b11625126d075a8cf8791b",
  "received": "2015-10-25T05:48:13.417949402Z",
  "oap_meta": "1a2b3c4d5e6f",
  "double_spend": false,
  "inputs": [
    {
      "prev_hash": "56253cffa1b3508d106391da3646cda2aee0bd080db427321c77ad11739e4239",
      "output_index": 0,
      "address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP",
      "output_value": 1000
    }
  ],
  "outputs": [
    {
      "address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK",
      "value": 200,
      "original_output_index": 1
    }
  ]
}
Resource Method Request Object Return Object
/oap/$ASSETID/transfer POST OAPIssue OAPTX

The Transfer Asset Endpoint transfers already issued assets (represented by ASSETID) onto a different OAP to_address, using your private key.

List Asset TXs Endpoint

# using asset id as generated above
curl https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/txs?token=YOURTOKEN

[
  "5f13d5c56ed5b7fe673832e2b5b21feceecebfd08aef03f3208ee855d25f050c",
  "022e05bdfa2e148bc1882cb7a81506b8316fee6957b11625126d075a8cf8791b",
  "7216fd3fb2908f87255f9514c98f40cf1299ea6b9182fa4825f5c5bfacf8b038",
  "56253cffa1b3508d106391da3646cda2aee0bd080db427321c77ad11739e4239",
  "dff06ef62b8d67ce6eb0750ed0a414932c1b13b825870d8711cd81219418f6d4"
]
Resource Method Return Object
/oap/$ASSETID/txs GET Array[String]

The List Asset TXs Endpoint returns an array of strings representing transaction hashes associated with this ASSETID.

Get Asset TX Endpoint

# using asset id as generated above, and first txhash from list asset txs endpoint
curl https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/txs/5f13d5c56ed5b7fe673832e2b5b21feceecebfd08aef03f3208ee855d25f050c?token=YOURTOKEN

{
  "ver": 1,
  "assetid": "1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui",
  "hash": "5f13d5c56ed5b7fe673832e2b5b21feceecebfd08aef03f3208ee855d25f050c",
  "block_height": 506539,
  "confirmed": "2015-10-25T04:50:06Z",
  "received": "2015-10-25T04:49:32.37Z",
  "double_spend": false,
  "oap_meta": "1a2b3c4d5e6f",
  "inputs": [],
  "outputs": [
    {
      "address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP",
      "value": 1000,
      "original_output_index": 0
    }
  ]
}
Resource Method Return Object
/oap/$ASSETID/txs/$TXHASH GET OAPTX

The Get Asset TX Endpoint returns an OAPTX by TXHASH and ASSETID.

Get Asset Address Endpoint

# using the transfer address from above
curl https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/addrs/1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK?token=YOURTOKEN

{
  "address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK",
  "total_received": 200,
  "total_sent": 0,
  "balance": 200,
  "unconfirmed_balance": 0,
  "final_balance": 200,
  "n_tx": 1,
  "unconfirmed_n_tx": 0,
  "final_n_tx": 1,
  "txrefs": [
    {
      "tx_hash": "022e05bdfa2e148bc1882cb7a81506b8316fee6957b11625126d075a8cf8791b",
      "block_height": 506598,
      "tx_input_n": -1,
      "tx_output_n": 1,
      "value": 200,
      "ref_balance": 200,
      "spent": false,
      "confirmations": 26,
      "confirmed": "2015-10-25T05:49:07Z",
      "double_spend": false
    }
  ],
  "tx_url": "https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/txs/"
}
Resource Method Return Object
/oap/$ASSETID/addrs/$OAPADDR GET Address

The Get Asset Address Endpoint returns an Address representing information about a particular OAPADDR underneath a given ASSETID. Note that while it returns an Address object, anything that would have represented “satoshis” now represents “amount of asset.” (e.g., balance, value, etc.)

Payment Forwarding

One of the well-known benefits of cryptocurrency is the ability to allow users to partake in online commerce without necessarily requiring extensive setup barriers, like registering new accounts. In that spirit, our Payment Forwarding API is the easiest way to accept—and consolidate—payments securely without forcing your users to create accounts and jump through unnecessary loops. It’s also a generic way to automatically transfer value from one address to another. While there are many possible use cases, the two we hear most about are:

We do not take a fee on payment forwarding, other than the required 10,000 satoshi miner fee; payments are free. However, as part of your own services, you can include a fee (either fixed or a percentage) that will also be automatically transfered to your own address in the same transaction. Fee-based business models are thus easily achieved, and moreover, easily auditable via the blockchain.

Create Payment Endpoint

curl -d '{"destination":"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh","callback_url": "https://my.domain.com/callbacks/new-pay"}' https://api.blockcypher.com/v1/btc/main/payments?token=YOURTOKEN

{
"input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX",
"destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
"callback_url": "https://my.domain.com/callbacks/payments",
"id": "399d0923-e920-48ee-8928-2051cbfbc369",
"token": "YOURTOKEN"
}
var payment = {
  "destination":"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
  "callback_url": "https://my.domain.com/callbacks/new-pay"
}
var url = 'https://api.blockcypher.com/v1/btc/main/payments?token='+TOKEN;
$.post(url, JSON.stringify(payment))
  .then(function(d) {console.log(d)});
{
"input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX",
"destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
"callback_url": "https://my.domain.com/callbacks/payments",
"id": "399d0923-e920-48ee-8928-2051cbfbc369",
"token": "YOURTOKEN"
}
> block_cypher.create_forwarding_address("15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", callback_url: "https://my.domain.com/callbacks/new-pay")
=> {"id"=>"72811fff-7826-4b04-8f99-4f492e84aeaa",
 "token"=>"YOURTOKEN",
 "destination"=>"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
 "input_address"=>"1Php2ZGrEtm5gUaEZNmTtUabmBei6zj9nP",
 "callback_url"=>"https://my.domain.com/callbacks/new-pay"}
>>> from blockcypher import create_forwarding_address_with_details
>>> create_forwarding_address_with_details(destination_address='15qx9ug952GWGTNn7Uiv6vode4RcGrRemh', api_key='YOUR_TOKEN', callback_url='https://my.domain.com/callbacks/new-pay')
{
    "callback_url": "https://my.domain.com/callbacks/new-pay", 
    "destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", 
    "id": "f35c80c2-3347-410d-b4ac-d049910289ec", 
    "input_address": "1CUYiFY3LzEd9dXgR6ubRaYPTq2SMxFFCJ", 
    "token": "YOUR_TOKEN"
}
# You can use create_forwarding_address to just return the input_address and not the rest of the JSON
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    payfwd, err := btc.CreatePayFwd(gobcy.PayFwd{Destination: "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", CallbackURL: "https://my.domain.com/callbacks/payments"})
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", payfwd)
}

//Result from `go run`:
//{ID:6fbe2b48-fe79-44a2-9cdc-8114bc4d5fcc Destination:15qx9ug952GWGTNn7Uiv6vode4RcGrRemh InputAddr:17Ri1Shdzo5G8kiUys1qoeM8w1PNj1eFAK ProcessAddr: ProcessPercent:0 ProcessValue:0 CallbackURL:https://my.domain.com/callbacks/payments EnableConfirm:false MiningFees:0 TXHistory:[]}
<?php
// Run on console:
// php -f .\sample\payment-api\CreatePaymentEndpoint.php

$paymentForwardClient = new PaymentForwardClient($apiContext);
$options = array(
    'callback_url' => 'http://requestb.in/rwp6jirw?uniqid=' . uniqid()
);
$paymentForward = $paymentForwardClient->createForwardingAddress('15qx9ug952GWGTNn7Uiv6vode4RcGrRemh', $options);


{
  "destination":"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
  "callback_url":"http://requestb.in/rwp6jirw?uniqid=5583de7d87288",
  "id":"ec2b4b4f-eeb2-4824-b528-7d78a6f52492",
  "token":"c0afcccdde5081d6429de37d16166ead",
  "input_address":"17h2S1KtX7AqS9DJexqqSTNFCgwCoqqxhU"
}

First, to create an payment forwarding address, you need to POST a partially filled PaymentForward object to the payment creation endpoint. You need to include at least a destination address and your token; optionally, you can add a callback_url, processing fees (either percent or fixed) and a process_fee_address, and a few other options. You can see more details about these options in the PaymentForward object details.

Resource Method Request Object Return Object
/payments POST PaymentForward PaymentForward

In return, you’ll get a more complete PaymentForward object, including an input_address and id.

List Payments Endpoint

curl https://api.blockcypher.com/v1/btc/main/payments?token=YOURTOKEN

[
    {
    "input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX",
    "destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
    "callback_url": "https://my.domain.com/callbacks/payments",
    "id": "399d0923-e920-48ee-8928-2051cbfbc369",
    "token": "YOURTOKEN"
    }
]
$.get('https://api.blockcypher.com/v1/btc/main/payments?token='+TOKEN)
  .then(function(d) {console.log(d)});
[
    {
    "input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX",
    "destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
    "callback_url": "https://my.domain.com/callbacks/payments",
    "id": "399d0923-e920-48ee-8928-2051cbfbc369",
    "token": "YOURTOKEN"
    }
]
> block_cypher.list_forwarding_addresses
=> [{"id"=>"72811fff-7826-4b04-8f99-4f492e84aeaa",
  "token"=>"YOURTOKEN",
  "destination"=>"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
  "input_address"=>"1Php2ZGrEtm5gUaEZNmTtUabmBei6zj9nP",
  "callback_url"=>"https://my.domain.com/callbacks/new-pay"}]
>>> from blockcypher import list_forwarding_addresses
>>> list_forwarding_addresses(api_key='YOUR_TOKEN')
[
    {
        "callback_url": "https://my.domain.com/callbacks/payments", 
        "destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", 
        "id": "f35c80c2-3347-410d-b4ac-d049910289ec", 
        "input_address": "1CUYiFY3LzEd9dXgR6ubRaYPTq2SMxFFCJ", 
        "token": "YOUR_TOKEN"
    }
]
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    payfwds, err := btc.ListPayFwds()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", payfwds)
}

//Result from `go run`:
//[{ID:6fbe2b48-fe79-44a2-9cdc-8114bc4d5fcc Destination:15qx9ug952GWGTNn7Uiv6vode4RcGrRemh InputAddr:17Ri1Shdzo5G8kiUys1qoeM8w1PNj1eFAK ProcessAddr: ProcessPercent:0 ProcessValue:0 CallbackURL:https://my.domain.com/callbacks/payments EnableConfirm:false MiningFees:0 TXHistory:[]}]
<?php
// Run on console:
// php -f .\sample\payment-api\ListPaymentsEndpoint.php

$paymentForwardClient = new PaymentForwardClient($apiContext);
$paymentForwardArray = $paymentForwardClient->listForwardingAddresses();

[
  {
    "id":"ec2b4b4f-eeb2-4824-b528-7d78a6f52492",
    "token":"c0afcccdde5081d6429de37d16166ead",
    "destination":"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
    "input_address":"17h2S1KtX7AqS9DJexqqSTNFCgwCoqqxhU",
    "callback_url":"http://requestb.in/rwp6jirw?uniqid=5583de7d87288"
  }
]

To list your currently active payment forwarding addresses, you can use this endpoint.

Resource Method Return Object
/payments GET Array[PaymentForward]
Flag Type Effect
start integer Returns list of payment forwards starting at the start index; useful for paging beyond the limit of 200 payment forwards.

This returns the full array of your currently active payment forwarding addresses, based on your token. By default, this endpoint only returns the first 200 payment forwards. If you have more, you can page through them using the optional start parameter.

Delete Payment Endpoint

# Piping to grep to just show status code
curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/payments/399d0923-e920-48ee-8928-2051cbfbc369?token=YOURTOKEN | grep "HTTP/1.1"

HTTP/1.1 204 No Content
var url = "https://api.blockcypher.com/v1/btc/main/payments/399d0923-e920-48ee-8928-2051cbfbc369?token="+TOKEN
$.ajax({
  url: url,
  method: "DELETE"
});
> block_cypher.delete_forwarding_address("72811fff-7826-4b04-8f99-4f492e84aeaa")
=> nil
>>> from blockcypher import delete_forwarding_address
>>> delete_forwarding_address('f35c80c2-3347-410d-b4ac-d049910289ec')
True
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    err := btc.DeletePayFwd("6fbe2b48-fe79-44a2-9cdc-8114bc4d5fcc ")
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println("PayFwd Deleted")
    }
}

//Result from `go run`:
//PayFwd Deleted
<?php
// Run on console:
// php -f .\sample\payment-api\DeletePaymentEndpoint.php

$paymentForwardClient = new PaymentForwardClient($apiContext);
$paymentForwardClient->deleteForwardingAddress('1fdf8f9b-cc37-4955-882b-8cbcd670a433');

HTTP/1.1 204 No Content

When you’re done with a payment forwarding address, you can delete it via its id.

Resource Method Return Object
/payments/$PAYID DELETE nil

PAYID is a string representing the payment forwarding request you want to delete, for example:

399d0923-e920-48ee-8928-2051cbfbc369

This will return no object, but will return an HTTP Status Code 204 if the request was successfully deleted.

Events and Hooks

Blockchains are highly transactional systems. Many usage patterns require knowing when an event occurs: i.e., when a transaction is included into a block, or when an unconfirmed transaction is relayed through the network. Instead of requiring you to continuously poll resources, we provide push APIs to facilitate those use cases, and support both WebSockets and WebHooks.

Which Should I Use?

WebSockets are typically used in client applications when a server is not already running: e.g., a web page displaying the most recent transactions or a wallet app updating its UI when a transaction has been confirmed. Websockets are less reliable in longer interactions (> 1 hour) because they require a connection to stay open.

WebHooks are the most reliable way to get event notifications but requires running a server to receive the callbacks. We automatically retry HTTP requests 5 times.

Types of Events

We support a number of different event types, and you can filter your notification requests depending on how you structure your Event request object.

Event Description
unconfirmed-tx Triggered for every new transaction BlockCypher receives before it’s confirmed in a block; basically, for every unconfirmed transaction. The payload is an unconfirmed TX.
new-block Triggered for every new block added to the blockchain you’ve selected as your base resource. The payload is a Block.
confirmed-tx Triggered for every new transaction making it into a new block; in other words, for every first transaction confirmation. This is equivalent to listening to the new-block event and fetching each transaction in the new Block. The payload is a confirmed TX.
tx-confirmation Simplifies listening to confirmations on all transactions for a given address up to a provided threshold. Sends first the unconfirmed transaction and then the transaction for each confirmation. Use the confirmations property within the Event to manually specify the number of confirmations desired (maximum 10, defaults to 6). The payload is a TX.
double-spend-tx Triggered any time a double spend is detected by BlockCypher. The payload is the TX that triggered the event; the hash of the transaction that it’s trying to double spend is included in its double_spend_tx property.
tx-confidence Triggered any time an address has an unconfirmed transaction above the confidence property specified in the Event, based on our Confidence Factor. The payload is the TX that triggered the event. If confidence is not set, defaults to 0.99. To ensure transactions are not missed, even if your confidence threshold is not reached, a transaction is still sent after a minute timeout; please remember to double-check the confidence attribute in the TX payload.

Using WebSockets

# no websockets via cURL, check the Javascript example
// Get latest unconfirmed transactions live
var ws = new WebSocket("wss://socket.blockcypher.com/v1/btc/main");
var count = 0;
ws.onmessage = function (event) {
  var tx = JSON.parse(event.data);
  var shortHash = tx.hash.substring(0, 6) + "...";
  var total = tx.total / 100000000;
  var addrs = tx.addresses.join(", ");
  $('#browser-websocket').before("<div>Unconfirmed transaction " + shortHash + " totalling " + total + "BTC involving addresses " + addrs + "</div>");
  count++;
  if (count > 10) ws.close();
}
ws.onopen = function(event) {
  ws.send(JSON.stringify({event: "unconfirmed-tx"}));
}
# no websockets via PHP, check the Javascript example

Opening a WebSocket to listen to our feeds is easy, like so in Javascript:

new WebSocket("wss://socket.blockcypher.com/v1/btc/main");

The code may differ if you’re not programming in Javascript (check relevant code examples for our standard libraries) but the URL will be identical. Once the socket is opened, the JSON document representing the Event of interest should be sent.

In addition to standard events, WebSockets accept a “ping” event. If you send the following, you will receive the same message back with “ping” replaced by “pong”:

{ "event": "ping" }

A regular ping (i.e. every 20 seconds) allows the WebSocket to stay connected for a longer period of time.

A WebSockets Live Example

Using the example above, we can demonstrate a client-side WebSocket event stream directly from your browser. In that example, we will subscribe to all pooled transactions (new, unconfirmed transactions) by opening a new WebSocket and sending the filter (unconfirmed-tx). Upon notification of new transactions, we format them and add them into the page.

Using WebHooks

WebHooks leverage similar objects and interactions but with two key differences:

We retry individual payloads to your url five times; if one fails, we wait exponentially between retries: 1 second, 2s, 4s, 8s, 16s. In order to protect against stale callback urls, your Event will be deleted if it reaches 50 aggregate callback_errors from failed payloads.

Create WebHook Endpoint

curl -d '{"event": "unconfirmed-tx", "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "url": "https://my.domain.com/callbacks/new-tx"}' https://api.blockcypher.com/v1/btc/main/hooks?token=YOURTOKEN

{
"id": "399d0923-e920-48ee-8928-2051cbfbc369"
"event": "unconfirmed-tx",
"address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
"token": "YOURTOKEN",
"url": "https://my.domain.com/callbacks/new-tx",
"callback_errors": 0
}
var webhook = {
  "event": "unconfirmed-tx",
  "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
  "url": "https://my.domain.com/callbacks/new-tx"
}
var url = 'https://api.blockcypher.com/v1/btc/main/hooks?token='+TOKEN;
$.post(url, JSON.stringify(webhook))
  .then(function(d) {console.log(d)});
{
"id": "399d0923-e920-48ee-8928-2051cbfbc369"
"event": "unconfirmed-tx",
"address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
"token": "YOURTOKEN",
"url": "https://my.domain.com/callbacks/new-tx",
"callback_errors": 0
}
> block_cypher.event_webhook_subscribe("https://my.domain.com/callbacks/new-tx", "unconfirmed-tx", address:"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh")
=> {"id"=>"85883de4-2b01-4f27-a7d4-4400856e124a",
 "token"=>"YOURTOKEN",
 "url"=>"https://my.domain.com/callbacks/new-tx",
 "callback_errors"=>0,
 "address"=>"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
 "event"=>"unconfirmed-tx",
 "filter"=>"addr=15qx9ug952GWGTNn7Uiv6vode4RcGrRemh&event=unconfirmed-tx"}
>>> from blockcypher import subscribe_to_address_webhook
>>> subscribe_to_address_webhook(callback_url='https://my.domain.com/callbacks/new-tx', subscription_address='15qx9ug952GWGTNn7Uiv6vode4RcGrRemh', event='unconfirmed-tx', api_key='YOUR_TOKEN')
'bcaf7c39-9a7f-4e8b-8ba4-23b3c1806039'

# returns the webhook ID
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    hook, err := btc.CreateHook(gobcy.Hook{Event: "tx-confirmation", Address: "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", URL: "https://my.domain.com/callbacks/payments"})
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", hook)
}

//Result from `go run`:
//{ID:376fcc2a-28ac-4ba5-9a29-6449ee0b1d83 Event:tx-confirmation Hash: WalletName: Address:15qx9ug952GWGTNn7Uiv6vode4RcGrRemh Confirmations:6 Confidence:0 Script: URL:https://my.domain.com/callbacks/payments CallbackErrs:0}
<?php
// Run on console:
// php -f .\sample\hook-api\CreateWebHookEndpoint.php

$webHook = new WebHook();
$webHook->setUrl("http://requestb.in/rwp6jirw?uniqid=" . uniqid());
$webHook->setEvent('unconfirmed-tx');
$webHook->setHash('2b17f5589528f97436b5d563635b4b27ca8980aa20c300abdc538f2a8bfa871b');

$webHookClient = new \BlockCypher\Client\WebHookClient($apiContext);
$webHook = $webHookClient->create($webHook);

{
  "url":"http://requestb.in/rwp6jirw?uniqid=5581998e19114",
  "event":"unconfirmed-tx",
  "hash":"2b17f5589528f97436b5d563635b4b27ca8980aa20c300abdc538f2a8bfa871b",
  "id":"d5ca3bd3-5dfb-477d-9fb4-ac3510af258d",
  "token":"c0afcccdde5081d6429de37d16166ead",
  "callback_errors":0,
  "filter":"event=unconfirmed-tx\u0026hash=2b17f5589528f97436b5d563635b4b27ca8980aa20c300abdc538f2a8bfa871b"
}

Using a partially filled out Event, you can create a WebHook using this resource. Check the Event object description and types of events to understand the options available for your events.

Resource Method Request Object Return Object
/hooks POST Event Event

If successful, it will return the Event with a newly generated id.

List WebHooks Endpoint

curl https://api.blockcypher.com/v1/btc/main/hooks?token=YOURTOKEN

[
    {
    "id": "399d0923-e920-48ee-8928-2051cbfbc369"
    "event": "unconfirmed-tx",
    "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
    "token": "YOURTOKEN",
    "url": "https://my.domain.com/callbacks/new-tx",
    "callback_errors": 0
    }
]
$.get('https://api.blockcypher.com/v1/btc/main/hooks?token='+TOKEN)
  .then(function(d) {console.log(d)});
[
    {
    "id": "399d0923-e920-48ee-8928-2051cbfbc369"
    "event": "unconfirmed-tx",
    "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
    "token": "YOURTOKEN",
    "url": "https://my.domain.com/callbacks/new-tx",
    "callback_errors": 0
    }
]
> block_cypher.event_webhook_listall
=> [{"id"=>"85883de4-2b01-4f27-a7d4-4400856e124a",
  "token"=>"YOURTOKEN",
  "url"=>"https://my.domain.com/callbacks/new-tx",
  "callback_errors"=>0,
  "address"=>"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
  "event"=>"unconfirmed-tx",
  "filter"=>"addr=15qx9ug952GWGTNn7Uiv6vode4RcGrRemh&event=unconfirmed-tx"}]
>>> from blockcypher import list_webhooks
>>> list_webhooks('YOUR_TOKEN')
[
    {
        "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", 
        "callback_errors": 0, 
        "confirmations": 6, 
        "event": "unconfirmed-tx", 
        "filter": "event=unconfirmed-tx&addr=15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", 
        "id": "bcaf7c39-9a7f-4e8b-8ba4-23b3c1806039", 
        "token": "YOUR_TOKEN", 
        "url": "https://my.domain.com/callbacks/new-tx"
    }, 
]
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    hooks, err := btc.ListHooks()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", hooks)
}

//Result from `go run`:
//[{ID:376fcc2a-28ac-4ba5-9a29-6449ee0b1d83 Event:tx-confirmation Hash: WalletName: Address:15qx9ug952GWGTNn7Uiv6vode4RcGrRemh Confirmations:6 Confidence:0 Script: URL:https://my.domain.com/callbacks/payments CallbackErrs:0}]
<?php
// Run on console:
// php -f .\sample\hook-api\ListWebHooksEndpoint.php

$webHookClient = new \BlockCypher\Client\WebHookClient($apiContext);
$webHooks = $webHookClient->getAll();

[
  {
    "id":"d5ca3bd3-5dfb-477d-9fb4-ac3510af258d",
    "token":"c0afcccdde5081d6429de37d16166ead",
    "url":"http://requestb.in/rwp6jirw?uniqid=5581998e19114",
    "callback_errors":0,
    "event":"unconfirmed-tx",
    "hash":"2b17f5589528f97436b5d563635b4b27ca8980aa20c300abdc538f2a8bfa871b",
    "filter":"event=unconfirmed-tx\u0026hash=2b17f5589528f97436b5d563635b4b27ca8980aa20c300abdc538f2a8bfa871b"
  }
]

This resource lists your currently active events, according to the base resource and $YOURTOKEN.

Resource Method Return Object
/hooks?token=$YOURTOKEN GET Array[Event]

WebHook ID Endpoint

curl https://api.blockcypher.com/v1/btc/main/hooks/399d0923-e920-48ee-8928-2051cbfbc369

{
"id": "399d0923-e920-48ee-8928-2051cbfbc369"
"event": "unconfirmed-tx",
"address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
"token": "YOURTOKEN",
"url": "https://my.domain.com/callbacks/new-tx",
"callback_errors": 0
}
$.get('https://api.blockcypher.com/v1/btc/main/hooks/399d0923-e920-48ee-8928-2051cbfbc369')
  .then(function(d) {console.log(d)});
{
"id": "399d0923-e920-48ee-8928-2051cbfbc369"
"event": "unconfirmed-tx",
"address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
"token": "YOURTOKEN",
"url": "https://my.domain.com/callbacks/new-tx",
"callback_errors": 0
}
> block_cypher.event_webhook_get("85883de4-2b01-4f27-a7d4-4400856e124a")
=> {"id"=>"85883de4-2b01-4f27-a7d4-4400856e124a",
 "token"=>"YOURTOKEN",
 "url"=>"https://my.domain.com/callbacks/new-tx",
 "callback_errors"=>0,
 "address"=>"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
 "event"=>"unconfirmed-tx",
 "filter"=>"addr=15qx9ug952GWGTNn7Uiv6vode4RcGrRemh&event=unconfirmed-tx"}
>>> from blockcypher import get_webhook_info
>>> get_webhook_info('bcaf7c39-9a7f-4e8b-8ba4-23b3c1806039')
{
    "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", 
    "callback_errors": 0, 
    "event": "unconfirmed-tx", 
    "filter": "addr=15qx9ug952GWGTNn7Uiv6vode4RcGrRemh&event=unconfirmed-tx", 
    "id": "bcaf7c39-9a7f-4e8b-8ba4-23b3c1806039", 
    "token": "YOUR_TOKEN", 
    "url": "https://my.domain.com/callbacks/new-tx"
}
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    hook, err := btc.GetHook("376fcc2a-28ac-4ba5-9a29-6449ee0b1d83")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("%+v\n", hook)
}

//Result from `go run`:
//{ID:376fcc2a-28ac-4ba5-9a29-6449ee0b1d83 Event:tx-confirmation Hash: WalletName: Address:15qx9ug952GWGTNn7Uiv6vode4RcGrRemh Confirmations:6 Confidence:0 Script: URL:https://my.domain.com/callbacks/payments CallbackErrs:0}
<?php
// Run on console:
// php -f .\sample\hook-api\WebHookIdEndpoint.php

$webHookClient = new \BlockCypher\Client\WebHookClient($apiContext);
$webHook = $webHookClient->get('d5ca3bd3-5dfb-477d-9fb4-ac3510af258d');

{
  "id":"d5ca3bd3-5dfb-477d-9fb4-ac3510af258d",
  "token":"c0afcccdde5081d6429de37d16166ead",
  "url":"http://requestb.in/rwp6jirw?uniqid=5581998e19114",
  "callback_errors":0,
  "event":"unconfirmed-tx",
  "hash":"2b17f5589528f97436b5d563635b4b27ca8980aa20c300abdc538f2a8bfa871b",
  "filter":"event=unconfirmed-tx\u0026hash=2b17f5589528f97436b5d563635b4b27ca8980aa20c300abdc538f2a8bfa871b"
}

This resource returns an Event based on its generated id.

Resource Method Return Object
/hooks/$WEBHOOKID GET Event

WEBHOOKID is a string representing the event’s generated id, for example:

399d0923-e920-48ee-8928-2051cbfbc369

Delete WebHook Endpoint

# Piping into grep to get status code
curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/hooks/399d0923-e920-48ee-8928-2051cbfbc369?token=YOURTOKEN | grep "HTTP/1.1"

HTTP/1.1 204 OK
$.ajax({
  url: "https://api.blockcypher.com/v1/btc/main/hooks/399d0923-e920-48ee-8928-2051cbfbc369?token="+TOKEN,
  method: "DELETE"
});
> block_cypher.event_webhook_delete("85883de4-2b01-4f27-a7d4-4400856e124a")
=> nil
>>> from blockcypher import unsubscribe_from_webhook
>>> unsubscribe_from_webhook('bcaf7c39-9a7f-4e8b-8ba4-23b3c1806039')
True
package main

import (
    "fmt"

    "github.com/blockcypher/gobcy"
)

func main() {
    btc := gobcy.API{"YOURTOKEN", "btc", "main"}
    err := btc.DeleteHook("376fcc2a-28ac-4ba5-9a29-6449ee0b1d83")
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println("Hook deleted")
    }
}

//Result from `go run`:
//Hook deleted
<?php
// Run on console:
// php -f .\sample\hook-api\DeleteWebHookEndpoint.php

$webHookClient = new \BlockCypher\Client\WebHookClient($apiContext);
$webHookClient->delete('d5ca3bd3-5dfb-477d-9fb4-ac3510af258d');

HTTP/1.1 204 OK

This resource deletes an active Event based on its id. Remember to include your token, or the request will fail.

Resource Method Return Object
/hooks/$WEBHOOKID DELETE nil

WEBHOOKID is a string representing the event’s generated id, for example:

399d0923-e920-48ee-8928-2051cbfbc369

If successful, it won’t return any objects, but will respond with an HTTP Status Code 204.