Blockchain Node API

This reference guide outlines the interfaces to access blockchain nodes that are created as part of the Bloq Nodes service.

Any key deviations from the standard node interface (by blockchain) are highlighted as part of the reference guide.

TIP

Testnet nodes use the same API calls as their mainnet counterparts. Just make sure the address port matches your node's chain!

Jump to:

BTC

TIP

The Bitcoin Node API is largely interoperable with Litecoin, with a few documented distinctions. Please see the Litecoin REST API documentation and Litecoin JSON-RPC methods for more information.

REST API

TIP

A key-client pair must be created prior to using the Nodes service. Use the bcl client-keys command if client-keys do not currently exist.

If a key-client pair already exists, use the bcl conf command to load your keypair.

TIP

In addition to having a client-key pair generated, a clientAccessToken and refreshToken are also required to access the Nodes service. Use the bcl client-token command to generate the tokens.

To learn more about the REST API that this node provides please see the REST API documentation.

JSON-RPC

The Nodes service supports the standard Bitcoin JSON-RPC calls with a number that are blacklisted. RPC calls that would negatively impact the running of the service are blacklisted. Wallet specific RPC calls are also currently not allowed as all nodes are run with --disable-wallet.

POST getblock

curl -k -X POST \
  --user <NodeUser>:<NodePass> \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc": "1.0", "method": "getblock", "params": ["000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", true] }' \
  https://<ip-address>:8332/

Response

{
  "hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
  "confirmations": 633169,
  "size": 285,
  "height": 0,
  "version": 1,
  "versionHex": "00000001",
  "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
  "tx": ["4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"],
  "time": 1231006505,
  "mediantime": 1231006505,
  "nonce": 2083236893,
  "bits": "1d00ffff",
  "difficulty": 1,
  "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",
  "nTx": 1,
  "nextblockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"
}

POST getdifficulty

curl -k -X POST \
  --user <NodeUser>:<NodePass> \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc": "1.0", "method": "getdifficulty", "params": [] }' \
  https://<ip-address>:8332/

Response

{
  "result": 15958652328578.1588
}

Full BTC JSON-RPC call list

For a full list of Bitcoin JSON-RPC commands please see Bitcoin JSON-RPC methods.

Blacklisted BTC JSON-RPC Calls

The following list of JSON-RPC calls are NOT available for the Nodes Bitcoin (BTC) service:

  • stop

  • generate

  • generatetoaddress

Disabled BTC Wallet Specific Calls

Wallet specific RPC calls are currently disabled. For the full list of unsupported wallet RPCs, please see Wallet RPC methods.

BCH

REST API

TIP

A key-client pair must be created prior to using the Nodes service. Use the bcl client-keys command if client-keys do not currently exist.

If a key-client pair already exists, use the bcl conf command to load your keypair.

TIP

In addition to having a client-key pair generated, a clientAccessToken and refreshToken are also required to access the Nodes service. Use the bcl client-token command to generate the tokens.

To learn more about the REST API that this node provides please see the REST API documentation.

JSON-RPC

The Nodes service supports the standard Bitcoin Cash JSON-RPC calls with a number that are blacklisted. RPC calls that would negatively impact the running of the service are blacklisted. Wallet specific RPC calls are also currently not allowed as all nodes are run with --disable-wallet.

Full BCH JSON-RPC call list

For a full list of Bitcoin JSON-RPC commands please see Bitcoin Cash JSON-RPC methods.

Blacklisted BCH JSON-RPC Calls

The following list of JSON-RPC calls are NOT available for the Nodes Bitcoin Cash (BCH) service:

  • stop

  • generate

  • generatetoaddress

Disabled BCH Wallet Specific Calls

Wallet specific RPC calls are currently disabled. For the full list of unsupported wallet RPCs, please see Wallet RPC methods.

ETH

JSON-RPC

The Nodes service supports the standard Ethereum JSON-RPC calls with a number that are blacklisted. RPC calls that would negatively impact the running of the service are blacklisted.

POST blockNumber

curl -X POST \
  --user <NodeUser>:<NodePass> \
  -H 'Content-Type: application/json' \
  -d '{ "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 }' \
  https://<ip-address>:8545/

Response

{
  "jsonrpc": "2.0",
  "result": "0x981fb8", //9969592
  "id": 1
}

Full ETH JSON-RPC call list

For a full list of Ethereum JSON-RPC commands see Ethereum JSON-RPC methods.

Blacklisted ETH JSON-RPC Calls

The following list of JSON-RPC calls are NOT available for the Nodes Ethereum (ETH) service:

  • eth_accounts

  • shh_newIdentity

Avalanche

Bloq Avalanche nodes support the JSON RPC described in the Avalanche API reference.

Management API

A special API is provided on port 8080 for all nodes with calls to help manage the nodes.

GET /status

Request the status of a node.

Responses

StatusMeaningDescription

200

Successful operation

Example responses

200 Response

"healthy"

Code Sample

curl -k -X GET \
  --user <NodeUser>:<NodePass> \
  -H 'Content-Type: application/json' \
  https://<ip-address>:8080/status

GET /logs

Request the logs from the running blockchain daemon.

Parameters

NameInTypeRequiredDescription

lines

body

number

false

Number of log lines to retrieve. Leave blank for full log.

Responses

StatusMeaningDescription

200

Successful operation

Example responses

200 Response

[
  "B2019-07-01T19:43:21Z Bitcoin Core version v0.17.1 (release build)",
  "z2019-07-01T19:43:21Z InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1",
  "2019-07-01T19:43:21Z Assuming ancestors of block 0000000000000000002e63058c023a9a1de233554f28c7b21380b6c9003f36a8 have valid signatures.",
  "p2019-07-01T19:43:21Z Setting nMinimumChainWork=0000000000000000000000000000000000000000028822fef1c230963535a90d"
]

Code Sample

curl -k -X GET \
  --user <NodeUser>:<NodePass> \
  -H 'Content-Type: application/json' \
  https://<ip-address>:8080/logs

Last updated