> For the complete documentation index, see [llms.txt](https://docs.openmm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openmm.io/api-reference/price-comparison/price-compare.md).

# GET /price/compare

Compare prices for a trading pair across multiple exchanges.

## Request

```
GET /api/v1/price/compare?symbol={symbol}&exchanges={exchanges}
```

### Parameters

| Parameter | Type   | Required | Default | Description                  |
| --------- | ------ | -------- | ------- | ---------------------------- |
| symbol    | string | ✅        | —       | Trading pair                 |
| exchanges | string | ❌        | all     | Comma-separated exchange IDs |

## Response

```json
{
  "symbol": "BTC/USDT",
  "prices": [
    {
      "exchange": "mexc",
      "price": 42150.00,
      "bid": 42148.00,
      "ask": 42152.00,
      "spread": 4.00,
      "spreadPercent": 0.0095,
      "timestamp": 1710000000000
    },
    {
      "exchange": "gateio",
      "price": 42145.00,
      "bid": 42143.00,
      "ask": 42147.00,
      "spread": 4.00,
      "spreadPercent": 0.0095,
      "timestamp": 1710000000000
    }
  ],
  "analysis": {
    "lowestAsk": {
      "exchange": "gateio",
      "price": 42147.00
    },
    "highestBid": {
      "exchange": "mexc",
      "price": 42148.00
    },
    "spread": 1.00,
    "spreadPercent": 0.0024,
    "arbitrageOpportunity": true
  },
  "timestamp": 1710000000000
}
```

### Analysis Fields

| Field                | Type    | Description                   |
| -------------------- | ------- | ----------------------------- |
| lowestAsk            | object  | Best exchange to buy          |
| highestBid           | object  | Best exchange to sell         |
| spread               | number  | Cross-exchange spread         |
| spreadPercent        | number  | Spread as percentage          |
| arbitrageOpportunity | boolean | True if profitable arb exists |

## Examples

```bash
# Compare across all exchanges
curl "http://localhost:3000/api/v1/price/compare?symbol=BTC/USDT"

# Compare specific exchanges
curl "http://localhost:3000/api/v1/price/compare?symbol=ETH/USDT&exchanges=mexc,kraken"
```

## Arbitrage Detection

When `arbitrageOpportunity` is `true`:

* Buy at `lowestAsk.exchange` at `lowestAsk.price`
* Sell at `highestBid.exchange` at `highestBid.price`
* Gross profit = `spread`

⚠️ Consider trading fees, withdrawal fees, and transfer times before executing.

## Errors

| Code | Error          | Description                  |
| ---- | -------------- | ---------------------------- |
| 400  | Invalid symbol | Symbol format incorrect      |
| 500  | Fetch failed   | One or more exchanges failed |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.openmm.io/api-reference/price-comparison/price-compare.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
