# Nodes API

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

Clusters utilize the same API as Bloq Nodes. To interact with your node clusters, change the `/nodes/` path in the API URL to `/clusters/`.
{% endhint %}

Jump to:

* [DELETE /users/me/nodes/{id}](#delete-users-me-nodes-id)
* [GET /chains](#get-chains)
* [GET /users/me/nodes](#get-users-me-nodes)
* [GET /users/me/nodes/{id}](#get-users-me-nodes-id)
* [POST /users/me/nodes](#post-users-me-nodes)

## GET /chains

This resource lists the chains and versions available for creating new nodes.

### Responses

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

### Example responses

> 200 Response

```json
[
  {
    "chain": "bch",
    "network": "mainnet",
    "software": "abc-0.19"
  },
  {
    "chain": "bch",
    "network": "testnet",
    "software": "abc-0.19"
  },
  {
    "chain": "btc",
    "network": "mainnet",
    "software": "core-0.17"
  },
  {
    "chain": "btc",
    "network": "testnet",
    "software": "core-0.17"
  }
  {
    "chain": "eth",
    "network": "mainnet",
    "software": "geth-1.8"
  },
  {
    "chain": "ltc",
    "network": "mainnet",
    "software": "litecoin-0.17"
  }
]
```

### Code sample

```shell
curl -X GET https://nodes.bloq.cloud/chains
```

## POST /users/me/nodes

This resource creates a new node.

### Parameters

| Name  | In   | Type    | Required | Description                                                                                       |
| ----- | ---- | ------- | -------- | ------------------------------------------------------------------------------------------------- |
| image | body | string  | true     | Blockchain id. `btc`, `bch`, `ltc`, `btctestnet`, `bchtestnet`, and `eth` are currently supported |
| large | body | boolean | false    | Set true to request a larger/faster node.                                                         |
| jwt   | body | boolean | false    | Use jwt Bearer token for auth.                                                                    |

> Body parameter

```json
{
  "image": "btc",
  "large": false,
  "jwt:" false
}
```

### Responses

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

**Example responses**

> 200 Response

```json
{
  "user": "user-xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "id": "node-xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "image": "btc",
  "version": "core-0.17",
  "state": "started",
  "nodeUser": "xxxxxxxxxx",
  "nodePass": "xxxxxxxxxx",
  "instance": {
    "vendor": "aws",
    "id": "i-032155ff0235d2dbb",
    "imageId": "ami-021e0f4b36b068ccb",
    "type": "t2.large"
  },
  "startedAt": "2019-03-27T18:40:19.878Z"
}
```

### Code sample

```shell
curl -X POST https://nodes.bloq.cloud/users/me/nodes \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer <AUTH_TOKEN>'
  -d '{
   "image": "btc"
  }'
```

## GET /users/me/nodes

This resource list created nodes

### Responses

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

**Example responses**

> 200 Response

```json
[
  {
    "stoppedAt": "2020-04-21T05:00:18.586Z",
    "serviceData": {
      "amiPrefix": "btc",
      "performance": "standard",
      "software": "core-0.17",
      "ports": [8080, 8332]
    },
    "ip": "18.213.193.254",
    "createdAt": "2020-04-21T00:45:07.687Z",
    "ttl": "1588050018",
    "user": "user-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "userPlanData": {
      "startsAt": "2020-04-21T00:45:05.324Z",
      "id": "user-plan-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "plan": "plan-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "expiresAt": "2020-05-21T00:45:05.324Z"
    },
    "instance": {
      "region": "us-east-1",
      "id": "i-02cb186c0808950f6",
      "imageId": "ami-01ee6543215d4006b"
    },
    "vendor": {
      "name": "aws",
      "subnet": "subnet-41daba24",
      "securityGroups": [
        "sg-50d39921",
        "sg-0a52e56ee0c02fd7a",
        "sg-784d5703",
        "sg-0769b9650222e64ce"
      ],
      "region": "us-east-1",
      "instanceType": "t3.large",
      "quickSync": true
    },
    "network": "mainnet",
    "state": "stopped",
    "service": "service-f409a426-8bdd-5c65-bcd3-7c6d0424a5ac",
    "auth": {
      "type": "basic",
      "user": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "pass": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    },
    "updatedAt": "2020-04-21T00:45:09.419Z",
    "chain": "btc",
    "id": "node-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  },
  {
    "stoppedAt": "2020-04-21T05:00:18.586Z",
    "serviceData": {
      "amiPrefix": "btc",
      "performance": "standard",
      "software": "core-0.17",
      "ports": [8080, 8332]
    },
    "ip": "18.213.193.254",
    "createdAt": "2020-04-21T00:45:07.687Z",
    "ttl": "1588050018",
    "user": "user-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "userPlanData": {
      "startsAt": "2020-04-21T00:45:05.324Z",
      "id": "user-plan-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "plan": "plan-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "expiresAt": "2020-05-21T00:45:05.324Z"
    },
    "instance": {
      "region": "us-east-1",
      "id": "i-02cb186c0808950f6",
      "imageId": "ami-01ee6543215d4006b"
    },
    "vendor": {
      "name": "aws",
      "subnet": "subnet-41daba24",
      "securityGroups": [
        "sg-50d39921",
        "sg-0a52e56ee0c02fd7a",
        "sg-784d5703",
        "sg-0769b9650222e64ce"
      ],
      "region": "us-east-1",
      "instanceType": "t3.large",
      "quickSync": true
    },
    "network": "mainnet",
    "state": "stopped",
    "service": "service-f409a426-8bdd-5c65-bcd3-7c6d0424a5ac",
    "auth": {
      "type": "basic",
      "user": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "pass": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    },
    "updatedAt": "2020-04-21T00:45:09.419Z",
    "chain": "btc",
    "id": "node-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  }
]
```

### Code sample

```shell
curl -X GET https://nodes.bloq.cloud/users/me/nodes \
  -H 'Authorization: Bearer <AUTH_TOKEN>'
```

## GET /users/me/nodes/{id}

This resource fetches a node by ID.

### Responses

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

**Example responses**

> 200 Response

```json
{
  "stoppedAt": "2020-04-21T05:00:18.586Z",
  "serviceData": {
    "amiPrefix": "btc",
    "performance": "standard",
    "software": "core-0.17",
    "ports": [8080, 8332]
  },
  "ip": "18.213.193.254",
  "createdAt": "2020-04-21T00:45:07.687Z",
  "ttl": "1588050018",
  "user": "user-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "userPlanData": {
    "startsAt": "2020-04-21T00:45:05.324Z",
    "id": "user-plan-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "plan": "plan-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "expiresAt": "2020-05-21T00:45:05.324Z"
  },
  "instance": {
    "region": "us-east-1",
    "id": "i-02cb186c0808950f6",
    "imageId": "ami-01ee6543215d4006b"
  },
  "vendor": {
    "name": "aws",
    "subnet": "subnet-41daba24",
    "securityGroups": [
      "sg-50d39921",
      "sg-0a52e56ee0c02fd7a",
      "sg-784d5703",
      "sg-0769b9650222e64ce"
    ],
    "region": "us-east-1",
    "instanceType": "t3.large",
    "quickSync": true
  },
  "network": "mainnet",
  "state": "stopped",
  "service": "service-f409a426-8bdd-5c65-bcd3-7c6d0424a5ac",
  "auth": {
    "type": "basic",
    "user": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "pass": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  },
  "updatedAt": "2020-04-21T00:45:09.419Z",
  "chain": "btc",
  "id": "node-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
```

### Code sample

```shell
curl -X GET https://nodes.bloq.cloud/users/me/nodes/node-xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \
  -H 'Authorization: Bearer <AUTH_TOKEN>'
```

## DELETE /users/me/nodes/{id}

This resource removes a node by ID.

### Responses

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

### Code sample

```shell
curl -X DELETE https://nodes.bloq.cloud/users/me/nodes/node-xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \
  -H 'Authorization: Bearer <AUTH_TOKEN>'
```
