> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solya.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe — read data

> List the catalog with pagination, search, and read inventory stock-out risks.

All examples assume the setup from [API recipes](/en/developers/recipes/overview) (base URL,
bearer token).

## List brands (page-based pagination)

`GET /api/brands` takes `page`, `pageSize`, and an optional `q` search; it returns the
`{ data, total, page, pageSize }` envelope.

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl "https://app.solya.app/api/brands?page=1&pageSize=20&q=adi" \
      -H "Authorization: Bearer solya_sa_xxx"
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests
    BASE, TOKEN = "https://app.solya.app", "solya_sa_xxx"
    headers = {"Authorization": f"Bearer {TOKEN}"}

    def list_brands(page=1, page_size=20, q=None):
        params = {"page": page, "pageSize": page_size}
        if q: params["q"] = q
        r = requests.get(f"{BASE}/api/brands", headers=headers, params=params)
        r.raise_for_status()
        return r.json()  # { data, total, page, pageSize }

    first = list_brands(q="adi")
    print(first["total"], len(first["data"]))
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const BASE = "https://app.solya.app", TOKEN = "solya_sa_xxx"
    const headers = { Authorization: `Bearer ${TOKEN}` }

    async function listBrands({ page = 1, pageSize = 20, q } = {}) {
      const url = new URL(`${BASE}/api/brands`)
      url.searchParams.set("page", page)
      url.searchParams.set("pageSize", pageSize)
      if (q) url.searchParams.set("q", q)
      const res = await fetch(url, { headers })
      if (!res.ok) throw new Error(`brands failed: ${res.status}`)
      return res.json() // { data, total, page, pageSize }
    }
    ```
  </Tab>
</Tabs>

Example response:

```json theme={null}
{
  "data": [
    { "id": "brand-uuid-adidas", "name": "Adidas", "code": "ADI", "isActive": true }
  ],
  "total": 1, "page": 1, "pageSize": 20
}
```

### Paginate through everything

```python theme={null}
def all_brands():
    page, out = 1, []
    while True:
        res = list_brands(page=page, page_size=100)
        out.extend(res["data"])
        if page * res["pageSize"] >= res["total"]:
            break
        page += 1
    return out
```

<Note>
  Some endpoints (mostly under `/api/data-platform/`) use **offset-based** pagination
  (`limit` / `offset`) and return `{ items, limit, offset }`. Check the endpoint in the
  **API Reference** tab. See [Making requests](/en/developers/making-requests).
</Note>

## Read inventory stock-out risks

`GET /api/inventory/risks` returns variants ranked by urgency, filterable by `status`,
`brandIds`, `shopIds`, and `period`.

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl "https://app.solya.app/api/inventory/risks?status=critical&pageSize=50" \
      -H "Authorization: Bearer solya_sa_xxx"
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    r = requests.get(
        f"{BASE}/api/inventory/risks",
        headers=headers,
        params={"status": "critical", "pageSize": 50},
    )
    r.raise_for_status()
    for row in r.json()["data"]:
        print(row["rank"], row["variantName"], row["daysOfSupply"], row["status"])
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const url = new URL(`${BASE}/api/inventory/risks`)
    url.searchParams.set("status", "critical")
    url.searchParams.set("pageSize", "50")
    const res = await fetch(url, { headers })
    const { data } = await res.json()
    data.forEach(r => console.log(r.rank, r.variantName, r.daysOfSupply, r.status))
    ```
  </Tab>
</Tabs>

Each row includes `variantId`, `variantName`, `brandName`, `closingStock`,
`avgDailySales`, `daysOfSupply`, and `status` (`critical` / `warning` / `healthy`). See the
[stock-out risk guide](/en/inventory-risks/stock-out-risk). To act on a critical row, turn
it into a plan — next recipe.
