# Get activity

`GET /api/market/activity`

Recent marketplace events, newest first: listed, cancelled and sold. Sales on other marketplaces are in `/api/sales`.

#### Query parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `row` | string | no | Only events of listings and offers under this row: its own, its sub-categories' and label's, and those holding some of its sats in a bundle (marked `sub` or `in_bundle`). |
| `limit` | integer | no | Events, 1-200. Default: `50`. (min 1, max 200) |
| `types` | string | no | Comma-separated event types: `listed`, `cancelled`, `sold` (the default: those three), `offer_made`, `offer_cancelled`, `offer_accepted`. |

#### Example request

```bash title="cURL"
curl 'https://raresats.net/api/market/activity?row=black_rare&limit=1&types=sold,offer_accepted'
```
```js title="JavaScript"
const response = await fetch('https://raresats.net/api/market/activity?row=black_rare&limit=1&types=sold,offer_accepted');
const data = await response.json();
```
```python title="Python"
import requests

data = requests.get("https://raresats.net/api/market/activity", params={"row": "black_rare", "limit": 1, "types": "sold,offer_accepted"}).json()
```

#### Response `200`

| Field | Type | Description |
| --- | --- | --- |
| `events` | array of object | Newest first. |
| `events[].seq` | integer | Event sequence number (rising). |
| `events[].type` | string | What happened: a listing's `listed`, `cancelled`, `sold`; an offer's `offer_made`, `offer_cancelled`, `offer_accepted` (only when asked for with `types`). |
| `events[].listing_id` | string \| null | The listing; on an offer event, the UTXO's live listing then, or `null`. |
| `events[].outpoint` | string | The listed UTXO. |
| `events[].row` | string | The listing's own row. |
| `events[].count` | integer | Sats of that row. |
| `events[].price` | integer | The listing price in sats (an offer's price on an offer event). |
| `events[].unit_price` | number | The listing's unit price. |
| `events[].seller_address` | string | The seller (same as `seller`). |
| `events[].txid` | string \| null | The purchase (or accepting) transaction of a `sold` or `offer_accepted` event; `null` otherwise. |
| `events[].time` | integer | Unix seconds. |
| `events[].seller` | string \| null | The seller's address. |
| `events[].buyer` | string \| null | A sale's buyer (or an accepted offer's bidder): the address the sats went to. `null` for other events, or when unknown. |
| `events[].affiliate` | string \| null | A sale bought here with an applied referral: the affiliate it paid. `null` otherwise. |
| `events[].offer_id` | string \| null | The offer, on an offer event; `null` otherwise. |
| `events[].bidder` | string \| null | The bidder's payment address, on an offer event; `null` otherwise. |
| `events[].sub` | boolean | Only on an event read for a row (`row=`) that is not its own row but holds every tracked sat of the item (a sub-category or a label row): `true`. |
| `events[].in_bundle` | boolean | Only on an event read for a row (`row=`) whose listing or offer holds some sats of that row among others (in bundle, e.g. a Block 9 chunk under `block9_palindrome`): `true`. Its price and unit price are those of its own `row`. |
| `events[].contains_count` | integer \| null | With `in_bundle`: how many sats of the row asked for the item holds. |

```json title="Response"
{
  "events": [
    {
      "seq": 3,
      "type": "sold",
      "listing_id": "1031931af1592e1c",
      "outpoint": "2fb6fb60ece3672924a373d7479d144d9ce4d3591185bfb5a00e62aedd53d3a9:0",
      "row": "black_rare",
      "count": 1,
      "price": 60546,
      "unit_price": 60000,
      "seller_address": "bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu",
      "txid": "6897451c42f02de2594abfdd6a5d4fcf4794a62cbbd9fbec1ec983893ddc5df4",
      "time": 1790952985,
      "seller": "bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu",
      "buyer": "bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr",
      "affiliate": "bc1p4qhjn9zdvkux4e44uhx8tc55attvtyu358kutcqkudyccelu0was9fqzwh",
      "offer_id": null,
      "bidder": null
    }
  ]
}
```

#### Errors

`{error, code}`; see [Errors](https://raresats.net/docs/errors.md) for every code.

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | `bad_paging` | `limit` or `offset` out of range. |
| 400 | `bad_row` | `row` is not a row id. |
| 400 | `bad_types` | `types` is not a comma-separated list of activity event types. |
| 404 | `retired_row` | `row` is a row the site retired (`uncommon_2009`, `rare_2009`): its listings are its parent row's. `retired` names the row and the parent and years to ask for. |

```json title="Error (404)"
{
  "error": "row uncommon_2009 is retired: ask for row uncommon with years 2009",
  "code": "retired_row",
  "retired": {"row": "uncommon_2009", "successor": {"row": "uncommon", "years": [2009]}}
}
```

Events are this marketplace's only. With `row`, they are the events of every listing and offer under the row: its own, its sub-categories' and label's (marked `sub: true`), and those holding some of its sats in a bundle (marked `in_bundle: true`, with `contains_count`; their price and unit price are their own row's). A `sold` event names the buyer when known (the purchase's ordinals address, else the buyer the sales index found for that transaction). For sales on every marketplace, use [Sales](https://raresats.net/docs/get-sales.md) or the [market overview](https://raresats.net/docs/get-market.md).

A purchase made here shows as a `pending` event while its transaction waits in the mempool. The index sees the same transaction as a pending sale (`pending` in [Sales](https://raresats.net/docs/get-sales.md), keyed `txid:vin`); the site lists it once, as the index's pending sale.
