# Blockchain Node API

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

{% hint style="success" %}
**TIP**

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

*Jump to:*

* [BTC](#btc)
* [BCH](#bch)
* [ETH](#eth)
* [Avalanche](#avalanche)

## BTC <a href="#btc" id="btc"></a>

{% hint style="success" %}
**TIP**

The Bitcoin Node API is largely interoperable with Litecoin, with a few documented distinctions. Please see the [Litecoin REST API documentation](https://github.com/litecoin-project/litecoin/blob/master/doc/REST-interface.md#supported-api) and [Litecoin JSON-RPC methods](https://litecoin.info/index.php/Litecoin_API) for more information.
{% endhint %}

### REST API <a href="#rest-api" id="rest-api"></a>

{% hint style="success" %}
**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.
{% endhint %}

{% hint style="success" %}
**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.
{% endhint %}

To learn more about the REST API that this node provides please see the [REST API documentation](https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/doc/REST-interface.md#supported-api).

### JSON-RPC <a href="#json-rpc" id="json-rpc"></a>

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**

```shell
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**

```json
{
  "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**

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

**Response**

```json
{
  "result": 15958652328578.1588
}
```

#### **Full BTC JSON-RPC call list**

For a full list of Bitcoin JSON-RPC commands please see [Bitcoin JSON-RPC methods](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list).

#### **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](https://bitcoin.org/en/developer-reference#wallet-rpcs).

## BCH <a href="#bch" id="bch"></a>

### REST API <a href="#rest-api-2" id="rest-api-2"></a>

{% hint style="success" %}
**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.
{% endhint %}

{% hint style="success" %}
**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.
{% endhint %}

To learn more about the REST API that this node provides please see the [REST API documentation](https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/doc/REST-interface.md#supported-api).

### JSON-RPC <a href="#json-rpc-2" id="json-rpc-2"></a>

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](https://docs.bitcoincashnode.org/doc/json-rpc/).

#### **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](https://bitcoin.org/en/developer-reference#wallet-rpcs).

## ETH <a href="#eth" id="eth"></a>

### JSON-RPC <a href="#json-rpc-3" id="json-rpc-3"></a>

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**

```shell
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**

```json
{
  "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](https://github.com/ethereum/wiki/wiki/JSON-RPC).

#### **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 <a href="#avalanche" id="avalanche"></a>

Bloq Avalanche nodes support the JSON RPC described in the [Avalanche API reference](https://docs.avax.network/build/tools/public-api#using-the-public-api-nodes).

### Management API <a href="#management-api" id="management-api"></a>

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

#### GET /status <a href="#get-status" id="get-status"></a>

Request the status of a node.

**Responses**

| Status | Meaning                                                 | Description          |
| ------ | ------------------------------------------------------- | -------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | Successful operation |

**Example responses**

> 200 Response

```
"healthy"
```

**Code Sample**

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

#### GET /logs <a href="#get-logs" id="get-logs"></a>

Request the logs from the running blockchain daemon.

**Parameters**

| Name  | In   | Type   | Required | Description                                                |
| ----- | ---- | ------ | -------- | ---------------------------------------------------------- |
| lines | body | number | false    | Number of log lines to retrieve. Leave blank for full log. |

**Responses**

| Status | Meaning                                                 | Description          |
| ------ | ------------------------------------------------------- | -------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | Successful operation |

**Example responses**

> 200 Response

```json
[
  "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**

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