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

# Categories

> Browse store categories and their products.

## GET /categories

List all active categories for the store, ordered by sort index.

### Authentication

None required.

### Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://front.rmz.gg/api/categories"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://front.rmz.gg/api/categories");
  const data = await response.json();
  ```

  ```python Python theme={null}
  response = requests.get("https://front.rmz.gg/api/categories")
  data = response.json()
  ```

  ```php PHP theme={null}
  $response = Http::get("https://front.rmz.gg/api/categories");
  $data = $response->json();
  ```
</CodeGroup>

### Response

#### Success (200)

```json theme={null}
{
  "success": true,
  "data": [
    {
      "id": 1,
      "name": "Games",
      "slug": "games",
      "description": null,
      "image": null,
      "icon": null,
      "is_active": true,
      "sort_order": 0,
      "products_count": 24,
      "created_at": "2024-01-01T00:00:00.000000Z",
      "updated_at": "2024-06-15T10:30:00.000000Z"
    },
    {
      "id": 2,
      "name": "Software",
      "slug": "software",
      "description": null,
      "image": null,
      "icon": null,
      "is_active": true,
      "sort_order": 1,
      "products_count": 12,
      "created_at": "2024-01-01T00:00:00.000000Z",
      "updated_at": "2024-06-15T10:30:00.000000Z"
    }
  ]
}
```

***

## GET /categories/{slug}

Get a single category by slug, including product count from child categories.

### Authentication

None required.

### Path Parameters

| Parameter | Type   | Description       |
| --------- | ------ | ----------------- |
| slug      | string | Category URL slug |

### Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://front.rmz.gg/api/categories/games"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://front.rmz.gg/api/categories/games");
  const data = await response.json();
  ```

  ```python Python theme={null}
  response = requests.get("https://front.rmz.gg/api/categories/games")
  data = response.json()
  ```

  ```php PHP theme={null}
  $response = Http::get("https://front.rmz.gg/api/categories/games");
  $data = $response->json();
  ```
</CodeGroup>

### Response

#### Success (200)

```json theme={null}
{
  "success": true,
  "data": {
    "id": 1,
    "name": "Games",
    "slug": "games",
    "description": null,
    "image": null,
    "icon": null,
    "is_active": true,
    "sort_order": 0,
    "products_count": 36,
    "created_at": "2024-01-01T00:00:00.000000Z",
    "updated_at": "2024-06-15T10:30:00.000000Z"
  }
}
```

<Note>
  The `products_count` includes products from both the parent category and all its active child categories.
</Note>

#### Error Responses

| Status | Description                    |
| ------ | ------------------------------ |
| 404    | Category not found or inactive |

***

## GET /categories/{slug}/products

Get products within a category. Includes products from child categories of the specified parent.

### Authentication

None required.

### Path Parameters

| Parameter | Type   | Description       |
| --------- | ------ | ----------------- |
| slug      | string | Category URL slug |

### Query Parameters

| Parameter  | Type    | Required | Description                                                                                                          |
| ---------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| search     | string  | No       | Search within category products (max 255 chars)                                                                      |
| sort       | string  | No       | Sort order: `price_asc`, `price_desc`, `name_asc`, `name_desc`, `created_asc`, `created_desc`. Default: newest first |
| per\_page  | integer | No       | Items per page (1-50). Default: `19`                                                                                 |
| type       | string  | No       | Filter by type: `digital`, `subscription`, `course`                                                                  |
| price\_min | number  | No       | Minimum price filter                                                                                                 |
| price\_max | number  | No       | Maximum price filter                                                                                                 |
| in\_stock  | boolean | No       | Filter to only in-stock products                                                                                     |

### Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://front.rmz.gg/api/categories/games/products?sort=price_asc&per_page=12"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://front.rmz.gg/api/categories/games/products?sort=price_asc&per_page=12");
  const data = await response.json();
  ```

  ```python Python theme={null}
  response = requests.get("https://front.rmz.gg/api/categories/games/products", params={
      "sort": "price_asc",
      "per_page": 12
  })
  data = response.json()
  ```

  ```php PHP theme={null}
  $response = Http::get("https://front.rmz.gg/api/categories/games/products", [
      "sort" => "price_asc",
      "per_page" => 12
  ]);
  $data = $response->json();
  ```
</CodeGroup>

### Response

#### Success (200)

Products use the same `ProductResource` structure as `GET /products`. See [List Products](/storefront-api/products/list-products) for the full response schema.

```json theme={null}
{
  "success": true,
  "data": [
    {
      "id": 101,
      "name": "Premium Game Key",
      "marketing_title": null,
      "slug": "premium-game-key",
      "description": "Premium game activation key for PC",
      "short_description": "Premium game activation key for PC...",
      "type": "code",
      "status": 1,
      "is_featured": false,
      "is_noticeable": false,
      "is_new": false,
      "is_discounted": false,
      "is_discount_expired": false,
      "show_reviews": true,
      "price": {
        "original": 199.99,
        "actual": 199.99,
        "discount": null,
        "discount_expiry": null,
        "show_discount_countdown": false,
        "show_discount_savings": false,
        "savings_amount": 0,
        "formatted": "199.99 ر.س",
        "formatted_original": "199.99 ر.س",
        "discount_percentage": 0,
        "currency": "SAR"
      },
      "stock": {
        "available": 50,
        "unlimited": false,
        "min_qty": 1,
        "codes_count": 50,
        "is_in_stock": true
      },
      "sales": {
        "badge": null
      },
      "image": {
        "id": 1,
        "url": "https://...",
        "full_link": "https://...",
        "path": "...",
        "filename": "image.webp",
        "alt_text": "Premium Game Key"
      },
      "categories": [],
      "fields": null,
      "meta": null,
      "metadata": null,
      "tags": null,
      "seo": {
        "meta_title": null,
        "meta_description": null,
        "meta_keywords": null
      },
      "created_at": "2024-06-15T10:30:00.000000Z",
      "updated_at": "2024-06-15T10:30:00.000000Z"
    }
  ],
  "pagination": {
    "current_page": 1,
    "last_page": 3,
    "per_page": 19,
    "total": 36,
    "from": 1,
    "to": 19,
    "has_more_pages": true,
    "next_page_url": "...",
    "prev_page_url": null
  }
}
```

#### Error Responses

| Status | Description                          |
| ------ | ------------------------------------ |
| 404    | Category not found or inactive       |
| 422    | Validation error on query parameters |
