# App API

## Get API Information

<mark style="color:blue;">`GET`</mark> `https://app-api.brink.trade/info`

This endpoint returns Brink API information, such as the version of the API.

## Estimate Cost of an Order

<mark style="color:blue;">`GET`</mark> `https://app-api.brink.trade/estimateOrderCost`

Get cost estimation for a given swap

#### Path Parameters

| Name                                             | Type    | Description                     |
| ------------------------------------------------ | ------- | ------------------------------- |
| owner<mark style="color:red;">\*</mark>          | address | address of owner                |
| tokenIn<mark style="color:red;">\*</mark>        | address | Address of token to be traded   |
| tokenOut<mark style="color:red;">\*</mark>       | address | Address of token to be received |
| tokenInAmount<mark style="color:red;">\*</mark>  | bigint  | number of tokens to be traded   |
| tokenOutAmount<mark style="color:red;">\*</mark> | bigin   | number of tokens to be received |

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

<pre class="language-json"><code class="lang-json">		{
				tokenIn: {...},
				tokenOut: {...},
				tokenInAmount: &#x3C;int>,
				tokenOutAmount: &#x3C;int>,
				tokenInAmountDecimals: &#x3C;int>,
				tokenOutAmountDecimals: &#x3C;int>,
				gasPrice: &#x3C;decimal>,
				marketPrices: {
					ETH_USD: &#x3C;decimal>,
					TokenIn_ETH: &#x3C;decimal>,
					TokenOut_ETH: &#x3C;decimal>
				},
				marketCosts: {
					TokenInAmount_TokenOut: &#x3C;decimal>,
					TokenInAmount_ETH: &#x3C;decimal>,
					TokenInAmount_USD: &#x3C;decimal>,
					TokenOutAmount_TokenIn: &#x3C;decimal>,
					TokenOutAmount_ETH: &#x3C;decimal>,
					TokenOutAmount_USD: &#x3C;decimal>
				},
				totalGasEstimate: {
					type: ‘totals’,
					gas: &#x3C;int>,
					gas_ETH: &#x3C;decimal>,
<strong>					gas_USD: &#x3C;decimal>,
</strong>					gas_TokenIn: &#x3C;decimal>,
					gas_TokenOut: &#x3C;decimal>
				},
				gasEstimates: [
					{
						type: ‘brinkAccountDeploy’,
						gas: &#x3C;int>,
<strong>						gas_ETH: &#x3C;decimal>,
</strong>						gas_USD: &#x3C;decimal>,
						gas_[TokenInAddress]: &#x3C;decimal>,
						gas_[TokenOutAddress]: &#x3C;decimal>
					},
					{
						type: ‘tokenSwap’,
						gas: &#x3C;int>,
						gas_ETH: &#x3C;decimal>,
						gas_USD: &#x3C;decimal>,
						gas_[TokenInAddress]: &#x3C;decimal>,
						gas_[TokenOutAddress]: &#x3C;decimal>
					},
					{
						type: ‘nftBuy’,
						gas: &#x3C;int>,
						gas_ETH: &#x3C;decimal>,
						gas_USD: &#x3C;decimal>,
						gas_[TokenInAddress]: &#x3C;decimal>,
						gas_[TokenOutAddress]: &#x3C;decimal>
					},
					{
						type: ‘overhead’,
						gas: &#x3C;int>,
						gas_ETH: &#x3C;decimal>,
						gas_USD: &#x3C;decimal>,
						gas_[TokenInAddress]: &#x3C;decimal>,
						gas_[TokenOutAddress]: &#x3C;decimal>
					}
				]
			}
</code></pre>

{% endtab %}
{% endtabs %}

## Get Order Details for a Single Order

<mark style="color:blue;">`GET`</mark> `https://app-api.brink.trade/orders/<hash>`

Using the hash of the order, retrieve order details about an order

#### Path Parameters

| Name           | Type      | Description                                                                                                                           |
| -------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| includeHistory | Boolean   | <p>true/false (Default false)<br>Include cost history of order</p>                                                                    |
| startTime      | Timestamp | <p>Must be included if includeHistory is true. startTime for cost history<br>Format: 2021-09-05T06:54:14.752Z<br>All dates in UTC</p> |
| endTime        | Timestamp | <p>Must be included if includeHistory is true. endTime for cost history<br>Format: 2021-09-05T06:54:14.752Z<br>All dates in UTC</p>   |

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

```json
{
	hash: ‘0x..’
	tokenIn: {...},
	tokenOut: {...},
	tokenInAmount: <int>,
	tokenOutAmount: <int>,
	tokenInAmountDecimals: <int>,
	tokenOutAmountDecimals: <int>,
	signedMessage: {...},
	messageType: TOKEN_TO_NFT,
	transactions: [
			{
				status: ‘success’,
				Hash: <TX_HASH>
			},
			{
				status: ‘failed’,
				Hash: <TX_HASH>
			}
		],
		costHistory: [
				{
					time: <timestamp>,
					estimatedCost: {
						ETH: <decimal>,
						TokenIn: <decimal>,
						TokenOut: <decimal>
					},
					estimateOutput: {
						ETH: <decimal>,
						TokenIn: <decimal>,
						TokenOut: <decimal>
					},
					floorPrice: {
						ETH: <decimal>,
						TokenIn: <decimal>
					}
				},
				…
		]
}

```

{% endtab %}
{% endtabs %}

## Retrieve Orders&#x20;

<mark style="color:blue;">`GET`</mark> `https://app-api.brink.trade/orders`

Endpoint to retrieve a list of orders specified by at the account level, and some other options such as order status

#### Path Parameters

| Name          | Type   | Description                                                                                           |
| ------------- | ------ | ----------------------------------------------------------------------------------------------------- |
| account       | String | Account address                                                                                       |
| signer        | String | Signer address                                                                                        |
| page          | Int    | Used for pagination, default 1                                                                        |
| pageSize      | Int    | Used for pagination, default 30                                                                       |
| sortDirection | String | <p><'asc'> or <'desc'> (default value)<br>Sorted by creation time</p>                                 |
| status        | String | <p>Options:<br>'canceled'</p><p>'filled'</p><p>'expired'</p><p>'open'</p><p>'all' (default value)</p> |
| asset         | String | <p>Filter by asset being traded<br>String Address</p>                                                 |

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

<pre class="language-json"><code class="lang-json">	{
		count: 571,
		account: &#x3C;0x123>,
		owner: &#x3C;0x123>,
		nextPage: &#x3C;url>,
		orders: [{
			created: &#x3C;TIMESTAMP>,
			type: &#x3C;limit_swap_token_to_token,...> - same as VERIFIER types,
			signedMessage: &#x3C;SignedMessage>,
			status: &#x3C;open|filled|canceled|expired>,
			transactions: [
				{
					hash: 0x1234…,
					success: true | false
				}
			],
			insufficientFunds: true|false,
<strong>			neverExecutable: true|false,
</strong>
			… additional fields depend on VERIFIER type
<strong>			… i.e for limit_swap_token_to_token:
</strong>			typeFields: {
				bitmapIndex: &#x3C;BIGINT>,
				bit: &#x3C;BIGINT>,
				tokenIn: 0x123,
				tokenInAmount: &#x3C;BIGINT>,
				tokenOut: 0xabc,
				tokenOutAmount: &#x3C;BIGINT>
				expiryBlock: &#x3C;BIGINT>
			}
		}]
	}

</code></pre>

{% 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://brink.gitbook.io/brink/developer-guides/app-api.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.
