# Market overview

`GET /api/market`

The homepage's market over a window: totals against the window before, rows by volume, the dearest and the latest sales (each with seller and buyer). Covers sales on every marketplace the index knows. Cacheable 30 s. `pending` lists the latest sales still in the mempool, in no total.

#### Query parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `window` | string | no | The window. One of: `24h`, `7d`, `30d`, `90d`, `1y`, `all`. Default: `30d`. |
| `inscribed` | string | no | `1` counts inscribed sales too. One of: `0`, `1`. Default: `0`. |
| `outliers` | string | no | `1` counts statistical outliers too. One of: `0`, `1`. Default: `0`. |

#### Example request

```bash title="cURL"
curl 'https://raresats.net/api/market?window=30d'
```
```js title="JavaScript"
const response = await fetch('https://raresats.net/api/market?window=30d');
const data = await response.json();
```
```python title="Python"
import requests

data = requests.get("https://raresats.net/api/market", params={"window": "30d"}).json()
```

#### Response `200`

| Field | Type | Description |
| --- | --- | --- |
| `available` | boolean | Whether the sales index is available. |
| `generation` | integer | Sales generation (changes on a reorg). |
| `seq` | integer | The newest sale's sequence number. |
| `as_of` | object \| null | The block the sales are as of: `{height, time}`. |
| `window` | string | The window. One of: `24h`, `7d`, `30d`, `90d`, `1y`, `all`. |
| `inscribed` | boolean | Inscribed sales counted. |
| `outliers` | boolean | Outliers counted. |
| `since` | integer \| null | Window start, unix seconds (`null` for `all`). |
| `until` | integer \| null | Window end, unix seconds. |
| `totals` | object | The window's totals. |
| `totals.volume` | integer | Sats traded. |
| `totals.sales` | integer | Sales. |
| `totals.sats` | integer | Sats sold. |
| `previous` | object \| null | The window before's totals (`null` for `all`). |
| `rows` | array of object | Rows by volume, largest first. |
| `rows[].row` | string | Row id. |
| `rows[].volume` | integer | Sats traded. |
| `rows[].sales` | integer | Sales. |
| `rows[].sats` | integer | Sats sold. |
| `rows[].median_unit` | number \| null | Median unit price. |
| `rows[].last_time` | integer \| null | Last sale, unix seconds. |
| `rows[].last_unit` | number \| null | Last unit price. |
| `rows[].last_price` | integer \| null | Last price. |
| `rows[].prev_volume` | integer \| null | Volume in the window before. |
| `rows[].prev_sales` | integer \| null | Sales in the window before. |
| `top` | array of object | The window's dearest sales (up to 24). |
| `top[].seq` | integer | The sale's sequence number (for `/api/sales/parties` and `/api/sales/{seq}/tx`). |
| `top[].t` | integer | Sale time, unix seconds. |
| `top[].h` | integer | Block height. |
| `top[].row` | string | The sale's own row. |
| `top[].u` | number \| null | Unit price: premium per sat of the row. |
| `top[].c` | integer | Sats of the row sold. |
| `top[].p` | integer \| null | Price in sats. |
| `top[].n` | integer | Tracked sats the sale sold. |
| `top[].s` | integer \| null | The first special sat sold. |
| `top[].sh` | integer \| null | The block that mined it. |
| `top[].sd` | integer \| null | The day it was mined (UTC days since 1970). |
| `top[].m` | string | Marketplace id (`magisat`, `magic_eden`, `unknown`, …). |
| `top[].x` | string \| null | The txid's first 8 and last 4 hex digits. |
| `top[].ins` | boolean | An inscription was on a sold sat. |
| `top[].out` | boolean | A statistical outlier. |
| `top[].secondary` | map of integer | A sale's secondary rows: the market rows of the other sats it sold (not its own row, a row it is a sub-category of, or a label row), each with its sats, primary-first: `{"black_omega": 1}` for a black omega sold with an alpha uncommon; `{}` for none. A sale never counts in its secondary rows' markets (the primary-sat rule, in Concepts). |
| `top[].seller` | string \| null | The seller's address. |
| `top[].buyer` | string \| null | The buyer's address. |
| `latest` | array of object | The latest sales (up to 10). |
| `latest[].seq` | integer | The sale's sequence number (for `/api/sales/parties` and `/api/sales/{seq}/tx`). |
| `latest[].t` | integer | Sale time, unix seconds. |
| `latest[].h` | integer | Block height. |
| `latest[].row` | string | The sale's own row. |
| `latest[].u` | number \| null | Unit price: premium per sat of the row. |
| `latest[].c` | integer | Sats of the row sold. |
| `latest[].p` | integer \| null | Price in sats. |
| `latest[].n` | integer | Tracked sats the sale sold. |
| `latest[].s` | integer \| null | The first special sat sold. |
| `latest[].sh` | integer \| null | The block that mined it. |
| `latest[].sd` | integer \| null | The day it was mined (UTC days since 1970). |
| `latest[].m` | string | Marketplace id (`magisat`, `magic_eden`, `unknown`, …). |
| `latest[].x` | string \| null | The txid's first 8 and last 4 hex digits. |
| `latest[].ins` | boolean | An inscription was on a sold sat. |
| `latest[].out` | boolean | A statistical outlier. |
| `latest[].secondary` | map of integer | A sale's secondary rows: the market rows of the other sats it sold (not its own row, a row it is a sub-category of, or a label row), each with its sats, primary-first: `{"black_omega": 1}` for a black omega sold with an alpha uncommon; `{}` for none. A sale never counts in its secondary rows' markets (the primary-sat rule, in Concepts). |
| `latest[].seller` | string \| null | The seller's address. |
| `latest[].buyer` | string \| null | The buyer's address. |
| `error` | string \| null | The sales index's last error, if any. |
| `pending` | array of object | The latest sales still in the mempool (at most 10), newest first: beside `latest`, in no total, row or top. |
| `pending[].seq` | null | No sequence number until it confirms. |
| `pending[].t` | integer \| null | `first_seen`: sorted by time, it leads the confirmed sales. |
| `pending[].h` | null | No block yet. |
| `pending[].row` | string | The sale's own row. |
| `pending[].u` | number \| null | Unit price: premium per sat of the row. |
| `pending[].c` | integer | Sats of the row sold. |
| `pending[].p` | integer \| null | Price in sats. |
| `pending[].n` | integer | Tracked sats the sale sold. |
| `pending[].s` | integer \| null | The first special sat sold. |
| `pending[].sh` | integer \| null | The block that mined it. |
| `pending[].sd` | integer \| null | The day it was mined (UTC days since 1970). |
| `pending[].m` | string | Marketplace id (`magisat`, `magic_eden`, `unknown`, …). |
| `pending[].x` | string \| null | The txid's first 8 and last 4 hex digits. |
| `pending[].ins` | boolean | An inscription was on a sold sat. |
| `pending[].out` | boolean | Always false: a pending sale is judged by no median. |
| `pending[].secondary` | map of integer | A sale's secondary rows: the market rows of the other sats it sold (not its own row, a row it is a sub-category of, or a label row), each with its sats, primary-first: `{"black_omega": 1}` for a black omega sold with an alpha uncommon; `{}` for none. A sale never counts in its secondary rows' markets (the primary-sat rule, in Concepts). |
| `pending[].seller` | string \| null | The seller's address. |
| `pending[].buyer` | string \| null | The buyer's address. |
| `pending[].key` | string | `txid:vin`: its identity. The confirmed sale has the same txid and vin and replaces it. |
| `pending[].pending` | `true` | Always true: the sale is still in the mempool. |
| `pending[].first_seen` | integer \| null | When the transaction was first seen in the mempool (bitcoind's entry time), unix seconds. |
| `pending[].fee_rate` | number \| null | Its fee rate, sat/vB (one decimal). |
| `pending[].txid` | string | The sale transaction, whole. |
| `pending[].vin` | integer \| null | The seller's input. |
| `pending[].seller_outpoint` | string \| null | The output it sells. |
| `pending[].buyer_outpoint` | string \| null | The output the sold sats go to. |
| `pending[].rows` | array of string | Its own row, then the rows of which it is a rarer sub-category. |
| `pending[].led_rows` | array of string | The rows of its other sats (it is led by `row` there). |
| `pending[].labels` | array of string | The label rows it lies in. |
| `pending[].kind` | string \| null | The fork's sale kind (`listing`, `offer`, …). |

#### Errors

`{error}` (a message, no code):

| Status | When |
| --- | --- |
| 400 | An unknown window, or a flag that is not 0 or 1. |

Each sale counts once, as its own row, so the rows add up to the totals: a bundle counts under its primary row only, and names the rest of what it sold in `secondary` (`{"black_omega": 1}`). Inscribed sales and statistical outliers are left out unless asked for. `previous` and the rows' `prev_*` fields compare with the window before.

`pending` lists the latest sales still in the mempool (at most 10, newest first, marked `pending: true` with `first_seen` and `fee_rate`). They count in no total, row, top list or `latest` until they confirm.
