# Market Data

Endpoints to obtain pricing for all supported assets.

## Get Price

`GET /v2/price/{sellingAsset}/{buyingAsset}`

Returns the price of a selling asset for a buying asset. The price is the quantity of the buying asset received for 1 unit of the selling asset, e.g. selling 1 BTC for 10120.65 USD.

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `sellingAsset` | path | Yes | string | Asset you wish to sell (e.g. `btc`) |
| `buyingAsset` | path | Yes | string | Asset you wish to buy (e.g. `usd`) |
| `commission_source` | query | No | string | If specified, returns the price adjusted to the commission you pay when trading on a particular source. If trading via API use OFFCHAIN, else specify the blockchain you plan to trade on (e.g. `OFFCHAIN`) |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `price` | string | Price (e.g. `10120.65`) |

- **400**: Bad request

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Duplicate asset pair):
  ```json
  {"code":"DUPLICATE_ASSET_PAIR","description":"Buying and selling asset cannot be the same"}
  ```
- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid JWT):
  ```json
  {"code":"INVALID_JWT_TOKEN","description":"Invalid JWT"}
  ```
- **403**: Invalid permissions

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid permissions):
  ```json
  {"code":"INVALID_PERMISSIONS","description":"Invalid permissions"}
  ```
- **404**: Instrument or market data not found

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (No market data):
  ```json
  {"code":"NO_MARKET_DATA_FOUND","description":"No market data found"}
  ```

**Example**

```bash
curl "https://api.demo.omniaexchange.com/api/v2/price/{sellingAsset}/{buyingAsset}" \
  -H "Authorization: Bearer <token>"
```

---

## Get Prices

`GET /v2/prices`

Gets multiple prices at once. The prices of each selling/buying asset pair can be requested by including them as query params (e.g. sellingAsset/buyingAsset). The price is the quantity of the buying asset received for 1 unit of the selling asset, e.g. selling 1 BTC for 10120.65 USD. There is a limit of 50 assets at once and no duplicates are allowed.

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `assets` | query | Yes | string[] | Specify all asset combinations you want prices for in the format {sellingAsset}/{buyingAsset}. This parameter can be repeated, e.g. ?assets=btc/usd&assets=eth/usd&assets=usd/sol |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `prices` | BatchPricePriceResponse[] | prices |


  Example (Single price success response):
  ```json
  {"prices":[{"assets":"btc/usd","price":"10120.65"}]}
  ```
- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid JWT):
  ```json
  {"code":"INVALID_JWT_TOKEN","description":"Invalid JWT"}
  ```
- **403**: Invalid permissions

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid permissions):
  ```json
  {"code":"INVALID_PERMISSIONS","description":"Invalid permissions"}
  ```

**Example**

```bash
curl "https://api.demo.omniaexchange.com/api/v2/prices" \
  -H "Authorization: Bearer <token>"
```

---

## Get Quantity Estimate

`GET /v2/quantity-estimate`

Calculates the estimated quantity of a buying asset you would receive for a specified quantity of a selling asset, based on current market data

**Parameters**

| Name | In | Required | Type | Description |
|------|-----|----------|------|-------------|
| `selling_asset` | query | Yes | string | Asset you wish to sell (e.g. `btc`) |
| `buying_asset` | query | Yes | string | Asset you wish to buy (e.g. `usd`) |
| `sell_quantity` | query | Yes | string | Amount you wish to sell (e.g. `1.75`) |
| `commission_source` | query | No | string | If specified, returns the estimated quantity adjusted to the commission you pay when trading on a particular source. If trading via API use OFFCHAIN, else specify the blockchain you plan to trade on (e.g. `OFFCHAIN`) |

**Responses**

- **200**: Ok

  | Field | Type | Description |
  |-------|------|-------------|
  | `sellingAsset` | string | Selling Asset (e.g. `btc`) |
  | `buyingAsset` | string | Buying Asset (e.g. `usd`) |
  | `sellingAmount` | string | Selling Amount (e.g. `5.67`) |
  | `quantityEstimate` | string | Quantity Estimate (e.g. `25864.23`) |

- **400**: Bad request

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Not enough liquidity):
  ```json
  {"code":"NOT_ENOUGH_LIQUIDITY","description":"Not enough liquidity"}
  ```
- **401**: Unauthorized

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid JWT):
  ```json
  {"code":"INVALID_JWT_TOKEN","description":"Invalid JWT"}
  ```
- **403**: Invalid permissions

  | Field | Type | Description |
  |-------|------|-------------|
  | `code` | string | Error code |
  | `description` | string | Error description |


  Example (Invalid permissions):
  ```json
  {"code":"INVALID_PERMISSIONS","description":"Invalid permissions"}
  ```

**Example**

```bash
curl "https://api.demo.omniaexchange.com/api/v2/quantity-estimate" \
  -H "Authorization: Bearer <token>"
```

---

