> For the complete documentation index, see [llms.txt](https://docs.aquanow.io/aquanow/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aquanow.io/aquanow/websockets/authenticated-websockets/reporting-websocket.md).

# Reporting Websocket

### Websocket Endpoints

#### Environments

There are two environments to access our authorized market data feeds:

1. **Live**

```
wss://report.aquanow.io:8081/
```

2. **Sandbox**

```
wss://report-staging.aquanow.io:8081/
```

### Websocket Access and Authorization

API Authentication is done using an API key and a secret. User needs to associate the following information in the payload of the subscription message. View the [Authorization page](/aquanow/integration-guide/authentication.md) for more detail.

#### Request Parameters

|      Name      |  Type  | Description                              |
| :------------: | :----: | ---------------------------------------- |
|    `apiKey`    | String | API key                                  |
| `apiSignature` | String | Signature created using API secret       |
|    `channel`   | String | Channel of subscription                  |
|     `type`     | String | Type of action; subscribe or unsubscribe |
|     `nonce`    | String | Numeric string timestamp in milliseconds |

#### There are three channels you can subscribe for:

1. `executionReport` - all order and balance updates
2. `parentOrderReport` - all order updates
3. `balanceReport` - all balance updates

### Example Usage

{% tabs %}
{% tab title="executionReport" %}

```javascript
const WebSocket = require("ws");
const crypto = require("crypto");

const ws = new WebSocket("");


const apiKey = "";
const secret = "";


function subscribeToOrders() {
  const timestamp = Date.now().toString();
  const payload = {
    type: "subscribe",
    channel: "executionReport",
    nonce: timestamp
  };
  const apiSignature = crypto
    .createHmac("sha384", secret)
    .update(JSON.stringify(payload))
    .digest("hex");


  const subsOption = JSON.stringify({
    ...payload,
    apiKey,
    apiSignature
  });


  ws.send(subsOption);
}


ws.on("open", () => {
  console.log(WS tunnel opened - trade);
  subscribeToOrders({ apiKey, secret });
});


ws.on("message", data => {
  console.log("data", data);
});
```

{% endtab %}

{% tab title="parentOrderReport" %}

```javascript
const WebSocket = require("ws");
const crypto = require("crypto");

const ws = new WebSocket("");


const apiKey = "";
const secret = "";


function subscribeToOrders() {
  const timestamp = Date.now().toString();
  const payload = {
    type: "subscribe",
    channel: "parentOrderReport",
    nonce: timestamp
  };
  const apiSignature = crypto
    .createHmac("sha384", secret)
    .update(JSON.stringify(payload))
    .digest("hex");


  const subsOption = JSON.stringify({
    ...payload,
    apiKey,
    apiSignature
  });


  ws.send(subsOption);
}


ws.on("open", () => {
  console.log(WS tunnel opened - trade);
  subscribeToOrders({ apiKey, secret });
});


ws.on("message", data => {
  console.log("data", data);
});java
```

{% endtab %}

{% tab title="balanceReport" %}

```javascript
const WebSocket = require("ws");
const crypto = require("crypto");

const ws = new WebSocket("");


const apiKey = "";
const secret = "";


function subscribeToOrders() {
  const timestamp = Date.now().toString();
  const payload = {
    type: "subscribe",
    channel: "balanceReport",
    nonce: timestamp
  };
  const apiSignature = crypto
    .createHmac("sha384", secret)
    .update(JSON.stringify(payload))
    .digest("hex");


  const subsOption = JSON.stringify({
    ...payload,
    apiKey,
    apiSignature
  });


  ws.send(subsOption);
}


ws.on("open", () => {
  console.log(WS tunnel opened - trade);
  subscribeToOrders({ apiKey, secret });
});


ws.on("message", data => {
  console.log("data", data);
});
```

{% endtab %}
{% endtabs %}

#### Example Response

{% tabs %}
{% tab title="executionReport" %}

#### Balance Update

Returns an [AuthenticateObject](/aquanow/data-objects-and-statuses/websocket-objects.md#authenticateobject).

```json
{
  "type": "balance",
  "payload": {
    "createdAt": 1554400262916,
    "accountId": "CA1000051R",
    "symbol": "BTC",
    "totalBalance": 2.30044886,
    "depositAddress": "-",
    "usernameSymbol": "helloWorld_BTC",
    "pendingTransfer": 0,
    "itemDateTime": 1557267645512,
    "availableBalance": 2.24044886,
    "updatedAt": 1554400262916,
    "username": "helloWorld"
  }
}
```

#### Order Update

Returns an [AuthenticateObject](/aquanow/data-objects-and-statuses/websocket-objects.md#authenticateobject).&#x20;

```json
{
  "type": "order",
  "payload": {
    "createdAt": 1557267645477,
    "accountId": "CA1000051R",
    "symbol": "BTC-USD",
    "totalBalance": 2.40047884,
    "depositAddress": "-",
    "usernameSymbol": "helloWorld_BTC",
    "pendingTransfer": 0,
    "itemDateTime": 1557267645646,
    "availableBalance": 2.24044886,
    "updatedAt": 1557267645477,
    "username": "helloWorld"
  }
}
```

{% endtab %}

{% tab title="parentOrderReport" %}

```json
{
  "type": "order",
  "payload": {
    "createdAt": 1557267645477,
    "accountId": "CA1000051R",
    "symbol": "BTC-USD",
    "totalBalance": 2.40047884,
    "depositAddress": "-",
    "usernameSymbol": "helloWorld_BTC",
    "pendingTransfer": 0,
    "itemDateTime": 1557267645646,
    "availableBalance": 2.24044886,
    "updatedAt": 1557267645477,
    "username": "helloWorld"
  }
}
```

{% endtab %}

{% tab title="balanceReport" %}

```json
{
  "type": "balance",
  "payload": {
    "createdAt": 1554400262916,
    "accountId": "CA1000051R",
    "symbol": "BTC",
    "totalBalance": 2.30044886,
    "depositAddress": "-",
    "usernameSymbol": "helloWorld_BTC",
    "pendingTransfer": 0,
    "itemDateTime": 1557267645512,
    "availableBalance": 2.24044886,
    "updatedAt": 1554400262916,
    "username": "helloWorld"
  }
}
```

{% endtab %}

{% tab title="tradeCreditBalance" %}

```json
{
  "type": "tradeCreditBalance",
  "payload": {
    "accountId": "CA1000051R",
    "adjustedMtmUSD": 49215.15490545314
    "createdAt": 1701366866377,
    "ltv": 167.79987870494583,
    "unutilizedCreditUSD": 950489.7899944618
    "updatedAt": 1712857675713,
    "username": "helloWorld"
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.aquanow.io/aquanow/websockets/authenticated-websockets/reporting-websocket.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
