# Quick Markets

15-minute auto-expiring price prediction markets for BTC, ETH, and other assets.

## Get Active Quick Market

Returns the currently active quick market for an asset.

```
GET /api/v1/quick-markets/{asset}
```

### Path Parameters

| Parameter | Type   | Description                       |
| --------- | ------ | --------------------------------- |
| `asset`   | string | Asset symbol (e.g., `BTC`, `ETH`) |

### Response (Active Market)

```json
{
  "active": true,
  "asset": "BTC",
  "quickMarket": {
    "id": 42,
    "marketId": "0x...",
    "asset": "BTC",
    "intervalMinutes": 15,
    "startPrice": 9750000000000,
    "startTime": 1735689000,
    "endTime": 1735689900,
    "resolved": false,
    "priceSource": "pyth",
    "createdAt": 1735689000
  },
  "bestAskPrice": 450000
}
```

| Field                     | Type   | Description                                                                                                     |
| ------------------------- | ------ | --------------------------------------------------------------------------------------------------------------- |
| `active`                  | bool   | Whether there is a currently active market                                                                      |
| `quickMarket.marketId`    | string | Market ID for placing orders                                                                                    |
| `quickMarket.startPrice`  | int64  | Strike price at market creation (price uses 6 decimals for USDC, but asset prices may use 8 decimals from Pyth) |
| `quickMarket.startTime`   | int64  | Unix timestamp when the market started                                                                          |
| `quickMarket.endTime`     | int64  | Unix timestamp when the market expires                                                                          |
| `quickMarket.resolved`    | bool   | Whether the market has been resolved                                                                            |
| `quickMarket.priceSource` | string | Price oracle source (e.g., `"pyth"`)                                                                            |
| `bestAskPrice`            | uint64 | Best YES ask from the live orderbook (6 decimals). `450000` = $0.45                                             |

### Response (No Active Market)

```json
{
  "active": false,
  "asset": "BTC",
  "nextMarket": null,
  "quickMarket": null
}
```

### Example

{% code title="curl" %}

```bash
curl "https://api.turbinefi.com/api/v1/quick-markets/BTC"
```

{% endcode %}

***

## Get Quick Market History

Returns recent quick markets for an asset.

```
GET /api/v1/quick-markets/{asset}/history
```

### Path Parameters

| Parameter | Type   | Description                |
| --------- | ------ | -------------------------- |
| `asset`   | string | Asset symbol (e.g., `BTC`) |

### Response

```json
{
  "asset": "BTC",
  "markets": [
    {
      "id": 42,
      "marketId": "0x...",
      "asset": "BTC",
      "startPrice": 9750000000000,
      "endPrice": 9760000000000,
      "startTime": 1735689000,
      "endTime": 1735689900,
      "resolved": true,
      "outcome": 0
    }
  ]
}
```

Returns up to 100 most recent quick markets.

| Field      | Type  | Description                                                                  |
| ---------- | ----- | ---------------------------------------------------------------------------- |
| `endPrice` | int64 | Price at expiration (null if not yet resolved)                               |
| `outcome`  | int   | `0` = YES (price went up), `1` = NO (price went down). Null if not resolved. |

### Example

{% code title="curl" %}

```bash
curl "https://api.turbinefi.com/api/v1/quick-markets/BTC/history"
```

{% endcode %}

***

## Get Current Price

Returns the current price for an asset from the Pyth oracle.

```
GET /api/v1/quick-markets/{asset}/price
```

### Path Parameters

| Parameter | Type   | Description                |
| --------- | ------ | -------------------------- |
| `asset`   | string | Asset symbol (e.g., `BTC`) |

### Response

```json
{
  "asset": "BTC",
  "price": 9760000000000,
  "priceUSD": 97600.0,
  "timestamp": 1735689000,
  "source": "https://pyth.network/..."
}
```

| Field       | Type    | Description           |
| ----------- | ------- | --------------------- |
| `price`     | int64   | Raw price from oracle |
| `priceUSD`  | float64 | Price in USD          |
| `timestamp` | int64   | Unix timestamp        |
| `source`    | string  | Oracle source URL     |

### Example

{% code title="curl" %}

```bash
curl "https://api.turbinefi.com/api/v1/quick-markets/BTC/price"
```

{% endcode %}

***

## Get Price History

Returns historical price data for chart rendering.

```
GET /api/v1/quick-markets/{asset}/price-history
```

### Path Parameters

| Parameter | Type   | Description                |
| --------- | ------ | -------------------------- |
| `asset`   | string | Asset symbol (e.g., `BTC`) |

### Response

```json
{
  "asset": "BTC",
  "history": [
    {
      "price": 9750000000000,
      "timestamp": 1735688000
    },
    {
      "price": 9755000000000,
      "timestamp": 1735688060
    }
  ]
}
```

Returns 20 minutes of price history.

### Example

{% code title="curl" %}

```bash
curl "https://api.turbinefi.com/api/v1/quick-markets/BTC/price-history"
```

{% endcode %}

***

## Price Stream (SSE)

Server-Sent Events stream of real-time price updates.

```
GET /api/v1/quick-markets/{asset}/price-stream
```

### Path Parameters

| Parameter | Type   | Description                |
| --------- | ------ | -------------------------- |
| `asset`   | string | Asset symbol (e.g., `BTC`) |

### Response Format

The response is a `text/event-stream` with JSON data events:

```
data: {"asset":"BTC","price":9760000000000,"priceUSD":97600.000000,"timestamp":1735689000000,"source":"pyth"}

data: {"asset":"BTC","price":9761000000000,"priceUSD":97610.000000,"timestamp":1735689001000,"source":"pyth"}
```

| Field       | Type    | Description                                          |
| ----------- | ------- | ---------------------------------------------------- |
| `asset`     | string  | Asset symbol                                         |
| `price`     | int64   | Raw price                                            |
| `priceUSD`  | float64 | Price in USD                                         |
| `timestamp` | int64   | Unix timestamp in milliseconds                       |
| `source`    | string  | Price source (`"pyth"`, `"coinbase"`, `"coingecko"`) |

An initial price is sent immediately upon connection. Subsequent updates stream as new prices arrive from the oracle.

### Examples

{% code title="curl (stream)" %}

```bash
curl -N "https://api.turbinefi.com/api/v1/quick-markets/BTC/price-stream"
```

{% endcode %}

{% code title="python (sseclient)" %}

```python
import sseclient
import requests

response = requests.get(
    "https://api.turbinefi.com/api/v1/quick-markets/BTC/price-stream",
    stream=True
)
client = sseclient.SSEClient(response)

for event in client.events():
    print(event.data)
```

{% endcode %}
