# Substrate API Sidecar

## About

The [Substrate API Sidecar](https://github.com/paritytech/substrate-api-sidecar) is an external application that provides a more convenient HTTP API on top of the low-level JSON-RPC API that node exposes.

Humanode network can be used with Substrate API Sidecar, although some of the Humanode specific APIs are not exposed.

If you are an app developer, and you need a quick way to do some common blockchain operations (e.g. balance transfer), consider using the Substrate API Sidecar.

## Usage

{% tabs %}
{% tab title="Node.js" %}

1. Install Node.js.
2. Install the Substrate API Sidecar.

   ```shell
   npm install -g @substrate/api-sidecar
   ```
3. Run the sidecar process and connect to Humanode network.

   ```shell
   SAS_SUBSTRATE_URL=<URL> substrate-api-sidecar
   ```

   Replace `<URL>` with the right JSON-RPC URL from the [chains](https://gitbook.humanode.io/docs/chains) page, or use your own.
   {% endtab %}

{% tab title="Docker" %}

1. Install Docker.
2. Run the Substrate API Sidecar image.

   ```shell
   docker run --rm -it \
     -p 8080:8080 \
     -e "SAS_SUBSTRATE_URL=<URL>" \
     parity/substrate-api-sidecar:latest
   ```

   Replace `<URL>` with the right JSON-RPC URL from the [chains](https://gitbook.humanode.io/docs/chains) page, or use your own.
   {% endtab %}
   {% endtabs %}

You can now send the simple HTTP requests and get simple JSON responses instead of dealing with the Substrate JSON-RPC protocol specifics.

```shell
$ curl -sS 'http://127.0.0.1:8080/accounts/hmpwhPbL5XJTYPWd3Gw9dUzdWrPwx2nbMFK7CmCQTrYNSfrW4/balance-info' | jq .
{
  "at": {
    "hash": "0x50c54161a09a127324de2e7a5c10d01458b896a4eef4905243c23c5c35f17827",
    "height": "796175"
  },
  "nonce": "0",
  "tokenSymbol": "HMND",
  "free": "353780945734999999999999000",
  "reserved": "0",
  "miscFrozen": "0",
  "feeFrozen": "0",
  "locks": []
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.humanode.io/docs/tools-and-services/substrate-api-sidecar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
