# Products and orders (/docs/payments/products-and-orders)

Your products and orders live in Swop. With a key that has **`commerce.read`** you can pull both into your own systems.

## Products [#products]

A product is anything you sell: a physical item, a digital download, a ticket. You create and edit products in the Swop app. Each one has an `_id`, which is what you send as `productId` when you create a checkout.

```bash tab="curl"
curl "https://apps.apiswop.co/api/v5/merchant/products?limit=20&page=1" \
  -H "Authorization: Bearer $SWOP_MERCHANT_KEY"
```

```js tab="Node"
const res = await fetch('https://apps.apiswop.co/api/v5/merchant/products?limit=20&page=1', {
  headers: { Authorization: `Bearer ${process.env.SWOP_MERCHANT_KEY}` },
});
const { data } = await res.json(); // { items, total, page, limit }
```

```python tab="Python"
import os, requests

r = requests.get(
    "https://apps.apiswop.co/api/v5/merchant/products",
    params={"limit": 20, "page": 1},
    headers={"Authorization": f"Bearer {os.environ['SWOP_MERCHANT_KEY']}"},
)
data = r.json()["data"]  # items, total, page, limit
```

Products are paged by `page` and `limit` (default 50, up to 200). Add `status=archived` to list archived products instead of live ones. Full shape in the [products reference](/docs/api-reference/products).

## Orders [#orders]

An order is created automatically when a checkout is paid. `GET /orders` returns **your sales only**, newest first, without the buyer's identity: it's built for your dashboard and accounting, not your customer list.

```bash tab="curl"
curl "https://apps.apiswop.co/api/v5/merchant/orders?limit=25" \
  -H "Authorization: Bearer $SWOP_MERCHANT_KEY"
```

```js tab="Node"
// Page through every order with the cursor.
async function* allOrders() {
  let before = null;
  do {
    const url = new URL('https://apps.apiswop.co/api/v5/merchant/orders');
    url.searchParams.set('limit', '100');
    if (before) url.searchParams.set('before', before);
    const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.SWOP_MERCHANT_KEY}` } });
    const { data } = await res.json();
    yield* data.orders;
    before = data.nextBefore;
  } while (before);
}
```

```python tab="Python"
import os, requests

def all_orders():
    before = None
    while True:
        params = {"limit": 100}
        if before:
            params["before"] = before
        r = requests.get(
            "https://apps.apiswop.co/api/v5/merchant/orders",
            params=params,
            headers={"Authorization": f"Bearer {os.environ['SWOP_MERCHANT_KEY']}"},
        )
        data = r.json()["data"]
        yield from data["orders"]
        before = data["nextBefore"]
        if not before:
            break
```

Orders use a **cursor**, not page numbers, because new orders arrive at the top. Pass the `nextBefore` value from one response as `before` in the next. When `nextBefore` is `null`, you've reached the end.

<Callout title="Where's the buyer's name and address?">
`GET /orders` deliberately leaves out buyer identity. To ship, use the [`checkout.paid`](/docs/webhooks/events) webhook, which carries the buyer's name, email, phone and shipping address for that order.
</Callout>

{/* TODO(review): webhooks carry buyer PII while GET /orders withholds it by design. Confirm this split is intended before launch. */}
