# Introduction

Welcome to Niza Global API!

Niza Global API offers comprehensive functionalities for spot trading operations. Public APIs provide real-time market statistics retrieval, while private APIs require authentication for trading on behalf of the user.


# General

Request URL

```url
https://app.niza.io/trade/v1
```


# Authentication

## Headers

### X-API-Key

Include the "X-API-Key" header in your API requests, and ensure it contains your API key.

### X-API-Sign

Authenticated requests must be signed using the "X-API-Sign" header. The signature is generated with your private key, encoded payload, and the request method, following the HMAC-SHA512 algorithm:

#### Generating the signature

<pre><code>HMAC-SHA512 of (<a data-footnote-ref href="#user-content-fn-1">Request Method</a> + SHA256(<a data-footnote-ref href="#user-content-fn-2">Request Body</a>)) and base64-decoded <a data-footnote-ref href="#user-content-fn-3">API Key secret</a>
</code></pre>

#### **Signature Calculation Example:**&#x20;

For a <mark style="color:yellow;">POST</mark> request, you might calculate the signature as follows:

1. Request Method: POST
2. POST data: SHA256 hash of the JSON payload. Example of payload: "{"name":"John"}"
3. &#x20;Concatenate the Request Method and SHA256 hash. Example: "POST" + "{"name":"John"}"
4. HMAC-SHA512: Apply HMAC-SHA512 using the concatenated string and the base64-decoded API Key secret

#### Code examples

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

```javascript
const crypto = require('crypto');
function generateSignature(apiSecret, method, body) {
    const payload = JSON.stringify(body);
    const sha256Hash = crypto.createHash('sha256').update(payload).digest('hex');
    const data = method + sha256Hash;
    const signature = crypto.createHmac('sha512', Buffer.from(apiSecret, 'base64')).update(data).digest('base64');
    return signature;
}

// Example Usage:
const apiKey = "your_api_key_here";
const apiSecret = "your_api_secret_here";
const method = "POST";

//When body is empty use empty object {}
const body = {
    "order_direction": "buy",
    "order_type": "limit",
    "pair": "DEMONIZA/USDT",
    "volume": "1",
    "price": "0.85"
};

const signature = generateSignature(apiSecret, method, body);
console.log(`X-API-Sign: ${signature}`);
```

{% endtab %}

{% tab title="Python" %}

```python
import hashlib
import hmac
import base64
import json

def generate_signature(api_secret, method, body):
    # sort_keys=False is important, otherwise the signature will be invalid
    payload = json.dumps(body, separators=(',', ':'), sort_keys=False)
    sha256_hash = hashlib.sha256(payload.encode()).hexdigest()
    data = method + sha256_hash
    signature = hmac.new(base64.b64decode(api_secret), data.encode(), hashlib.sha512).digest()
    return base64.b64encode(signature).decode()

# Example Usage:
api_key = "your_api_key_here"
api_secret = "your_api_secret_here"
method = "POST"
body = {
    "order_direction": "buy",
    "order_type": "limit",
    "pair": "DEMONIZA",
    "volume": "1",
    "price": "0.85"
}

signature = generate_signature(api_secret, method, body)
print("Signature: ",signature)
url = 'https://app.niza.io/trade/v1/orders'
# body must be send as raw string
bodyRaw = payload = json.dumps(body)
headers = {
    'Accept': 'application/json', 
    'Content-Type': 'application/json',
    'X-API-Key': api_key,
    'X-API-Sign': signature
}
res = requests.post(url, headers=headers, data=payload)
```

{% endtab %}

{% tab title="PHP" %}

```php

function generateSignature($apiSecret, $method, $body) {
    $payload = json_encode($body, true);
    $sha256Hash = hash('sha256', $payload);
    $data = $method . $sha256Hash;
    $signature = base64_encode(hash_hmac('sha512', $data, base64_decode($apiSecret), true));
    return $signature;
}

// Example Usage:
$apiKey = "your_api_key_here";
$apiSecret = "your_api_secret_here";
$method = "POST";
//When body is empty use empty object {}
$body = (object) [
    "order_direction" => "buy",
    "order_type" => "limit",
    "pair" => "DEMONIZA",
    "volume" => "1,
    "price" => "0.85"
];

$signature = generateSignature($apiSecret, $method, $body);
echo "X-API-Sign: $signature\n";

```

{% endtab %}
{% endtabs %}

[^1]: The request method, one of the following GET, POST, DELETE, PUT

[^2]: The request body as parsed JSON String

[^3]: Your API Key Secret


# Markets

## Get Available Markets

<mark style="color:green;">**`GET`**</mark>`/markets`

Get a list of available trading pairs.

**Query Parameters**

<table><thead><tr><th>Name</th><th>Value</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>pair</td><td><code>String</code></td><td>false</td></tr></tbody></table>

**Response**

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

```json
{
    "success": true,
    "message": "Request processed successfully",
    "data": {
        "NIZA/EUR": {
            "altname": "DEMONIZA",
            "wsname": "DEMONIZA/EUR",
            "classBase": "currency",
            "base": "DEMONIZA",
            "classQuote": "currency",
            "quote": "USDT",
            "pairDecimals": 2,
            "lotDecimals": 2,
            "ordermin": "1"
        }
    },
    "code": 200
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "success": false,
    "error": {
        "message": "Invalid request!",
        "code": 400
    }
}
```

{% endtab %}
{% endtabs %}


# Tickers

## Get Tickers

<mark style="color:green;">`GET`</mark>`/tickers`

Get ticker information for all or requested market pairs:

* Today's prices start at midnight UTC
* Leaving the `ticker_id` parameter blank will return tickers for all assets

**Query Parameters**

<table><thead><tr><th>Name</th><th>Value</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>ticker_id</td><td>string: <code>NIZA/USDT</code></td><td>false</td></tr></tbody></table>

**Response**

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

```json
[
    {
        "ticker_id": "DEMONIZA/USDT",
        "base_currency": "DEMONIZA",
        "target_currency": "USDT",
        "last_price": "0.9",
        "base_volume": "2108353.039823",
        "target_volume": "0.000000",
        "bid": "0.00867410",
        "ask": "0.00869230",
        "high": "0.00898780",
        "low": "0.00782030"
    }
]
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# OHLC Data

### Get OHLC

<mark style="color:green;">`GET`</mark> `/ohlc`

Get OHLC (open/high/low/close, otherwise known as candle) data for a given market.

**Query Parameters**

<table><thead><tr><th>Name</th><th>Value</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>ticker_id</td><td>string: <code>DEMONIZA/USDT</code></td><td>true</td></tr><tr><td>since</td><td>timestamp: <code>1708619280</code></td><td>false</td></tr><tr><td>interval</td><td>enum (minutes): <code>1, 5, 15, 30 60, 240, 1440, 10080 21600</code> </td><td>false</td></tr><tr><td></td><td></td><td>false</td></tr></tbody></table>

**Response**

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

```json
[
        {
            "time": 1709325573.9077,
            "open": "0.01869900",
            "high": "0.01869900",
            "low": "0.01869900",
            "close": "0.01869900",
            "vwap": "0.03739800",
            "volume": "1117.31843576",
            "count": 2
        },
        {
            "time": 1709325656.1582,
            "open": "0.01869900",
            "high": "0.01869900",
            "low": "0.01869900",
            "close": "0.01869900",
            "vwap": "0.03739800",
            "volume": "695.37154928",
            "count": 2
        },
        ...
]
```

{% endtab %}

{% tab title="422" %}

```json
{
    "success": false,
    "error": {
        "message": "The given data was invalid!",
        "validations": [
            "Pair attribute must be set"
        ],
        "code": 422
    }
}
```

{% endtab %}
{% endtabs %}


# Order Book

## Get Order Book

<mark style="color:green;">`GET`</mark>`/orderbook`

Get current order book details.

**Query Parameters**

<table><thead><tr><th>Name</th><th>Value</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>ticker_id</td><td><code>DEMONIZA/USDT</code></td><td>true</td></tr><tr><td>depth</td><td><code>100</code></td><td>false</td></tr></tbody></table>

**Response**

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

```json
[
    {
        "ticker_id": "DEMONIZA/USDT",
        "timestamp": 1712613489,
        "bids": [
            [
                "0.00867410",
                "2.41520892"
            ],
            ...
        ],
        "asks": [
            [
                "0.00869230",
                "2912.00000000"
            ],
            ...
        ]
    }
]
```

{% endtab %}

{% tab title="422" %}

```json
{
    "success": false,
    "error": {
        "message": "The given data was invalid!",
        "validations": [
            "Pair attribute must be set"
        ],
        "code": 422
    }
}
```

{% endtab %}
{% endtabs %}


# Historical Trades

## Get historical trades

<mark style="color:green;">`GET`</mark> `/`historical\_trades

Returns trades for the given ticker

**Query Parameters**

<table><thead><tr><th>Name</th><th>Value</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>ticker_id</td><td>string: <code>DEMONIZA/USDT</code></td><td>true</td></tr><tr><td>type</td><td>string: <code>buy/sell</code></td><td>false</td></tr><tr><td>limit</td><td>integer: <code>10</code></td><td>false</td></tr><tr><td>start_time</td><td>timestamp: <code>1709150766</code></td><td>false</td></tr></tbody></table>

**Response**

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

```json
{
 "buy": [  
   {        
      "trade_id":1234567,
      "price":"0.009",
      "base_volume":"10000",
      "target_volume":"90",
      "trade_timestamp":"1700050000",
      "type":"buy"
   },
   ...
],
"sell": [
      {        
         "trade_id":1234567,
         "price":"0.009",
         "base_volume":"10000",
         "target_volume":"90",
         "trade_timestamp":"1700050000",
         "type":"sell"
      }
   ]
}


```

{% endtab %}

{% tab title="422" %}

```json
{
    "success": false,
    "error": {
        "message": "The given data was invalid!",
        "validations": [
            "Pair attribute must be set"
        ],
        "code": 422
    }
}
```

{% endtab %}
{% endtabs %}


# Balances


# (Deprecated) Trade Wallet

## Trade Wallet Balance

<mark style="color:green;">`GET`</mark> `/trade-wallet`

Get Trade wallet balance info

**Headers**

| Name       | Value                 |
| ---------- | --------------------- |
| X-API-Key  | API\_KEY              |
| X-API-Sign | `Generated Signature` |

**Response**

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

```json
{
    "success": true,
    "message": "Request processed successfully",
    "data": [
        {
            "asset_id": "NIZA",
            "asset_name": "Niza Global",
            "type": "crypto",
            "balance": {
                "balance_total": "290768.633106611",
                "balance_total_in_fiat": "5255.34645940"
            },
            "pending": {
                "has_pending": false,
                "balance_pending": "0.000000000",
                "balance_pending_in_fiat": "0.00000000"
            },
            "balance_currency": "USD"
        },
        {
            "asset_id": "USD",
            "asset_name": "Dollar",
            "type": "fiat",
            "balance": {
                "balance_total": "0.00",
                "balance_total_in_fiat": "0.00000000"
            },
            "pending": {
                "has_pending": false,
                "balance_pending": "0.00",
                "balance_pending_in_fiat": "0.00000000"
            },
            "balance_currency": "USD"
        },
        {
            "asset_id": "USDT",
            "asset_name": "Tether USDt",
            "type": "crypto",
            "balance": {
                "balance_total": "10.21718852",
                "balance_total_in_fiat": "10.22368951"
            },
            "pending": {
                "has_pending": false,
                "balance_pending": "0.00000000",
                "balance_pending_in_fiat": "0.00000000"
            },
            "balance_currency": "USD"
        }
    ],
    "code": 200
}
```

{% endtab %}

{% tab title="422" %}

```json
{
  "error": "Invalid Signature"
}
```

{% endtab %}
{% endtabs %}


# Spot Wallet

## Spot Wallet Balance

<mark style="color:green;">`GET`</mark> `/spot-wallet`

Get spot wallet balance info

**Headers**

| Name       | Value                 |
| ---------- | --------------------- |
| X-API-Key  | API\_KEY              |
| X-API-Sign | `Generated Signature` |

**Response**

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

```json
{
    "success": true,
    "message": "Request processed successfully",
    "data": [
        {
            "asset_id": "NIZA",
            "asset_name": "Niza Global",
            "type": "crypto",
            "balance": {
                "balance_total": "100000000.000000000",
                "balance_total_in_fiat": "0.00000000"
            },
            "pending": {
                "has_pending": false,
                "balance_pending": "0.000000000",
                "balance_pending_in_fiat": "0.00000000"
            },
            "balance_currency": "USD"
        },
        {
            "asset_id": "USD",
            "asset_name": "Dollar",
            "type": "fiat",
            "balance": {
                "balance_total": "0.00",
                "balance_total_in_fiat": "0.00000000"
            },
            "pending": {
                "has_pending": false,
                "balance_pending": "0.00",
                "balance_pending_in_fiat": "0.00000000"
            },
            "balance_currency": "USD"
        },
        {
            "asset_id": "USDT",
            "asset_name": "Tether USDt",
            "type": "crypto",
            "balance": {
                "balance_total": "0.00000000",
                "balance_total_in_fiat": "0.00000000"
            },
            "pending": {
                "has_pending": false,
                "balance_pending": "0.00000000",
                "balance_pending_in_fiat": "0.00000000"
            },
            "balance_currency": "USD"
        }
    ],
    "code": 200
}
```

{% endtab %}

{% tab title="422" %}

```json
{
  "error": "Invalid Signature"
}
```

{% endtab %}
{% endtabs %}


# Orders


# Create Order

## Create a new order

<mark style="color:orange;">`POST`</mark> `/orders`

Creates new order

**Headers**

| Name       | Value                 |
| ---------- | --------------------- |
| X-API-Key  | `API Key`             |
| X-API-Sign | `Generated Signature` |

**Body**

<table><thead><tr><th>Name</th><th>Type</th><th data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>order_direction</code></td><td>string</td><td>true</td><td>One of: <code>buy,sell</code></td></tr><tr><td><code>order_type</code></td><td>string</td><td>true</td><td>One of: <code>market,limit</code></td></tr><tr><td><code>pair</code></td><td>string</td><td>true</td><td>Market pair example <code>NIZA/USDT</code></td></tr><tr><td><code>volume</code></td><td>string</td><td>true</td><td>The order volume</td></tr><tr><td><code>price</code></td><td>string</td><td>true</td><td>Required if <code>order_type</code> is different from <code>market</code></td></tr></tbody></table>

**Response**

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

```json
{
    "success": true,
    "message": "Request processed successfully.",
    "code": 200
}
```

{% endtab %}

{% tab title="422" %}

```json
{
    "message": "The price field is required.",
    "errors": {
        "price": [
            "The price field is required."
        ]
    }
}
```

{% endtab %}
{% endtabs %}


# Cancel Order

## Cancel a open order

<mark style="color:red;">`DELETE`</mark> `/orders/:order_id`

Cancels an open order

**Headers**

| Name       | Value                 |
| ---------- | --------------------- |
| X-API-Key  | `API Key`             |
| X-API-Sign | `Generated Signature` |

Path Params

| Parameter | Value            |
| --------- | ---------------- |
| order\_id | Numeric Order ID |

No request body

**Response**

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

```json
{
    "success": true,
    "message": "Request processed successfully.",
    "code": 200
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# Open Orders

## Get open orders list

<mark style="color:green;">`GET`</mark> `/open-orders`

Get open orders with pagination

**Headers**

| Name       | Value                 |
| ---------- | --------------------- |
| X-API-Key  | `API Key`             |
| X-API-Sign | `Generated Signature` |

**Query Params**

<table><thead><tr><th>Name</th><th>Type</th><th data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>pair</code></td><td>string</td><td>false</td><td>Example NIZA/USDT</td></tr><tr><td><code>page-size</code></td><td>number</td><td>false</td><td> If not set, no pagination is applied</td></tr><tr><td><code>page</code></td><td>number</td><td>false</td><td>Page number if pagination is enabled</td></tr></tbody></table>

**Response**

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

```json
{
    "success": true,
    "message": "Request processed successfully",
    "data": [
        {
            "id": 420,
            "user_id": 16,
            "transaction_id": "O39OO7-NIBT3-7RTNX1",
            "status": "open",
            "open_time": "1711233663.0000",
            "close_time": null,
            "expire_time": "0.0000",
            "reason": null,
            "pair": "NIZAEUR",
            "type": "buy",
            "order_type": "limit",
            "description": {
                "pair": "NIZAEUR",
                "type": "buy",
                "close": "",
                "order": "buy 2092.00000000 NIZAEUR @ limit",
                "price": "0.01410000",
                "leverage": "none",
                "orderType": "limit",
                "secondaryPrice": null
            },
            "volume": {
                "amount": "2092.00000000",
                "currency": "NIZA"
            },
            "volume_executed": {
                "amount": "0.00000000",
                "currency": "NIZA"
            },
            "fee": null,
            "price": {
                "amount": "0.01410000",
                "currency": "EUR"
            },
            "secondary_price": null,
            "limit_price": null,
            "cost": null,
            "asset_pair": {
                "id": 679,
                "name": "NIZAEUR",
                "display_name": "NIZA/EUR",
                "base_name": "NIZA",
                "quote_name": "EUR"
            },
            "trigger_conditions": "--",
            "trades": []
        },
        {
            "id": 419,
            "user_id": 16,
            "transaction_id": "ORQPE8-UZJQK-INBBPM",
            "status": "open",
            "open_time": "1711233600.0000",
            "close_time": null,
            "expire_time": "0.0000",
            "reason": null,
            "pair": "NIZAEUR",
            "type": "buy",
            "order_type": "limit",
            "description": {
                "pair": "NIZAEUR",
                "type": "buy",
                "close": "",
                "order": "buy 1000.00000000 NIZAEUR @ limit",
                "price": "0.01450000",
                "leverage": "none",
                "orderType": "limit",
                "secondaryPrice": null
            },
            "volume": {
                "amount": "1000.00000000",
                "currency": "NIZA"
            },
            "volume_executed": {
                "amount": "0.00000000",
                "currency": "NIZA"
            },
            "fee": null,
            "price": {
                "amount": "0.01450000",
                "currency": "EUR"
            },
            "secondary_price": null,
            "limit_price": null,
            "cost": null,
            "asset_pair": {
                "id": 679,
                "name": "NIZAEUR",
                "display_name": "NIZA/EUR",
                "base_name": "NIZA",
                "quote_name": "EUR"
            },
            "trigger_conditions": "--",
            "trades": []
        }
    ],
    "code": 200,
    "meta": {
        "current_page": 1,
        "from": 1,
        "to": 2,
        "path": "https://app.niza.io/trade/v1/open-orders",
        "per_page": 2,
        "total": 9,
        "last_page": 5
    }
}
```

{% endtab %}

{% tab title="422" %}

```json
{
  "error": "Invalid Signature"
}
```

{% endtab %}
{% endtabs %}


# Closed Orders

## Get closed orders

<mark style="color:green;">`GET`</mark> `/closed-orders`

Get list of closed orders

**Headers**

| Name       | Value                 |
| ---------- | --------------------- |
| X-API-Key  | `API Key`             |
| X-API-Sign | `Generated Signature` |

**Query Params**

<table><thead><tr><th>Name</th><th>Type</th><th data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>pair</code></td><td>string</td><td>false</td><td>Example NIZA/USDT</td></tr><tr><td><code>page-size</code></td><td>number</td><td>false</td><td> If not set, no pagination is applied</td></tr><tr><td><code>page</code></td><td>number</td><td>false</td><td>Page number if pagination is enabled</td></tr></tbody></table>

**Response**

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

````json
{
    "success": true,
    "message": "Request processed successfully",
    "data": [
        {
            "id": 414,
            "user_id": 16,
            "transaction_id": "ODRCKJ-JCDEO-E6WWJ7",
            "status": "closed",
            "open_time": "1711222874.0000",
            "close_time": "1711226536.3496",
            "expire_time": "0.0000",
            "reason": null,
            "pair": "NIZAEUR",
            "type": "buy",
            "order_type": "limit",
            "description": {
                "pair": "NIZAEUR",
                "type": "buy",
                "close": "",
                "order": "buy 10000.00000000 NIZAEUR @ limit",
                "price": "0.01450000",
                "leverage": "none",
                "orderType": "limit",
                "secondaryPrice": null
            },
            "volume": {
                "amount": "10000.00000000",
                "currency": "NIZA"
            },
            "volume_executed": {
                "amount": "10000.00000000",
                "currency": "NIZA"
            },
            "fee": {
                "amount": "10.00000000",
                "currency": "NIZA"
            },
            "price": {
                "amount": "0.01450000",
                "currency": "EUR"
            },
            "secondary_price": null,
            "limit_price": null,
            "cost": {
                "amount": "145.00000000",
                "currency": "EUR"
            },
            "asset_pair": {
                "id": 679,
                "name": "NIZAEUR",
                "display_name": "NIZA/EUR",
                "base_name": "NIZA",
                "quote_name": "EUR"
            },
            "trigger_conditions": "--",
            "trades": [
                {
                    "id": 649,
                    "timestamp": "2024-03-23 20:41:34",
                    "type": "buy",
                    "volume": {
                        "amount": "9895.89972975",
                        "currency": "NIZA"
                    },
                    "price": {
                        "amount": "0.01450000",
                        "currency": "NIZA/EUR"
                    },
                    "cost": {
                        "amount": "143.49054608",
                        "currency": "EUR"
                    },
                    "transaction_id": "TZMV3L-FLZLZ-UPN23X"
                },
                {
                    "id": 651,
                    "timestamp": "2024-03-23 21:40:15",
                    "type": "buy",
                    "volume": {
                        "amount": "50.00000000",
                        "currency": "NIZA"
                    },
                    "price": {
                        "amount": "0.01450000",
                        "currency": "NIZA/EUR"
                    },
                    "cost": {
                        "amount": "0.72500000",
                        "currency": "EUR"
                    },
                    "transaction_id": "TMWHLR-WNUTL-NZIL3B"
                },
                {
                    "id": 653,
                    "timestamp": "2024-03-23 21:42:16",
                    "type": "buy",
                    "volume": {
                        "amount": "54.10027025",
                        "currency": "NIZA"
                    },
                    "price": {
                        "amount": "0.01450000",
                        "currency": "NIZA/EUR"
                    },
                    "cost": {
                        "amount": "0.78445392",
                        "currency": "EUR"
                    },
                    "transaction_id": "TTXR7L-IC8HD-BFND2K"
                }
            ]
        },
        {
            "id": 409,
            "user_id": 16,
            "transaction_id": "OTST3F-8ER6U-CQFXYC",
            "status": "closed",
            "open_time": "1711140640.0000",
            "close_time": "1711222894.3192",
            "expire_time": "0.0000",
            "reason": null,
            "pair": "NIZAEUR",
            "type": "buy",
            "order_type": "limit",
            "description": {
                "pair": "NIZAEUR",
                "type": "buy",
                "close": "",
                "order": "buy 202.73972603 NIZAEUR @ limit",
                "price": "0.01460000",
                "leverage": "none",
                "orderType": "limit",
                "secondaryPrice": null
            },
            "volume": {
                "amount": "202.73972603",
                "currency": "NIZA"
            },
            "volume_executed": {
                "amount": "202.73972603",
                "currency": "NIZA"
            },
            "fee": {
                "amount": "0.20273973",
                "currency": "NIZA"
            },
            "price": {
                "amount": "0.01460000",
                "currency": "EUR"
            },
            "secondary_price": null,
            "limit_price": null,
            "cost": {
                "amount": "2.96000000",
                "currency": "EUR"
            },
            "asset_pair": {
                "id": 679,
                "name": "NIZAEUR",
                "display_name": "NIZA/EUR",
                "base_name": "NIZA",
                "quote_name": "EUR"
            },
            "trigger_conditions": "--",
            "trades": [
                {
                    "id": 645,
                    "timestamp": "2024-03-23 20:37:50",
                    "type": "buy",
                    "volume": {
                        "amount": "98.63945578",
                        "currency": "NIZA"
                    },
                    "price": {
                        "amount": "0.01460000",
                        "currency": "NIZA/EUR"
                    },
                    "cost": {
                        "amount": "1.44013605",
                        "currency": "EUR"
                    },
                    "transaction_id": "T22LYE-CUNXC-UFIBKE"
                },
                {
                    "id": 647,
                    "timestamp": "2024-03-23 20:41:34",
                    "type": "buy",
                    "volume": {
                        "amount": "104.10027025",
                        "currency": "NIZA"
                    },
                    "price": {
                        "amount": "0.01460000",
                        "currency": "NIZA/EUR"
                    },
                    "cost": {
                        "amount": "1.51986395",
                        "currency": "EUR"
                    },
                    "transaction_id": "T8YZRI-NV6MO-VG3JKZ"
                }
            ]
        }
    ],
    "code": 200,
    "meta": {
        "current_page": 1,
        "from": 1,
        "to": 2,
        "path": "https://app.niza.io/trade/v1/closed-orders",
        "per_page": 2,
        "total": 72,
        "last_page": 36
    }
}
```
````

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# Get Order

## Get order

<mark style="color:green;">`GET`</mark> `/orders/:order_id`

Get an order details

**Headers**

| Name       | Value                 |
| ---------- | --------------------- |
| X-API-Key  | `API Key`             |
| X-API-Sign | `Generated Signature` |

**Path Params**

<table><thead><tr><th>Name</th><th>Type</th><th data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>order_id</code></td><td>number</td><td>true</td><td>The order id to get</td></tr></tbody></table>

**Response**

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

```json
{
    "success": true,
    "message": "Request processed successfully",
    "data": {
        "id": 422,
        "user_id": 16,
        "transaction_id": "OPOXV7-5N2VX-E4A58A",
        "status": "canceled",
        "open_time": "1711558585.0000",
        "close_time": "1711584893.6048",
        "expire_time": "0.0000",
        "reason": "User requests",
        "pair": "NIZAEUR",
        "type": "buy",
        "order_type": "limit",
        "description": {
            "pair": "NIZAEUR",
            "type": "buy",
            "close": "",
            "order": "buy 1600.00000000 NIZAEUR @ limit",
            "price": "0.00812000",
            "leverage": "none",
            "orderType": "limit",
            "secondaryPrice": null
        },
        "volume": {
            "amount": "1600.00000000",
            "currency": "NIZA"
        },
        "volume_executed": {
            "amount": "0.00000000",
            "currency": "NIZA"
        },
        "fee": null,
        "price": {
            "amount": "0.00812000",
            "currency": "EUR"
        },
        "secondary_price": null,
        "limit_price": null,
        "cost": null,
        "asset_pair": {
            "id": 679,
            "name": "NIZAEUR",
            "display_name": "NIZA/EUR",
            "base_name": "NIZA",
            "quote_name": "EUR"
        },
        "trigger_conditions": "--",
        "trades": []
    },
    "code": 200
}
```

{% endtab %}

{% tab title="404" %}

```json
{
    "success": false,
    "message": "No query results for model 4224",
    "error": {
        "message": "No query results for model 4224",
        "code": 404
    }
}
```

{% endtab %}
{% endtabs %}


# Trades


# Trades History

## Get user trades history

<mark style="color:green;">`GET`</mark> `/trades`

Get a list of user trades with pagination

**Headers**

| Name       | Value                 |
| ---------- | --------------------- |
| X-API-Key  | `API Key`             |
| X-API-Sign | `Generated Signature` |

**Query Params**

<table><thead><tr><th>Name</th><th>Type</th><th data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>pairs[]</code></td><td>array</td><td>false</td><td>Multiple pairs to filter</td></tr><tr><td><code>page-size</code></td><td>number</td><td>false</td><td>Items per page, if not set no pagination is applied</td></tr><tr><td><code>page</code></td><td>number</td><td>false</td><td>The page number to get</td></tr></tbody></table>

**Response**

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

```json
{
    "success": true,
    "message": "Request processed successfully",
    "data": [
        {
            "id": 653,
            "timestamp": "2024-03-23 21:42:16",
            "type": "buy",
            "order_id": 414,
            "order_type": "limit",
            "pair_id": 679,
            "pair": "NIZA/EUR",
            "volume": {
                "amount": "54.10027025",
                "currency": "NIZA"
            },
            "price": {
                "amount": "0.01450000",
                "currency": "NIZA/EUR"
            },
            "cost": {
                "amount": "0.78445392",
                "currency": "EUR"
            },
            "fee": {
                "amount": "0.78445392",
                "currency": "NIZA"
            },
            "transaction_id": "TTXR7L-IC8HD-BFND2K",
            "leverage": null
        },
        {
            "id": 651,
            "timestamp": "2024-03-23 21:40:15",
            "type": "buy",
            "order_id": 414,
            "order_type": "limit",
            "pair_id": 679,
            "pair": "NIZA/EUR",
            "volume": {
                "amount": "50.00000000",
                "currency": "NIZA"
            },
            "price": {
                "amount": "0.01450000",
                "currency": "NIZA/EUR"
            },
            "cost": {
                "amount": "0.72500000",
                "currency": "EUR"
            },
            "fee": {
                "amount": "0.72500000",
                "currency": "NIZA"
            },
            "transaction_id": "TMWHLR-WNUTL-NZIL3B",
            "leverage": null
        }
    ],
    "code": 200,
    "meta": {
        "current_page": 2,
        "from": 3,
        "to": 4,
        "path": "https://app.niza.io/trade/v1/trades",
        "per_page": 2,
        "total": 253,
        "last_page": 127
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# Get Trade

## Get a trade

<mark style="color:green;">`GET`</mark> `/trades/:trade_id`

Get a trade details

**Headers**

| Name       | Value                 |
| ---------- | --------------------- |
| X-API-Key  | `API Key`             |
| X-API-Sign | `Generated Signature` |

**Path Params**&#x20;

<table><thead><tr><th>Name</th><th>Type</th><th data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>trade_id</code></td><td>number</td><td>true</td><td>The ID of the trade to return</td></tr></tbody></table>

**Response**

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

```json
{
    "success": true,
    "message": "Request processed successfully",
    "data": {
        "id": 653,
        "timestamp": "2024-03-23 21:42:16",
        "type": "buy",
        "order_id": 414,
        "order_type": "limit",
        "pair_id": 679,
        "pair": "NIZA/EUR",
        "volume": {
            "amount": "54.10027025",
            "currency": "NIZA"
        },
        "price": {
            "amount": "0.01450000",
            "currency": "NIZA/EUR"
        },
        "cost": {
            "amount": "0.78445392",
            "currency": "EUR"
        },
        "fee": {
            "amount": "0.78445392",
            "currency": "NIZA"
        },
        "transaction_id": "TTXR7L-IC8HD-BFND2K",
        "leverage": null
    },
    "code": 200
}
```

{% endtab %}

{% tab title="404" %}

```json
{
    "success": false,
    "message": "No query results for model 6534",
    "error": {
        "message": "No query results for model 6534",
        "code": 404
    }
}
```

{% endtab %}
{% endtabs %}


# Overview

Real-time market data updates through WebSocket's

WebSocket API offers real-time market data updates. WebSocket's is a bidirectional protocol offering fastest real-time data. The **public** message types presented in the Niza documentation do not require authentication. Private-data messages can be subscribed on a separate authenticated endpoint.


# Connection Details

Guide how to open a connection to Niza WebSocket.

We use [Pusher ](https://pusher.com/)as a Socket client, please look at this [documentation ](https://pusher.com/docs/channels/using_channels/client-api-overview/)how to setup pusher and connect using different languages. \
The public APP\_KEY is `23d6f445cd259b91adf9` .\
The connection string will look like this:

```javascript
wss://ws-eu.pusher.com/app/23d6f445cd259b91adf9?protocol=7&client=js&version=8.4.0-rc2&flash=false
```

Once the connection is successful you are ready to subscribe and receive public messages. For the private messages please look at the [WebSocket Authentication](/websocket-api-1.0/websocket-authentication) documentation how to authenticate your user to receive private messages.


# WebSocket Authentication

Guide how to authenticate your API user to the Niza WebSocket.

\
To listen to private channels an authorization token is required. This is accomplished by making an HTTP request to the [Channel Authorization Endpoint](#channel-authorization-endpoint). The authorization token received should be set in the payload of the subscribe message.

### Pusher Channel Authorization

If  you are using Pusher client the authorization endpoint should be set when initializing Pusher instance, read more about setting the authorization endpoint [here](https://pusher.com/docs/channels/server_api/authorizing-users/#client-side-setting-the-authorization-endpoint).

Example of initialization of the Pusher with `channelAuthorization`

```javascript
var pusher = new Pusher("APP_KEY", {
      cluster: "eu",
      forceTLS: true,
      disableStats: true,
      enabledTransports: ["wss", "ws"],
      activityTimeout: 10000,
      channelAuthorization: {
        endpoint: `https://app.niza.io/trade/v1/broadcasting/auth`,
        transport: "ajax",
        headers: {
          "X-API-Key": "[API_KEY]",
          "X-API-Sign": "[GENERATED_SIGNATURE]",
          "Access-Control-Allow-Origin": "*",
        },
      },
    });

```

## Channel Authorization Endpoint

<mark style="color:green;">`POST`</mark> `/broadcasting/auth`

Authorize channel subscription. Request should be made to the general [Request URL](/general).

**Headers**

| Name         | Value                                                                 |
| ------------ | --------------------------------------------------------------------- |
| Content-Type | `application/json`                                                    |
| X-API-Key    | API Key                                                               |
| X-API-Sign   | The generated signature, check api [authentication](/authentication). |

**Body**

| Name           | Type   | Description                                     |
| -------------- | ------ | ----------------------------------------------- |
| `socket_id`    | number | The id of the currently connected WebSocket.    |
| `channel_name` | string | The private channel name you want to subscribe. |

**Response**

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

```json
{
    "auth": "23d6f445cd259b91adf9:c35ecc2c7a8280911ff4b4818be21ee80ae9b3843f8db60d422a3f5824474ac4"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}

{% tab title="403" %}

```json
{
    "error": "Access Denied"
}
```

{% endtab %}
{% endtabs %}


# Public Channels


# Ticker Information

Ticker information on currency pair.

{% hint style="info" %}
When subscribing, the `pair should` be set in **alphanumeric format only**. Do not use separators between the base and quote asset. The correct format for NIZA/USDT to be set in a channel name is `NIZAUSDT`.
{% endhint %}

### Subscribe with Pusher

```javascript
var channel = pusher.subscribe("ticker-information.{pair}");
```

### Subscribe Request Payload

```json
{
   "event": "pusher:subscribe",
   "data": {
       "channel": "ticker-information.{pair}"
   }
}
```

### Examples

<details>

<summary>Pusher</summary>

```javascript
var channel = pusher.subscribe("ticker-information.NIZAUSDT");
```

</details>

<details>

<summary>WebSocket API in Javascript</summary>

```javascript
const message = {
        event: "pusher:subscribe",
        data: {
            channel: "ticker-information.NIZAUSDT"
        }
    };
socket.send(JSON.stringify(message));
```

</details>

### Payload

| Name             | Type    | Description                           |
| ---------------- | ------- | ------------------------------------- |
| channel          | string  | Channel name of subscription          |
| type             | string  | Type of event notification            |
| data             | array   | The payload of the ticker information |
| data.ask         | decimal | Best ask price                        |
| data.ask\_qty    | decimal | Best ask quantity                     |
| data.bid         | decimal | Best bid price                        |
| data.bid\_qty    | decimal | Best bid quantity                     |
| data.change      | decimal | 24-hour price change (quote currency) |
| data.change\_ptc | decimal | 24-hour price change in percentage    |
| data.high        | decimal | 24-hour highest trade price           |
| data.last        | decimal | Last trade price                      |
| data.low         | decimal | 24-hour lowest trade price            |
| data.symbol      | string  | The symbol of the currency pair       |
| data.volume      | decimal | 24-hour trade volume in base currency |
| data.vwap        | decimal | 24-hour volume weighted average price |

### **Example of the ticker event payload received as JSON**

```json
{
   "channel": "ticker",
   "type": "update",
   "data": [
       {
           "ask": "0.01000000",
           "ask_qty": "2.00000000",
           "bid": "0.01000000",
           "bid_qty": "428.00000000",
           "change": "0.00000000",
           "change_pct": "0.00000000",
           "high": "0.00000000",
           "last": "0.00000000",
           "low": "0.00000000",
           "symbol": "NIZA\/USDT",
           "volume": "0.00000000",
           "vwap": "0.00000000"
       }
   ]
}
```


# OHLC

Open High Low Close (Candle) feed for a currency pair and interval period.

{% hint style="info" %}
When subscribing, the `pair should` be set in **alphanumeric format only**. Do not use separators between the base and quote asset. The correct format for NIZA/USDT to be set in a channel name is `NIZAUSDT`.
{% endhint %}

The accepted values for interval are 1, 5, 15, 30, 60, 240, 1440, 10080, 21600.&#x20;

### Subscribe with Pusher

```javascript
var channel = pusher.subscribe("ohlc.{pair}.{interval}");
```

### Subscribe Request Payload

```javascript
{
   "event": "pusher:subscribe",
   "data": {
       "channel": "ohlc.{pair}.{interval}"
   }
}
```

### Examples

Subscribing to NIZAUSDT ohlc with 1 hour interval.

<details>

<summary>Pusher</summary>

```javascript
var channel = pusher.subscribe("ohlc.NIZAUSDT.60");
```

</details>

<details>

<summary>WebSocket API in Javascript</summary>

```javascript
const message = {
        event: "pusher:subscribe",
        data: {
            channel: "ohlc.NIZAUSDT.60"
        }
    };
socket.send(JSON.stringify(message));
```

</details>

### Payload

| Name                 | Type    | Description                                                       |
| -------------------- | ------- | ----------------------------------------------------------------- |
| channel              | string  | The name of the channel                                           |
| type                 | string  | Type of event notification                                        |
| timestamp            | string  | The timestamp of the start of the interval                        |
| data                 | array   | The payload of OHLC data                                          |
| data.symbol          | string  | The symbol of the of the currency pair                            |
| data.open            | decimal | The opening trade price within the interval.                      |
| data.high            | decimal | The highest trade price within the interval.                      |
| data.low             | decimal | The lowest trade price within the interval.                       |
| data.close           | decimal | The last trade price within the interval.                         |
| data.trades          | integer | Number of trades within the interval.                             |
| data.volume          | decimal | Total traded volume (in base currency terms) within the interval. |
| data.vwap            | decimal | Volume weighted average trade price within the interval.          |
| data.interval\_begin | string  | The timestamp of start of the interval. Format: RFC3339           |
| data.interval        | integer | The timeframe from the interval in minutes.                       |

### Example of the Payload

```json
{
   "channel": "ohlc",
   "type": "update",
   "timestamp": "2024-09-18 18:09:32.533726",
   "data": {
       "symbol": "NIZA\/USDT",
       "open": "100.00000000",
       "high": "100.00000000",
       "low": "100.00000000",
       "close": "100.00000000",
       "trades": 1,
       "volume": "100.00000000",
       "vwap": "100.00000000",
       "interval_begin": "2024-09-18T16:09:00.000000Z",
       "interval": 1,
       "timestamp": "2024-09-18T16:10:00.000000Z"
   }
}
```


# Recent Trades

Trade feed for a currency pair.

The trade channel generates a trade event when orders are matched in the book. Multiple trades may be batched in a single message but that does not mean that these trades resulted from a single taker order.

{% hint style="info" %}
When subscribing, the `pair should` be set in **alphanumeric format only**. Do not use separators between the base and quote asset. The correct format for NIZA/USDT to be set in a channel name is `NIZAUSDT`.
{% endhint %}

### Subscribe with Pusher

```javascript
var channel = pusher.subscribe("trade.{pair}");
```

### Subscribe Request Payload

```javascript
{
   "event": "pusher:subscribe",
   "data": {
       "channel": "trade.{pair}"
   }
}
```

### Examples

<details>

<summary>Pusher</summary>

```javascript
var channel = pusher.subscribe("trade.NIZAUSDT");
```

</details>

<details>

<summary>WebSocket API in Javascript</summary>

```javascript
const message = {
        event: "pusher:subscribe",
        data: {
            channel: "trade.NIZAUSDT"
        }
    };
socket.send(JSON.stringify(message));
```

</details>

### Payload

| Name           | Type    | Description                                                          |
| -------------- | ------- | -------------------------------------------------------------------- |
| channel        | string  | The name of the channel                                              |
| type           | string  | Type of event notification                                           |
| data           | array   | The payload of trade data                                            |
| data.ord\_type | string  | Possible values: \[limit, market] The order type of the taker order. |
| data.price     | decimal | Average price of the trade.                                          |
| data.qty       | decimal | Size of the trade.                                                   |
| data.side      | string  | The side of the taker order.                                         |
| data.symbol    | string  | Example: "NIZA/USD" The symbol of the currency pair.                 |
| data.timestamp | string  | Format: RFC3339. The book order update timestamp.                    |
| data.trade\_id | integer | Trade identifier is a sequence number, unique per book               |

### Example of the Payload

```json
{
   "channel": "trade",
   "type": "update",
   "data": [
       {
           "ord_type": "limit",
           "price": "100.00000000",
           "qty": "100.00000000",
           "side": "sell",
           "symbol": "NIZA\/USDT",
           "timestamp": "2024-09-18 23:31:27.572200",
           "trade_id": 78236
       }
   ]
}
```


# Orderbook

Order book feed for a currency pair.

The order-book channel generates a book event when a order is added, updated, deleted from the orderbook.

{% hint style="info" %}
When subscribing, the `pair` should be set in **alphanumeric format only**. Do not use separators between the base and quote asset. The correct format for NIZA/USDT to be set in a channel name is `NIZAUSDT`.
{% endhint %}

### Subscribe with Pusher

```javascript
var channel = pusher.subscribe("order-book.{pair}");
```

### Subscribe Request Payload

```javascript
{
   "event": "pusher:subscribe",
   "data": {
       "channel": "order-book.{pair}"
   }
}
```

### Examples

<details>

<summary>Pusher</summary>

```javascript
var channel = pusher.subscribe("order-book.NIZAUSDT");
```

</details>

<details>

<summary>WebSocket API in Javascript</summary>

```javascript
const message = {
        event: "pusher:subscribe",
        data: {
            channel: "order-book.NIZAUSDT"
        }
    };
socket.send(JSON.stringify(message));
```

</details>

### Payload

| Name            | Type    | Description                                            |
| --------------- | ------- | ------------------------------------------------------ |
| channel         | string  | The name of the channel                                |
| type            | string  | Type of the event                                      |
| data            | array   | The payload of trade data                              |
| data.asks       | string  | Sell order data. Empty array if order side is Buy      |
| data.asks.price | decimal | Order price                                            |
| data.asks.qty   | decimal | Order volume                                           |
| data.bids       | object  | Buy order data. Empty array if the order side is sell. |
| data.bids.price | decimal | Order price                                            |
| data.bids.qty   | decimal | Order Volume                                           |
| data.symbol     | string  | Example: "NIZA/USDT" The symbol of the currency pair.  |

### Example of the Payload

```json
{
    "channel":"book",
    "type":"update",
    "data":{
        "asks":[],
        "bids":{
            "price":"0.00013180",
            "qty":"854921.09000000"
        },
        "symbol":"NIZA/USDT"
    }
}
```


# Private Channels


# Order Executed

Order status update feed

The executions channel streams order status and execution events for this account.&#x20;

{% hint style="info" %}
This channel contains account specific data, an authentication token is required in the request. Follow this [documentation ](/websocket-api-1.0/websocket-authentication)how to get an authentication token.
{% endhint %}

### Subscribe with Pusher

```javascript
var channel = pusher.subscribe("private-order-executed.{userId}");
```

### Subscribe Request Payload

```javascript
{
   "event": "pusher:subscribe",
   "data": {
       "auth": "cd02139a35ead0a82ef6:672560a4d0f83cf5053cf509157ee24009c674188b58b71dd2f98647d9cab1df",
       "channel": "private-order-executed.{userId}"
   }
}
```

### Examples

<details>

<summary>Pusher</summary>

```javascript
var channel = pusher.subscribe("private-order-executed.{userId}");
```

</details>

<details>

<summary>WebSocket API in Javascript</summary>

```javascript
const message = {
        event: "pusher:subscribe",
        "data": {
            "auth": "cd02139a35ead0a82ef6:672560a4d0f83cf5053cf509157ee24009c674188b58b71dd2f98647d9cab1df",
            "channel": "private-order-executed.1"
         }
    };
socket.send(JSON.stringify(message));
```

</details>

### Payload

| Name                                       | Type           | Description                                                                |
| ------------------------------------------ | -------------- | -------------------------------------------------------------------------- |
| id                                         | integer        | Unique identifier for the order.                                           |
| user\_id                                   | integer        | ID of the user who placed the order.                                       |
| transaction\_id                            | string         | Unique transaction identifier for the order.                               |
| status                                     | string         | Current status of the order (e.g., "closed").                              |
| open\_time                                 | float          | Timestamp when the order was opened (in Unix time).                        |
| close\_time                                | float          | Timestamp when the order was closed (in Unix time).                        |
| expire\_time                               | float          | Expiry time of the order (set to 0 if not applicable).                     |
| reason                                     | string or null | Reason for the order closure, if applicable (null in this case).           |
| pair                                       | string         | Asset pair involved in the trade (e.g., "NIZAUSDT").                       |
| type                                       | string         | Type of order (e.g., "buy").                                               |
| order\_type                                | string         | The type of order (e.g., "limit").                                         |
| description                                | object         | Detailed description of the order.                                         |
| description.pair                           | string         | Asset pair being traded (e.g., "NIZAUSDT").                                |
| description.type                           | string         | Type of order (e.g., "buy").                                               |
| description.close                          | string         | Closing details, empty in this case.                                       |
| description.order                          | string         | Full description of the order (e.g., "buy 100.00000000 NIZAUSDT @ limit"). |
| description.price                          | string         | Price at which the order was executed.                                     |
| description.leverage                       | string         | Leverage used in the trade (e.g., "none").                                 |
| description.orderType                      | string         | Type of order (e.g., "limit").                                             |
| description.secondaryPrice                 | string or null | Secondary price, if applicable (null in this case).                        |
| volume.amount                              | string         | Volume of the asset being traded (e.g., "100.00000000").                   |
| volume.currency                            | string         | The asset being traded (e.g., "NIZA").                                     |
| volume\_executed.amount                    | string         | Amount of the asset that was executed (e.g., "100.00000000").              |
| volume\_executed.currency                  | string         | Currency of the executed volume (e.g., "NIZA").                            |
| fee.amount                                 | string         | Fee charged for the trade (e.g., "1.00000000").                            |
| fee.currency                               | string         | Currency in which the fee is paid (e.g., "NIZA").                          |
| price.amount                               | string         | Price at which the asset was traded (e.g., "100.00000000").                |
| price.currency                             | string         | Currency of the price (e.g., "USDT").                                      |
| secondary\_price                           | string or null | Secondary price, if applicable (null in this case).                        |
| limit\_price                               | string or null | Limit price, if applicable (null in this case).                            |
| cost.amount                                | string         | Total cost of the order (e.g., "10000.00000000").                          |
| cost.currency                              | string         | Currency in which the cost is calculated (e.g., "USDT").                   |
| [asset\_pair.id](http://asset_pair.id)     | integer        | Unique identifier of the asset pair.                                       |
| [asset\_pair.name](http://asset_pair.name) | string         | Name of the asset pair (e.g., "NIZAUSDT").                                 |
| asset\_pair.display\_name                  | string         | Display name of the asset pair (e.g., "NIZA/USDT").                        |
| asset\_pair.base\_name                     | string         | The base asset of the pair (e.g., "NIZA").                                 |
| asset\_pair.quote\_name                    | string         | The quote asset of the pair (e.g., "USDT").                                |
| trigger\_conditions                        | string         | Conditions that trigger the trade (e.g., "--").                            |
| trades                                     | array          | List of trades related to this order.                                      |
| trades\[0].id                              | integer        | Unique identifier for the trade.                                           |
| trades\[0].timestamp                       | string         | Timestamp of the trade (e.g., "2024-09-18 23:31:27").                      |
| trades\[0].type                            | string         | Type of trade (e.g., "buy").                                               |
| trades\[0].volume.amount                   | string         | Volume traded (e.g., "100.00000000").                                      |
| trades\[0].volume.currency                 | string         | Currency of the volume (e.g., "NIZA").                                     |
| trades\[0].price.amount                    | string         | Price at which the trade occurred (e.g., "100.00000000").                  |
| trades\[0].price.currency                  | string         | Currency pair of the trade (e.g., "NIZA/USDT").                            |
| trades\[0].cost.amount                     | string         | Total cost of the trade (e.g., "10000.00000000").                          |
| trades\[0].cost.currency                   | string         | Currency of the cost (e.g., "USDT").                                       |
| trades\[0].fee.amount                      | string         | Fee charged for the trade (e.g., "1.00000000").                            |
| trades\[0].fee.currency                    | string         | Currency of the fee (e.g., "NIZA").                                        |
| trades\[0].transaction\_id                 | string         | Unique transaction ID of the trade (e.g., "TJ6TZ7-RMUVA-BFLC44").          |
| socket                                     | string or null | Socket connection details, if applicable (null in this case).              |

### Example of the Payload

```json
{
   "id": 196857,
   "user_id": 4,
   "transaction_id": "OXUSHG-ND5YU-NJ6ILZ",
   "status": "closed",
   "open_time": "1726695085.0000",
   "close_time": "1726695087.6582",
   "expire_time": "0.0000",
   "reason": null,
   "pair": "NIZAUSDT",
   "type": "sell",
   "order_type": "limit",
   "description": {
       "pair": "NIZAUSDT",
       "type": "sell",
       "close": "",
       "order": "sell 100.00000000 NIZAUSDT @ limit",
       "price": "100.00000000",
       "leverage": "none",
       "orderType": "limit",
       "secondaryPrice": null
   },
   "volume": {
       "amount": "100.00000000",
       "currency": "NIZA"
   },
   "volume_executed": {
       "amount": "100.00000000",
       "currency": "NIZA"
   },
   "fee": {
       "amount": "100.00000000",
       "currency": "USDT"
   },
   "price": {
       "amount": "100.00000000",
       "currency": "USDT"
   },
   "secondary_price": null,
   "limit_price": null,
   "cost": {
       "amount": "10000.00000000",
       "currency": "USDT"
   },
   "asset_pair": {
       "id": 685,
       "name": "NIZAUSDT",
       "display_name": "NIZA\/USDT",
       "base_name": "NIZA",
       "quote_name": "USDT"
   },
   "trigger_conditions": "--",
   "trades": [
       {
           "id": 156391,
           "timestamp": "2024-09-18 23:31:27",
           "type": "sell",
           "volume": {
               "amount": "100.00000000",
               "currency": "NIZA"
           },
           "price": {
               "amount": "100.00000000",
               "currency": "NIZA\/USDT"
           },
           "cost": {
               "amount": "10000.00000000",
               "currency": "USDT"
           },
           "fee": {
               "amount": "100.00000000",
               "currency": "NIZA"
           },
           "transaction_id": "TGZA3R-ZVETW-RUIYAO"
       }
   ]
}
```


# Trade Executed

Own trades executed feed

The executions channel streams trades execution events for this account.

{% hint style="info" %}
This channel contains account specific data, an authentication token is required in the request. Follow this [documentation ](/websocket-api-1.0/websocket-authentication)how to get an authentication token.
{% endhint %}

### Subscribe with Pusher

```javascript
var channel = pusher.subscribe("private-trade-executed.{userId}");
```

### Subscribe Request Payload

```javascript
{
   "event": "pusher:subscribe",
   "data": {
       "auth": "cd02139a35ead0a82ef6:672560a4d0f83cf5053cf509157ee24009c674188b58b71dd2f98647d9cab1df",
       "channel": "private-trade-executed.{userId}"
   }
}
```

### Examples

<details>

<summary>Pusher</summary>

```javascript
var channel = pusher.subscribe("private-trade-executed.{userId}");
```

</details>

<details>

<summary>WebSocket API in Javascript</summary>

```javascript
const message = {
        event: "pusher:subscribe",
        "data": {
            "auth": "cd02139a35ead0a82ef6:672560a4d0f83cf5053cf509157ee24009c674188b58b71dd2f98647d9cab1df",
            "channel": "private-trade-executed.1"
         }
    };
socket.send(JSON.stringify(message));
```

</details>

### Payload

| Name            | Type           | Description                                                    |
| --------------- | -------------- | -------------------------------------------------------------- |
| id              | integer        | Unique identifier for the trade.                               |
| timestamp       | string         | Timestamp of the trade (e.g., "2024-09-18 23:31:27").          |
| type            | string         | Type of trade (e.g., "sell").                                  |
| order\_id       | integer        | Unique identifier for the related order (e.g., 196857).        |
| order\_type     | string         | The type of order (e.g., "limit").                             |
| pair\_id        | integer        | Unique identifier of the asset pair (e.g., 685).               |
| pair            | string         | The asset pair being traded (e.g., "NIZA/USDT").               |
| volume.amount   | string         | Volume of the asset being traded (e.g., "100.00000000").       |
| volume.currency | string         | The asset being traded (e.g., "NIZA").                         |
| price.amount    | string         | Price at which the asset was traded (e.g., "100.00000000").    |
| price.currency  | string         | Currency pair of the price (e.g., "NIZA/USDT").                |
| cost.amount     | string         | Total cost of the trade (e.g., "10000.00000000").              |
| cost.currency   | string         | Currency in which the cost is calculated (e.g., "USDT").       |
| fee.amount      | string         | Fee charged for the trade (e.g., "100.00000000").              |
| fee.currency    | string         | Currency of the fee (e.g., "USDT").                            |
| transaction\_id | string         | Unique transaction identifier for the trade.                   |
| leverage        | string or null | Leverage used in the trade, if applicable (null in this case). |

### Example of the Payload

```json
{
   "id": 156391,
   "timestamp": "2024-09-18 23:31:27",
   "type": "sell",
   "order_id": 196857,
   "order_type": "limit",
   "pair_id": 685,
   "pair": "NIZA\/USDT",
   "volume": {
       "amount": "100.00000000",
       "currency": "NIZA"
   },
   "price": {
       "amount": "100.00000000",
       "currency": "NIZA\/USDT"
   },
   "cost": {
       "amount": "10000.00000000",
       "currency": "USDT"
   },
   "fee": {
       "amount": "100.00000000",
       "currency": "USDT"
   },
   "transaction_id": "TGZA3R-ZVETW-RUIYAO",
   "leverage": null
}
```


