# Danh mục sản phẩm

* API này dùng để lấy [danh mục sản phẩm](https://nhanh.vn/product/category/index).
* Danh mục sản phẩm thường rất ít khi bị thay đổi, bạn có thể lấy dữ liệu và cache khoảng 24h (và có chức năng để user có thể xóa cache, để lấy dữ liệu mới nhất khi cần) giúp giảm tải việc gọi API.

## Request

* Xem [common request params](https://apidocs.nhanh.vn/v3/readme#request-params).
* Xem [Postman sample](https://www.postman.com/nhanh-vn/pos-open-nhanh-vn/request/svrw042/product-category).

```curl
curl --location 'https://pos.open.nhanh.vn/v3.0/product/category?appId={{appId}}&businessId={{businessId}}' \
--header 'Authorization: {{accessToken}}' \
--header 'Content-Type: application/json'
--data '{
    "filters": {
        "status": 1
    },
    "paginator": {
        "size": 50
    }
}'
```

### Filters

| Key    | Type   | Description                                             |
| ------ | ------ | ------------------------------------------------------- |
| ids    | array  | Mảng ID danh mục, tối đa 100                            |
| name   | string | Tên danh mục                                            |
| code   | string | Mã danh mục                                             |
| status | int    | <p>Trạng thái danh mục (1 = Active<br>2 = Inactive)</p> |

## Response

* Xem cấu trúc chung [tại đây](https://apidocs.nhanh.vn/v3/readme#response).

### Failed response

* Xem các mã lỗi chung [tại đây](https://apidocs.nhanh.vn/v3/readme#failed-response).

### Successful response

```json
{
  "code": 1,
  "paginator": {
    "next": "Dùng để lấy dữ liệu trang tiếp theo"
  },
  "data": [
    {
      "id": "(int) ID danh mục 1",
      "parentId": "(int) ID danh mục cha 1",
      "code": "(string) Mã danh mục 1",
      "name": "(string) Tên danh mục 1",
      "order": "(int) Thứ tự",
      "image": "(string) Đường dẫn ảnh danh mục",
      "content": "(string) Nội dung",
      "status": "(int) Trạng thái: 1 = Active, 2 = Inactive"
    },
   {
      "id": "(int) ID danh mục 2",
      "parentId": "(int) ID danh mục cha 2",
      "code": "(string) Mã danh mục 2",
      "name": "(string) Tên danh mục 2",
      "order": "(int) Thứ tự",
      "image": "(string) Đường dẫn ảnh danh mục",
      "content": "(string) Nội dung",
      "status": "(int) Trạng thái: 1 = Active, 2 = Inactive"
    }
  ]
}
```
