One of the goals for Blocktap is to bring pricing and network data into a single queryable interface. We have completed the groundwork to make this possible and have added support for Bitcoin data.

You can now query Bitcoin blocks, transactions, and addresses. We also compute time series statistics that can be combined alongside market pricing information.

Network Data

Querying Bitcoin blocks, transactions, and addresses solves the use case for creating block explorers and retrieving known data from the Bitcoin blockchain. Simply query the Bitcoin asset and return the desired properties.  

This shows how network statistics can be returned for Bitcoin:

query bitcoin {
  asset(assetSymbol:"BTC"){
    assetName
    ... on AssetBtc {
      info {
        bestHeight
        bestBlockHash
        blocks
        lastBlockUnix
        lastBlockDate
        mempoolSize
        difficulty
        sizeBytes
      }
    }
  }
}
{
  "data": {
    "asset": {
      "assetName": "Bitcoin",
      "info": {
        "bestHeight": 564067,
        "bestBlockHash": "0000000000000000001a716e99d64b55aab3e4809cfec9740f7f00de42285af8",
        "blocks": 564067,
        "lastBlockUnix": 1550787727,
        "lastBlockDate": "2019-02-21T22:22:07.490Z",
        "mempoolSize": 19675,
        "difficulty": "6061518831027.271",
        "sizeBytes": "233613593446"
      }
    }
  }
}

Try me!

In a similar manner you can query individual blocks:

query bitcoinBlock {
  asset(assetSymbol:"BTC"){
    assetName
    ... on AssetBtc {
      block {
        height
        hash
        prevHash
        nextHash
        merkleRoot
        version
        difficulty
        sizeBytes
        time
        date
        bits
        nonce
        confirmations
        txCount
        txs(limit:2) {
          txId
          valueIn
          valueOut
          fees
          vin {
            value
            addresses
          }
          vout {
            value
            spent
            addresses
          }
        }
      }
    }
  }
}
{
  "data": {
    "asset": {
      "assetName": "Bitcoin",
      "block": {
        "height": 564067,
        "hash": "0000000000000000001a716e99d64b55aab3e4809cfec9740f7f00de42285af8",
        "prevHash": "00000000000000000007f9a01d9a1781d27515dca5b3035e6f48f20a7a100825",
        "nextHash": "",
        "merkleRoot": "bc30907707c31d9690092bc294ce17948cd4f07d24b23ebe736d040b815e27bb",
        "version": 536870912,
        "difficulty": "6061518831027.271",
        "sizeBytes": "1192402",
        "time": 1550787700,
        "date": "2019-02-21T22:21:40.000Z",
        "bits": "172e6f88",
        "nonce": "252248448",
        "confirmations": 1,
        "txCount": 2743,
        "txs": [
          {
            "txId": "ca8f1d84e99e102c85cdd00c7e7c9bde5b01c2c7df0a6906915c10913690bbe0",
            "valueIn": "0",
            "valueOut": "1285978826",
            "fees": "0",
            "vin": [
              {
                "value": "0",
                "addresses": []
              }
            ],
            "vout": [
              {
                "value": "1285978826",
                "spent": false,
                "addresses": [
                  "bc1qjl8uwezzlech723lpnyuza0h2cdkvxvh54v3dn"
                ]
              },
              {
                "value": "0",
                "spent": false,
                "addresses": [
                  "OP_RETURN aa21a9ed4d81d08d6b1ac6f52a09d36a0124db4855898ee66e14320d853fb69618c4e374"
                ]
              },
              {
                "value": "0",
                "spent": false,
                "addresses": []
              }
            ]
          },
          {
            "txId": "5f93be09bc37862329bb34b3750dfceee84ed2b6e04fbfa921089eafaf607a3b",
            "valueIn": "9475896",
            "valueOut": "8975896",
            "fees": "500000",
            "vin": [
              {
                "value": "9475896",
                "addresses": [
                  "1HxYE5qais5BwQqwCbvXjRDqZrHZbk67Pg"
                ]
              }
            ],
            "vout": [
              {
                "value": "1933814",
                "spent": false,
                "addresses": [
                  "3GPkz7MFUQJdDudeB1cL5yXqChrfpHkYkw"
                ]
              },
              {
                "value": "7042082",
                "spent": false,
                "addresses": [
                  "18b4ovdAJjX2GuKnVns9dRnbq3h1ZGMxTW"
                ]
              }
            ]
          }
        ]
      }
    }
  }
}

Try me!

You can view more examples and learn about the various query options in the Bitcoin Asset documentation.

Time Series Data

In addition to the network information, Blocktap creates time based statistics for blocks and transactions. This information can be powerfully combined with pricing data in a single query!

# join market and network information for bitcoin / usdt
query timeseries {
  timeseries(resolution:_1d startDate:"2019-01-01" limit: 30 sort:OLD_FIRST){
    startDate
    
    # btc transaction stats
    assets(filter:{ assetSymbol:{_eq:"BTC"}}){
      assetSymbol
      ...on TimeSeriesBtc {
        onchain {
          totalTxs
          totalValueOut
        }
      }
    }
    
    # btc/usdt market information
    markets(filter:{
      baseSymbol:{_eq:"BTC"}
      quoteSymbol:{_eq:"USDT"}
    }) {
      exchangeSymbol
      closePrice
      baseVolume
    }

  }
}
{
  "data": {
    "timeseries": [
      {
        "startDate": "2019-01-01T00:00:00.000Z",
        "assets": [
          {
            "assetSymbol": "BTC",
            "onchain": {
              "totalTxs": "234576",
              "totalValueOut": "547892.92478019"
            }
          }
        ],
        "markets": [
          {
            "exchangeSymbol": "Binance",
            "closePrice": "3797.14000000",
            "baseVolume": "23741.68703300"
          },
          {
            "exchangeSymbol": "Bittrex",
            "closePrice": "3795.52231154",
            "baseVolume": "506.24117747"
          },
          {
            "exchangeSymbol": "Coinex",
            "closePrice": "0.00000000",
            "baseVolume": "0.00000000"
          },
          {
            "exchangeSymbol": "HitBTC",
            "closePrice": "3811.44000000",
            "baseVolume": "21810.58000000"
          },
          {
            "exchangeSymbol": "Huobi",
            "closePrice": "3796.24000000",
            "baseVolume": "21065.87453337"
          },
          {
            "exchangeSymbol": "OKEx",
            "closePrice": "3796.27430000",
            "baseVolume": "42602.97791188"
          },
          {
            "exchangeSymbol": "Poloniex",
            "closePrice": "3795.55974532",
            "baseVolume": "519.29482163"
          },
          {
            "exchangeSymbol": "ZB",
            "closePrice": "3797.72000000",
            "baseVolume": "4209.43720000"
          }
        ]
      },
      ...
    ]
  }
}

Try me!

You can learn more in the Bitcoin Time Series documentation.