# Trade

*<mark style="color:red;">Note: All trading calls need to be authorized against your</mark>* [*<mark style="color:red;">**AIO Exchange**</mark>*](https://aio.exchange/) *<mark style="color:red;">account before processing any request, refer to the Authentication tab for more details.</mark>*

## Request A Quote&#x20;

## Queries each exchange and returns the best quote corresponding to parameters.

<mark style="color:green;">`POST`</mark> `https://api.aio.exchange/api/v2/trade/requestquote`

Each exchange orderbook is queried and blockchains analyzed according to parameters.

#### Request Body

| Name                                            | Type      | Description                                                                                                                                                                                                                                                                                                                                                                                                            |
| ----------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| side<mark style="color:red;">\*</mark>          | String    | "buy" or "sell"                                                                                                                                                                                                                                                                                                                                                                                                        |
| executionType<mark style="color:red;">\*</mark> | Integer   | <p>1 = Best Execution</p><p>2 = Quickest Best Execution</p><p>3 = Instant Settlement</p>                                                                                                                                                                                                                                                                                                                               |
| orderType<mark style="color:red;">\*</mark>     | String    | "Market", "Limit" or "Stop"                                                                                                                                                                                                                                                                                                                                                                                            |
| baseAmount                                      | Decimal   | <p>This refers to the (base) amount in terms of the first part of the ticker pair. </p><p></p><p><em>i.e. if BTC-USDT ({BaseSymbol}-{TargetSymbol} is requested, the baseAmount refers to the amount in BTC.</em></p><p></p><p>This parameter can be used for both "buy" and "sell" orders.</p><p></p><p><mark style="color:orange;">\*If this parameter is not provided, targetAmount is required.</mark> </p><p></p> |
| baseTokenId                                     | Integer   | <p>Unique Token Identifier </p><p></p><p><mark style="color:orange;">\*If this parameter is not provided, baseTokenSymbol is required.</mark></p>                                                                                                                                                                                                                                                                      |
| targetTokenId                                   | Integer   | <p>Unique Token Identifier </p><p></p><p><mark style="color:orange;">\*If this parameter is not provided, targetTokenSymbol is required.</mark></p>                                                                                                                                                                                                                                                                    |
| sources                                         | String\[] | <p>Array of exchangeIds to filter quotes. </p><p>Available value include</p><p></p><p><em>\["BINANCE", "BITFINEX", "BITMART", "BITMART", "BITSTAMP", "BITTREX", "CEX", "COINBASE", "COINMETRO", "CRYPTOCOM", "GATE", "HUOBI", "KRAKEN", "KUCOIN", "OKX", "OKCOIN", "PROBIT"]</em> </p>                                                                                                                                 |
| targetAmount                                    | Decimal   | <p>This refers to the (base) amount in terms of the first part of the ticker pair. </p><p></p><p><em>i.e. if BTC-USDT ({BaseSymbol}-{TargetSymbol} is requested, the targetAmount refers to the amount in USDT.</em></p><p></p><p>This parameter can be used for both "buy" and "sell" orders.</p><p></p><p><mark style="color:orange;">\*If this parameter is not provided, baseAmount is required.</mark></p>        |
| targetTokenSymbol                               | String    | <p>ticker of quote currency (e.g. "BTC")</p><p></p><p><mark style="color:orange;">\*If this parameter is not provided, targetCoinId is required.</mark></p>                                                                                                                                                                                                                                                            |
| baseTokenSymbol                                 | String    | <p>ticker of base currency (e.g. "BTC")</p><p></p><p><mark style="color:orange;">\*If this parameter is not provided, baseCoinId is required.</mark></p>                                                                                                                                                                                                                                                               |

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

```javascript
{
   "data":{
      "enforceMasterBalance":true,
      "id":1459,
      "quoteId":"AIOQ908536F9207349BA99C66",
      "side":"SELL",
      "executionType":1,
      "orderType":"MARKET",
      "status":"QUOTED",
      "baseAmount":1.27914,
      "targetAmount":25.0,
      "rate":20.17,
      "baseTokenSymbol":"SOL",
      "targetTokenSymbol":"USDT", 
      "baseTokenId":3956,
      "targetTokenId":4276,
      "makerFee":0.0,
      "takerFee":0.0,
      "aioFee":5.0,
      "totalFee":1.8357,
      "chain":"SPL-SPL",
      "exchange":"BINANCE",
      "estSettlementTimeSecs":146,
      "expiryTime":"1/1/1900 12:00:00 AM",
      "dateCreated":"4/9/2023 11:54:55 AM",
      "dateModified":"4/9/2023 11:54:58 AM",
      "sources":null
   },
   "success":true,
   "timestamp":1681041295072,
   "requestId":"511203ff-3999-4f3d-ac1c-045d02cbd855",
   "message":"",
   "error":null
}
```

{% endtab %}
{% endtabs %}

## Accept A Quote&#x20;

## Accept Quote (Place Order)

<mark style="color:green;">`POST`</mark> `https://api.aio.exchange/api/v2/trade/acceptquote`

#### Request Body

| Name                                      | Type   | Description                                          |
| ----------------------------------------- | ------ | ---------------------------------------------------- |
| quoteId<mark style="color:red;">\*</mark> | String | Id Of The Quote To Accept                            |
| MaxTimeout                                | Int    | <p>Default: 20 seconds</p><p>Maximum: 60 seconds</p> |

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

```
{
   "data":{
      "orderId":"e8952605-4bc2-4039-a133-4e3gk513afd4c",// for API orders 
      "quoteId":"AIOQ908536F9207349BA99C66",
      "timestampCreated":1668931096371,
   },
   "success":true,
   "timestamp":1681041295072,
   "requestId":"511203ff-3999-4f3d-ac1c-04364564sg55",
   "message":"",
   "error":null
}
```

{% endtab %}
{% endtabs %}

## Get Order Detail&#x20;

## Order placed using accept a quote can be retrieved using order id. &#x20;

<mark style="color:blue;">`GET`</mark> `https://api.aio.exchange/api/v2/trade/orderdetail/{orderId}`

Eg. <https://api.aio.exchange/api>/v2/trade/orderdetail/e8952605-4bc2-4039-a133-4e3gk513afd4c

#### Path Parameters

| Name    | Type   | Description                                       |
| ------- | ------ | ------------------------------------------------- |
| orderId | string | orderId retrieved from previous Accept Quote call |

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

```
{
   "data":{
      "orderId":"e8952605-4bc2-4039-a133-4e3gk513afd4c",
      "quoteId":"AIOQ908536F9207349BA99C66",
      "orderStatus":"ERROR NO BALANCE",
      "baseSymbol":"SOL",
      "targetSymbol":"USDT",
      "exchange":"BINANCE",
      "side":"SELL",
      "orderSize":null,
      "received":0.0,
      "receivedSymbol":"USDT",
      "depositMethod":{
         "network":"SPL",
         "amount":1.26907,
         "symbol":"SOL",
         "transactionId":"",
         "fee":0.0000100000,
         "FeeSymbol":"SOL"
      },
      "withdrawMethod":{
         "network":"SPL",
         "amount":0.0,
         "symbol":"USDT",
         "transactionId":"",
         "fee":0.8000000000,
         "FeeSymbol":"USDT"
      },
      "aioFee":5.0000000000,
      "aioFeeSymbol":"AIO",
      "dateCreated":"4/8/2023 6:06:30 PM",
      "dateModified":"4/8/2023 6:06:30 PM"
   },
   "success":true,
   "timestamp":1681041677918,
   "requestId":"72b4bb7c-f00d-488d-9945-9212ca07b31a",
   "message":"",
   "error":null
}
```

{% endtab %}
{% endtabs %}

## Get All Order Details

## All orders placed within the account can be retrieved using above request. API will return the last 50 orders. Older order can be fetched using the page number, each request will return a maximum of 50 orders.

<mark style="color:blue;">`GET`</mark> `https://api.aio.exchange/api/v2/trade/orderdetails`

Eg. <https://api.aio.exchange/api>/v2/trade/orderdetails ,

&#x20;<https://api.aio.exchange/api>/v2/trade/orderdetails/{pagenumber}

#### Path Parameters

| Name       | Type    | Description                                                                                                                                              |
| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| pagenumber | integer | maximum order per request is 50, any later order can be fetched by passing the page number, if page number not passed, default it will return first page |

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

```
{
   "data":[{
      "orderId":"e8952605-4bc2-4039-a133-4e3gk513afd4c",
      "quoteId":"AIOQ908536F9207349BA99C66",
      "orderStatus":"ERROR NO BALANCE",
      "baseSymbol":"SOL",
      "targetSymbol":"USDT",
      "exchange":"BINANCE",
      "side":"SELL",
      "orderSize":null,
      "received":0.0,
      "receivedSymbol":"USDT",
      "depositMethod":{
         "network":"SPL",
         "amount":1.26907,
         "symbol":"SOL",
         "transactionId":"",
         "fee":0.0000100000,
         "FeeSymbol":"SOL"
      },
      "withdrawMethod":{
         "network":"SPL",
         "amount":0.0,
         "symbol":"USDT",
         "transactionId":"",
         "fee":0.8000000000,
         "FeeSymbol":"USDT"
      },
      "aioFee":5.0000000000,
      "aioFeeSymbol":"AIO",
      "dateCreated":"4/8/2023 6:06:30 PM",
      "dateModified":"4/8/2023 6:06:30 PM"
   },
   {
      "orderId":"34df505-4bc2-4039-a133-4e3gk513afd4c",
      "quoteId":"AIOQ908536F9207349BA99C66",
      "orderStatus":"ERROR NO BALANCE",
      "baseSymbol":"SOL",
      "targetSymbol":"USDT",
      "exchange":"BINANCE",
      "side":"SELL",
      "orderSize":null,
      "received":0.0,
      "receivedSymbol":"USDT",
      "depositMethod":{
         "network":"SPL",
         "amount":1.26907,
         "symbol":"SOL",
         "transactionId":"",
         "fee":0.0000100000,
         "FeeSymbol":"SOL"
      },
      "withdrawMethod":{
         "network":"SPL",
         "amount":0.0,
         "symbol":"USDT",
         "transactionId":"",
         "fee":0.8000000000,
         "FeeSymbol":"USDT"
      },
      "aioFee":5.0000000000,
      "aioFeeSymbol":"AIO",
      "dateCreated":"4/8/2023 6:06:30 PM",
      "dateModified":"4/8/2023 6:06:30 PM"
   }],
   "success":true,
   "timestamp":1681041677918,
   "requestId":"72b4bb7c-f00d-488d-9945-9212ca07b31a",
   "message":"",
   "error":null
}
```

{% endtab %}
{% endtabs %}


---

# 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.aio.exchange/trade.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.
