# Websocket Documentation

Websocket url: wss\://quoter.coinquoter.com:9001

## Websocket Streams

Our platform provides two methods for obtaining price feeds.

1. **General** - the best pricing feeds for token pairs in general.
2. **Specific for a maker** - the best token pairs pricing feeds for a specific maker.

### General Pricing Data

General pricing data allow us to connect to two different streams.&#x20;

1. **General stream**
2. **Request stream**

#### General stream&#x20;

The best price stream contains two sides of a token pair.

**Parameters**

<table><thead><tr><th width="203.40941512125534">Name</th><th width="151">Type</th><th width="150">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>action</td><td>String</td><td>Yes</td><td>Always "sub-quoter-pricing"</td></tr><tr><td>channel</td><td>String</td><td>Yes</td><td>Structure: tokenName0-tokenName1-pairId</td></tr></tbody></table>

**Request example**

```
{ 
    "action": "sub-quoter-pricing",
    "channel": "WONE-1USDT-1"
}
```

**Example response**

```
{
  "message": {
    "content": {
      "type": "",
      "method": "",
      "data": {
        "bid": "0.047650468",
        "ask": "0.047674767",
        "gasFeeToken0": "0.004642591",
        "gasFeeToken1": "0.00022128910001499997",
        "inboundBid": 0.04766,
        "inboundAsk": 0.04767,
        "transactionFee": 1000000000000000000,
        "transactionFeeToken": "0xDcC4DaAD65Dd459505D8af9bfF60aFd2A8c0b2cc",
        "makerAddressBid": "0x98c3cec32166936672a75fd7d85ad92eb5178d84",
        "makerAddressAsk": "0x98c3cec32166936672a75fd7d85ad92eb5178d84",
        "amount0Address": "0xca3e951D17C520B42ED98482b1f8B6478D4531E2",
        "amount1Address": "0xb63b211f1dB545C04829CA0a3E7D8313711E7eA9",
        "amount0Dec": 18,
        "amount1Dec": 6,
        "maxToken0Bid": "4.7650468",
        "maxToken1Bid": "1091.3844948831131",
        "minToken0": "1",
        "minToken1": "0",
        "pairId": 1
      }
    }
  }
}
```

#### Request stream

The best price stream includes only one side of a pair and is based on the amount of token you want to sell/buy.&#x20;

**Parameters**

<table><thead><tr><th>Name</th><th width="150">Type</th><th width="150">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>action</td><td>String</td><td>Yes</td><td>Always "custom-topic-subscribe".</td></tr><tr><td>data</td><td>Object</td><td>Yes</td><td>Contains information about a topic. </td></tr><tr><td>topic_identifier</td><td>String</td><td>Yes</td><td>Any name that will identify the destination place for websocket data.</td></tr><tr><td>topic_name</td><td>String</td><td>Yes</td><td>Name of topic you'd like to connect to.</td></tr><tr><td>parameters</td><td>Array</td><td>Yes</td><td>Array of stream parameters (side, pairId, value).</td></tr><tr><td>side</td><td>Integer</td><td>Yes</td><td>0-bid, 1-ask</td></tr><tr><td>pairId</td><td>Integer</td><td>Yes</td><td>Token pair id. Token pairs available on our API endpoint.</td></tr><tr><td>value</td><td>Decimal</td><td>Yes</td><td>Token amount you want to buy or sell.</td></tr></tbody></table>

**Request example**

```
{
    "action": "custom-topic-subscribe",
    "data": {
        "topic_identifier": "PRICE_REQUEST",
        "topic_name": "SELECT_REQUEST_PRICING",
        "parameters": [0, 1, 10]  // in order: side, pairId, value
  }
}
```

**Example response**

```
{
  "topic_identifier": "PRICE_REQUEST",
  "topic": "SELECT_REQUEST_PRICING",
  "columns": [
    "rule_id",
    "pair_id",
    "spread_perc",
    "side",
    "outbound_price",
    "maker_address",
    "token0_address",
    "token1_address",
    "token0_dec",
    "token1_dec",
    "gas_fee_token0",
    "gas_fee_token1"
  ],
  "rows": [
    {
      "rule_id": 132,
      "pair_id": 1,
      "spread_perc": 0.0001,
      "side": 1,
      "outbound_price": 0.047774777,
      "maker_address": "0x98c3cec32166936672a75fd7d85ad92eb5178d84",
      "token0_address": "0xca3e951D17C520B42ED98482b1f8B6478D4531E2",
      "token1_address": "0xb63b211f1dB545C04829CA0a3E7D8313711E7eA9",
      "token0_dec": 18,
      "token1_dec": 6,
      "gas_fee_token0": 0.004642591,
      "gas_fee_token1": 0.000221706933205
    }
  ]
}
```

{% hint style="warning" %}
Your response might be empty. It means that there is no price stream for this particular value.
{% endhint %}

### Pricing data for a specific maker&#x20;

Pricing data for a specific maker also allows us to connect to two different streams.

1. **General stream**
2. **Request stream**

#### **General stream**&#x20;

The best price stream provided by a specific maker containing two sides of a token pair.

**Parameters**

<table><thead><tr><th width="206">Name</th><th width="150">Type</th><th width="150">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>action</td><td>String</td><td>Yes</td><td>Always "custom-topic-subscribe".</td></tr><tr><td>data</td><td>Object</td><td>Yes</td><td>Contains information about a topic. </td></tr><tr><td>topic_identifier</td><td>String</td><td>Yes</td><td>Any name that will identify the destination place for websocket data.</td></tr><tr><td>topic_name</td><td>String</td><td>Yes</td><td>Name of topic you'd like to connect to.</td></tr><tr><td>parameters</td><td>Array</td><td>Yes</td><td>Array of stream parameters (side, pairId, value).</td></tr><tr><td>pairId</td><td>Integer</td><td>Yes</td><td>Token pair id. Token pairs available on our API endpoint.</td></tr><tr><td>makerAddress</td><td>String</td><td>Yes</td><td>The wallet address of a maker whom pricing stream you want to receive.</td></tr></tbody></table>

**Request example**

```
{
    "action": "custom-topic-subscribe",
    "data": {
        "topic_identifier": "MAKER_PAIR_PRICING",
        "topic_name": "MAKER_PAIR_PRICING",
        "parameters": [
            1, 
            "0xDa0DD31b18C6BABc35e7d59f94fAe7a180594C7b",
            1, 
            "0xDa0DD31b18C6BABc35e7d59f94fAe7a180594C7b"
        ]  // in order: pairId, makerAddress, pairId, makerAddress
  }
}
```

**Example response**

```
{
    "topic_identifier": "MAKER_PAIR_PRICING",
    "topic": "MAKER_PAIR_PRICING",
    "columns": [
        "pair_id",
        "feed_tier",
        "side",
        "spread_perc",
        "spread_perc:1",
        "min_amount",
        "max_slippage_perc",
        "inbound_price",
        "outbound_price",
        "max_buy_amount",
        "symbol_token0",
        "symbol_token1",
        "maker_address",
        "token0_address",
        "token1_address",
        "token0_dec",
        "token1_dec",
        "gas_fee_token0",
        "gas_fee_token1",
        "transaction_fee",
        "transaction_fee_token"
    ],
    "rows": [
        {
            "pair_id": 1,
            "feed_tier": 0,
            "side": 1,
            "spread_perc": 0.0001,
            "spread_perc:1": 0.0001,
            "min_amount": 0,
            "max_slippage_perc": 10,
            "inbound_price": 0.04718,
            "outbound_price": 0.047184718,
            "max_buy_amount": 1112,
            "symbol_token0": "WONE",
            "symbol_token1": "1USDT",
            "maker_address": "0x98c3cec32166936672a75fd7d85ad92eb5178d84",
            "token0_address": "0xca3e951D17C520B42ED98482b1f8B6478D4531E2",
            "token1_address": "0xb63b211f1dB545C04829CA0a3E7D8313711E7eA9",
            "token0_dec": 18,
            "token1_dec": 6,
            "gas_fee_token0": 0.0052416350000000006,
            "gas_fee_token1": 0.000247274131125,
            "transaction_fee": 1000000000000000000,
            "transaction_fee_token": "0xDcC4DaAD65Dd459505D8af9bfF60aFd2A8c0b2cc"
        }
    ]
}
```

#### **Request stream**

The best price stream provided by a specific maker including only one side of a pair and is based on the amount of token you want to sell/buy.&#x20;

**Parameters**

<table><thead><tr><th>Name</th><th width="150">Type</th><th width="150">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>action</td><td>String</td><td>Yes</td><td>Always "custom-topic-subscribe".</td></tr><tr><td>data</td><td>Object</td><td>Yes</td><td>Contains information about a topic. </td></tr><tr><td>topic_identifier</td><td>String</td><td>Yes</td><td>Any name that will identify the destination place for websocket data.</td></tr><tr><td>topic_name</td><td>String</td><td>Yes</td><td>Name of topic you'd like to connect to.</td></tr><tr><td>parameters</td><td>Array</td><td>Yes</td><td>Array of stream parameters (side, pairId, value).</td></tr><tr><td>side</td><td>Integer</td><td>Yes</td><td>0-bid, 1-ask</td></tr><tr><td>pairId</td><td>Integer</td><td>Yes</td><td>Token pair id. Token pairs available on our API endpoint.</td></tr><tr><td>value</td><td>Decimal</td><td>Yes</td><td>Token amount you want to buy or sell.</td></tr><tr><td>makerAddress</td><td>String</td><td>Yes</td><td>The wallet address of a maker whom pricing stream you want to receive.</td></tr></tbody></table>

**Request example**

```
{
    "action": "custom-topic-subscribe",
    "data": {
        "topic_identifier": "MAKER_PRICE_REQUEST",
        "topic_name": "SELECT_REQUEST_MAKER_PRICING",
        "parameters": [0, 1, 10, "0x98C3CEC32166936672A75FD7D85ad92eb5178D84"]  
        // in order: side, pairId, value, makerAddress
  }
}
```

**Example response**

```
{
    "topic_identifier": "MAKER_PRICE_REQUEST",
    "topic": "SELECT_REQUEST_MAKER_PRICING",
    "columns": [
        "rule_id",
        "pair_id",
        "spread_perc",
        "side",
        "outbound_price",
        "maker_address",
        "token0_address",
        "token1_address",
        "token0_dec",
        "token1_dec",
        "gas_fee_token0",
        "gas_fee_token1"
    ],
    "rows": [
        {
            "rule_id": 131,
            "pair_id": 1,
            "spread_perc": 0.0002,
            "side": 0,
            "outbound_price": 0.047200558000000004,
            "maker_address": "0x98c3cec32166936672a75fd7d85ad92eb5178d84",
            "token0_address": "0xca3e951D17C520B42ED98482b1f8B6478D4531E2",
            "token1_address": "0xb63b211f1dB545C04829CA0a3E7D8313711E7eA9",
            "token0_dec": 18,
            "token1_dec": 6,
            "gas_fee_token0": 0.0052416350000000006,
            "gas_fee_token1": 0.00024753621287500004
        }
    ]
}
```

### Order Execution

To execute an order, send a message to the quote-executions-\[UUID] channel with the following information.

|                     |                 | Description                                                                            |
| ------------------- | --------------- | -------------------------------------------------------------------------------------- |
| type                | Number          | 0 - bid, 1 - ask                                                                       |
| takerAmount         | String          | Has to be number with no decimals.                                                     |
| makerAmount         | String          | Has to be number with no decimals.                                                     |
| limitOrder          | RFQOrder        | Object created with "buildRFQOrder" method from limit order protocol library.          |
| sessionKey          | String          | Session public key.                                                                    |
| resultEIP712        | EIP712TypedData | Object created with "buildRFQOrderTypedData" method from limit order protocol library. |
| limitOrderSignature | String          | String created with "buildOrderSignature" method from limit order protocol library.    |
| ruleId              | Number          | Rule id received from pricing stream.                                                  |
| orderGas            | Object          | Gas Fee information received from the pricing stream.                                  |

**Example request**

```
{ 
    "action": "execute-order"
    ​"channel": "quote-executions-6f47c643-cfa6-48ae-ae5b-f8fed519ef65"
​    "data": 
        { 
               "limitOrder": RFQOrder,
               "limitOrderSignature": "0x30dcd76f11d3b0a1f75757eb442b73c056a19df80209107d4b7ef4135f4699086f0e090ab9d96bd74f439124381d52be13d19abd440dd4bd9793b69a86a0d3e81b",
               "takerAmount": "10000", 
               "makerAmount": "75023679387584720",
               "type": 1,
               ​​"ruleId": 114,
​               "sessionKey": "0xD9594fa3BAd626Eed13d0F2b5BFDC2dd7a7576e9",
               "orderGas": 
                  {
                       "gasFee":0.00464478,
                       "gasFeeToken0":"0.00464478",
                       "gasFeeToken1":"0.0005829431139",
                       "gasFeeOperation":4
                  },
               "resultEIP712": EIP712TypedData
       }
​​​}
```

### Order Status

In order to receive your transaction status, subscribe to a channel that is the id you used to create RFQOrder.&#x20;

**Subscription example**

```
{ 
    "action": "sub-response-client-execution",
    "channel": "3203138488"  // that is the same id you had used to create RFQOrder
}
```

**Example responses**

```
{ 
    "type": "pending" 
}
```

```
{
    "action": "quote-execution-response",
    "channel": "3203138488",
    "content": {
            "type": "transaction_posted",
            "hash: "0x499e6a5c76920118987055b19b5d8d0217e4c9559e8023d61e284bb606b2677d"
    }
}
```

```
{ 
    "type": "send_to_blockchain",
    "hash": "0x499e6a5c76920118987055b19b5d8d0217e4c9559e8023d61e284bb606b2677d" 
}
```

```
{ 
    "type": "filled",
    "hash": "0x499e6a5c76920118987055b19b5d8d0217e4c9559e8023d61e284bb606b2677d" 
}
```

## Advanced Panel Streams

There are two additional streams for advanced mode.&#x20;

1. General advanced stream&#x20;
2. Advanced stream for a specific maker

**Parameters**

<table><thead><tr><th width="208.42857142857144">Name</th><th width="150">Type</th><th width="150">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>pairId</td><td>Integer</td><td>Yes</td><td>Token pair id. Token pairs available on our API endpoint.</td></tr><tr><td>valueBid</td><td>Decimal</td><td>Yes</td><td>Token amount on bid side.</td></tr><tr><td>valueAsk</td><td>Decimal</td><td>Yes</td><td>Token amount on ask side.</td></tr><tr><td>makerAddress</td><td>String</td><td>Yes</td><td>The wallet address of a maker whom pricing stream you want to receive.</td></tr></tbody></table>

### General advanced stream

The best price stream includes two sides of a pair and is based on the amount of token you want to sell/buy.&#x20;

**Example request**

```
{
    "action": "custom-topic-subscribe",
    "data": {
        "topic_identifier": "6", // pairId (string)
        "topic_name": "SELECT_ADVANCED_REQUEST_PRICING",
        "parameters": [6, 0.1, 6, 0.1]  
        // in order: pairId, valueBid, pairId, valueAsk
  }
}
```

**Example response**

```
{
    "topic_identifier": "6",
    "topic": "SELECT_ADVANCED_REQUEST_PRICING",
    "columns": [
        "rule_id",
        "pair_id"
        "side",
        "outbound_price",
        "maker_address",
        "token0_address",
        "token1_address",
        "token0_dec",
        "token1_dec",
        "gas_fee_token0",
        "gas_fee_token1",
        "transaction_fee",
        "transaction_fee_token"
    ],
    "rows": [
        {
        "gas_fee_token0": 0.018512530089152
        ​​​"gas_fee_token1": 0.015949470298308906
        ​​​"maker_address": "0xda0dd31b18c6babc35e7d59f94fae7a180594c7b"
        ​​​"outbound_price": 0.86149991385
        ​​​"pair_id": 6
        ​​​"rule_id": 234
        ​​​"side": 0
        ​​​"token0_address": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"
        ​​​"token0_dec": 18
        ​​​"token1_address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
        ​​​"token1_dec": 6
        ​​"transaction_fee": 0
        "​transaction_fee_token": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
        },
        
        {
        "gas_fee_token0": 0.018512530089152
        ​​​"gas_fee_token1": 0.015949470298308906
        ​​​"maker_address": "0xda0dd31b18c6babc35e7d59f94fae7a180594c7b"
        ​​​"outbound_price": 0.86149991385
        ​​​"pair_id": 6
        ​​​"rule_id": 235
        ​​​"side": 1
        ​​​"token0_address": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"
        ​​​"token0_dec": 18
        ​​​"token1_address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
        ​​​"token1_dec": 6
        ​​"transaction_fee": 0
        "​transaction_fee_token": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
        }
    ]
}
```

### Advanced stream for a specific maker

The best price stream includes two sides of a pair and is based on the amount of token you want to sell/buy. Stream is provided by a specific maker.&#x20;

**Request example**

```
{
    "action": "custom-topic-subscribe",
    "data": {
        "topic_identifier": "6", // pairId (string)
        "topic_name": "SELECT_ADVANCED_REQUEST_PRICING",
        "parameters": [6, 0.1, "0x98C3CEC32166936672A75FD7D85ad92eb5178D84",
         6, 0.1,"0x98C3CEC32166936672A75FD7D85ad92eb5178D84"]  
        // in order: pairId, valueBid, makerAddress, pairId, valueAsk, makerAddress
  }
}
```

**Response Example**

```
{
    "topic_identifier": "6",
    "topic": "SELECT_ADVANCED_MAKER_REQUEST_PRICING",
    "columns": [
        "rule_id",
        "pair_id"
        "side",
        "outbound_price",
        "maker_address",
        "token0_address",
        "token1_address",
        "token0_dec",
        "token1_dec",
        "gas_fee_token0",
        "gas_fee_token1",
        "transaction_fee",
        "transaction_fee_token"
    ],
    "rows": [
        {
        "gas_fee_token0": 0.018512530089152
        ​​​"gas_fee_token1": 0.015949470298308906
        ​​​"maker_address": "0xda0dd31b18c6babc35e7d59f94fae7a180594c7b"
        ​​​"outbound_price": 0.86149991385
        ​​​"pair_id": 6
        ​​​"rule_id": 234
        ​​​"side": 0
        ​​​"token0_address": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"
        ​​​"token0_dec": 18
        ​​​"token1_address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
        ​​​"token1_dec": 6
        ​​"transaction_fee": 0
        "​transaction_fee_token": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
        },
        
        {
        "gas_fee_token0": 0.018512530089152
        ​​​"gas_fee_token1": 0.015949470298308906
        ​​​"maker_address": "0xda0dd31b18c6babc35e7d59f94fae7a180594c7b"
        ​​​"outbound_price": 0.86149991385
        ​​​"pair_id": 6
        ​​​"rule_id": 235
        ​​​"side": 1
        ​​​"token0_address": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"
        ​​​"token0_dec": 18
        ​​​"token1_address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
        ​​​"token1_dec": 6
        ​​"transaction_fee": 0
        "​transaction_fee_token": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
        }
    ]
}
```


---

# 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://docs.coinquoter.com/products/taker/websocket-documentation.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.
