# API Details - Product
###### tags: `API Details`
#### 取得所有商品
Response Example
```json
{
"ok": 1,
"data": [
{
"id": 4,
"vendorId": 1,
"name": "糖果",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/AHI6TSf.png",
"price": 262,
"quantity": 300,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-12-31T16:00:00.000Z",
"description": "甜甜的會讓小朋友蛀牙",
"isAvailable": true,
"createdAt": "2021-10-01T11:59:16.000Z",
"updatedAt": "2021-10-01T11:59:16.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
},
{
"id": 3,
"vendorId": 1,
"name": "小玉西瓜",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/mHWygJg.png",
"price": 2,
"quantity": 390,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-10-30T16:00:00.000Z",
"description": "小玉水水西瓜",
"isAvailable": true,
"createdAt": "2021-10-01T11:59:07.000Z",
"updatedAt": "2021-10-01T12:06:30.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
},
{
"id": 2,
"vendorId": 1,
"name": "法國麵包",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/UqorRbJ.png",
"price": 262,
"quantity": 290,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-12-31T16:00:00.000Z",
"description": "硬梆梆的",
"isAvailable": true,
"createdAt": "2021-10-01T11:58:57.000Z",
"updatedAt": "2021-10-03T04:15:31.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
},
{
"id": 1,
"vendorId": 1,
"name": "義大利麵",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/ptpIhC0.png",
"price": 0,
"quantity": 2004,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-12-31T16:00:00.000Z",
"description": "美味",
"isAvailable": true,
"createdAt": "2021-09-29T15:35:49.000Z",
"updatedAt": "2021-10-01T08:25:44.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
}
]
}
```
#### 取得該分類商品
Response Example
```json
{
"ok": 1,
"data": [
{
"id": 4,
"vendorId": 1,
"name": "糖果",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/AHI6TSf.png",
"price": 262,
"quantity": 300,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-12-31T16:00:00.000Z",
"description": "甜甜的會讓小朋友蛀牙",
"isAvailable": true,
"createdAt": "2021-10-01T11:59:16.000Z",
"updatedAt": "2021-10-01T11:59:16.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
},
{
"id": 3,
"vendorId": 1,
"name": "小玉西瓜",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/mHWygJg.png",
"price": 2,
"quantity": 390,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-10-30T16:00:00.000Z",
"description": "小玉水水西瓜",
"isAvailable": true,
"createdAt": "2021-10-01T11:59:07.000Z",
"updatedAt": "2021-10-01T12:06:30.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
},
]
}
```
#### 取得賣家商品
Response Example
```json
{
"ok": 1,
"data": [
{
"id": 2,
"vendorId": 1,
"name": "法國麵包",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/UqorRbJ.png",
"price": 262,
"quantity": 290,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-12-31T16:00:00.000Z",
"description": "硬梆梆的",
"isAvailable": true,
"createdAt": "2021-10-01T11:58:57.000Z",
"updatedAt": "2021-10-03T04:15:31.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
},
{
"id": 1,
"vendorId": 1,
"name": "義大利麵",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/ptpIhC0.png",
"price": 0,
"quantity": 2004,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-12-31T16:00:00.000Z",
"description": "美味",
"isAvailable": true,
"createdAt": "2021-09-29T15:35:49.000Z",
"updatedAt": "2021-10-01T08:25:44.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
}
]
}
```
#### 搜尋已通過商品
Request Example
```json
{
"keyword": "短",
}
```
Response Example
```json
{
"ok": 1,
"data": [
{
"id": 4,
"vendorId": 1,
"name": "糖果",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/AHI6TSf.png",
"price": 262,
"quantity": 300,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-12-31T16:00:00.000Z",
"description": "甜甜的會讓小朋友蛀牙",
"isAvailable": true,
"createdAt": "2021-10-01T11:59:16.000Z",
"updatedAt": "2021-10-01T11:59:16.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
},
{
"id": 3,
"vendorId": 1,
"name": "小玉西瓜",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/mHWygJg.png",
"price": 2,
"quantity": 390,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-10-30T16:00:00.000Z",
"description": "小玉水水西瓜",
"isAvailable": true,
"createdAt": "2021-10-01T11:59:07.000Z",
"updatedAt": "2021-10-01T12:06:30.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
},
]
}
```
#### 取得單ㄧ商品詳細資料
Response Example
```json
{
"ok": 1,
"data": {
"id": 3,
"vendorId": 1,
"name": "蘋果",
"categoryId": 1,
"pictureUrl": "https://i.imgur.com/mHWygJg.png",
"price": 2,
"quantity": 390,
"manufactureDate": "2021-08-31T16:00:00.000Z",
"expiryDate": "2021-10-30T16:00:00.000Z",
"description": "又紅又大",
"isAvailable": true,
"createdAt": "2021-10-01T11:59:07.000Z",
"updatedAt": "2021-10-01T12:06:30.000Z",
"ProductCategory": null,
"Vendor": {
"vendorName": "storeA",
"avatarUrl": "https://i.imgur.com/cIQdirA.png",
"categoryId": 0
}
}
}
```
#### 新增商品
Request Example
```formdata
{
"name": "花椰菜"
"categoryId": 2
"price": 20
"quantity": 1
"manufatureDate": "2021-10-30T16:00:00.000Z"
"expiryDate": "2021-10-30T16:00:00.000Z"
"description": "讚讚"
"isAvailable": true
"picture": file
}
```
Response Example
```json
{
"ok": 1,
"message": "Success",
"data": {
"productId": 10
}
}
```
#### 編輯商品
Request Example
```formdata
{
"name": "花椰菜"
"categoryId": 2
"price": 20
"quantity": 1
"manufatureDate": "2021-10-30T16:00:00.000Z"
"expiryDate": "2021-10-30T16:00:00.000Z"
"description": "讚讚"
"isAvailable": true
"picture": file
}
```
Response Example
```json
//成功
{
"ok": 1,
"message": "Success",
"data": {
"productId": 8
}
}
```
#### 刪除商品
Response Example
```json
{
"ok": 1,
"message": "Success"
}
```
#### 取得購物車商品資料
Request Example
```json
{"cart":[
{"id": 5, "quantity": 3},
{"id": 155, "quantity": 3}
]}
```
Response Example
```json
{
"ok": 1,
"data": {
"25": [
{
"id": 155,
"vendorId": 25,
"name": "咖哩麵包",
"categoryId": 55,
"pictureUrl": "https://i.imgur.com/xJjOXxA.jpg",
"price": 10,
"quantity": 98,
"manufactureDate": null,
"expiryDate": null,
"description": "香噴噴剛出爐麵包",
"isAvailable": true,
"createdAt": "2021-10-20T07:11:51.000Z",
"updatedAt": "2021-10-20T07:23:24.000Z",
"ProductCategory": {
"id": 55,
"name": "烘焙麵點"
},
"Vendor": {
"id": 25,
"vendorName": "麵包店",
"avatarUrl": null,
"categoryId": 1
},
"cartQuantity": 3
}
],
"55": [
{
"id": 5,
"vendorId": 55,
"name": "花椰菜++++++++++++++++++++++++++++++++",
"categoryId": 35,
"pictureUrl": "https://i.imgur.com/gf4a6FD.jpg",
"price": 20,
"quantity": 449,
"manufactureDate": "2021-10-30T00:00:00.000Z",
"expiryDate": "2021-11-30T00:00:00.000Z",
"description": "白的花椰菜,又稱花菜、椰菜花,是一種常見的蔬菜,是甘藍的變種。花椰菜的頭部為白色或綠色花序,與青花菜的頭部類似。花椰菜富含維生素B群、C,這些成分屬於水溶性,易受熱溶出而流失,所以煮花椰菜不宜高溫烹調,也不適合水煮。雖然花椰菜與青花菜都是食用它們的花球,但其植物學結構有所不同:花椰菜是未分化的組織,即花原基(floral primordia),為重複分枝的肉質組織;青花菜則是已分化的花蕾球,但尚未開花。",
"isAvailable": true,
"createdAt": "2021-10-08T12:58:39.000Z",
"updatedAt": "2021-10-18T13:05:32.000Z",
"ProductCategory": {
"id": 35,
"name": "飲品"
},
"Vendor": {
"id": 55,
"vendorName": "小地方雜貨鋪",
"avatarUrl": "https://i.imgur.com/wYpKFOc.png",
"categoryId": 15
},
"cartQuantity": 3
}
]
}
}
```