---
# System prepended metadata

title: API Details - Vendor
tags: [API Details]

---

# API Details - Vendor
###### tags: `API Details`

## 註冊賣家

### Request Example

FormData:
```formdata
{
    "vendorName": "example",
    "username": "iammike",
    "address": "台北市中正區重慶南路一段122號",
    "latlng": "{lat: 24.1978414, lng:120.6570637}" // JSON 格式
    "phone": "091111111",
    "openingHour": "[{monday: {start: 0900, end: 2100}}, {tuesday: {start: 1000, end: 2000}}, ...]"
    "avatar": <file>,
    "banner": <file>,
}
```

### Response Example
```json
{   
    "ok": 1,
    "token": "abcdefghij...."
}
```

## 取得自己的賣家資料

### Response Example
```json
{
    "ok": 1,
    "data": {
        "id": 65,
        "userId": 195,
        "vendorName": "好新鮮蔬菜店喔喔喔",
        "address": "台中市西屯區中清路二段",
        "position": {
            "type": "Point",
            "coordinates": [
                24.1978414,
                120.6570637
            ]
        },
        "phone": "0944555666",
        "avatarUrl": "https://i.imgur.com/123.png",
        "bannerUrl": "",
        "categoryId": 15,
        "description": "好新鮮的水果！",
        "openingHour": "{\"Monday\":{\"isOpen\":0,\"start\":\"\",\"end\":\"\"},\"Tuesday\":{\"isOpen\":1,\"start\":\"06:00\",\"end\":\"17:00\"},\"Wednesday\":{\"isOpen\":0,\"start\":\"\",\"end\":\"\"},\"Thursday\":{\"isOpen\":1,\"start\":\"08:00\",\"end\":\"18:00\"},\"Friday\":{\"isOpen\":1,\"start\":\"08:00\",\"end\":\"17:00\"},\"Saturday\":{\"isOpen\":1,\"start\":\"09:00\",\"end\":\"18:00\"},\"Sunday\":{\"isOpen\":0,\"start\":\"\",\"end\":\"\"}}",
        "isOpen": true,
        "isSuspended": false,
        "createdAt": "2021-10-11T06:44:37.000Z",
        "updatedAt": "2021-11-02T11:09:21.000Z",
        "VendorCategory": {
            "name": "蔬菜"
        }
    }
}
```

## 修改自己的賣家資料

### Request Example

FormData: 
```formData
{
    "vendorName": "example",
    "address": "台北市中正區重慶南路一段122號",
    "latlng": "{lat: 24.1978414, lng:120.6570637}", // JSON 格式
    openingHour": "[{monday: {start: 0900, end: 2100}}, {tuesday: {start: 1000, end: 2000}}, ...]",  // JSON 格式
    "phone": "091111111",
    "avatar": <file>,
    "banner": <file>,
}
```

### Response  Example
```json
{
    "ok": 1,
    "data": "Success"
}
```

## 取得單一賣家資料

### Response Example

```json
{
    "ok": 1,
    "data": {
        "id": 55,
        "userId": 155,
        "vendorName": "小地方雜貨鋪",
        "address": "235新北市中和區中安街6號",
        "position": {
            "type": "Point",
            "coordinates": [
                25.003422,
                121.5134953
            ]
        },
        "phone": "0912345677",
        "avatarUrl": "https://i.imgur.com/123.png",
        "bannerUrl": "https://i.imgur.com/123.png",
        "categoryId": 15,
        "description": "賣一些在地新鮮手工的小東西。",
        "openingHour": "{\"Monday\":{\"isOpen\":1,\"start\":\"06:00\",\"end\":\"17:00\"},\"Tuesday\":{\"isOpen\":1,\"start\":\"07:00\",\"end\":\"17:00\"},\"Wednesday\":{\"isOpen\":0,\"start\":\"\",\"end\":\"\"},\"Thursday\":{\"isOpen\":1,\"start\":\"08:00\",\"end\":\"18:00\"},\"Friday\":{\"isOpen\":1,\"start\":\"08:00\",\"end\":\"17:00\"},\"Saturday\":{\"isOpen\":0,\"start\":\"\",\"end\":\"\"},\"Sunday\":{\"isOpen\":0,\"start\":\"\",\"end\":\"\"}}",
        "isOpen": true,
        "isSuspended": false,
        "createdAt": "2021-10-08T12:50:02.000Z",
        "updatedAt": "2021-10-29T03:11:51.000Z",
        "VendorCategory": {
            "name": "蔬菜"
        },
        "User": {
            "username": "rrrrrr",
            "role": "vendor"
        }
    }
}
```



## 修改單一賣家資料

### Request Example

FormData:
```formdata
{
    "vendorName": "example",
    "address": "台北市中正區重慶南路一段122號",
    "latlng": "{lat: 24.1978414, lng:120.6570637}" // JSON 格式
    "email": "abc@gmail.com",  
    "openingHour": "[{monday: {start: 0900, end: 2100}}, {tuesday: {start: 1000, end: 2000}}, ...]",  // JSON 格式
    "avatar": <file>,
    "banner": <file>,
}
```

### Response  Example
```json
{
    "ok": 1,
    "data": "Success"
}
```

## 取得所有有效賣家資料

### query 參數：
- `_page` 頁數，預設為 1
- `_limit` 查詢筆數
- `_sort` 依...排序，預設為 'id'，另可輸入 'userId'、'vendorName'、'address'
- `_order` 正序/反序，預設為 'DESC'，另可輸入 'ASC'
- `categoryId` 取得該分類的賣家

> 僅能取得未被停權之賣家

### Response Example
```json
{
    "ok": 1,
    "data": [
      {
        "id": 17,
        "userId": 7,
        "vendorName": "vendor01",
        "address": "台北市中正區重慶南路一段122號",
        "position": {
            "type": "Point",
            "coordinates": [
                24.1604424,
                120.6428043
            ]
        },
        "phone": "09111111",
        "avatarUrl": "https://i.imgur.com/123",
        "bannerUrl": "https://i.imgur.com/123",
        "categoryId": 1,
        "description": "this is description.",
        "openingHour": "openinghour",
        "isOpen": true,
        "isSuspended": false,
        "VendorCategory": {
            "name": "category1"
        }
      },
      {
        "id": 17,
        "userId": 7,
        "vendorName": "vendor01",
        "address": "台北市中正區重慶南路一段122號",
        "position": {
            "type": "Point",
            "coordinates": [
                24.1604424,
                120.6428043
            ]
        },
        "phone": "09111111",
        "avatarUrl": "https://i.imgur.com/123",
        "bannerUrl": "https://i.imgur.com/123",
        "categoryId": 1,
        "description": "this is description.",
        "openingHour": "openinghour",
        "isOpen": true,
        "isSuspended": false,
        "VendorCategory": {
            "name": "category1"
        }
      }
    ] 
}
```


## 取得所有賣家資料

### query 參數：
- `_page` 頁數，預設為 1
- `_limit` 查詢筆數，預設為 10
- `_sort` 依...排序，預設為 'id'，另可輸入 'userId'、'vendorName'、'address'
- `_order` 正序/反序，預設為 'DESC'，另可輸入 'ASC'
- `categoryId` 取得該分類的賣家
- `isOpen` 賣場是否開放，預設為搜尋全部，另可輸入 '0' 表示 false、其餘值表示 true
- `isSuspended` 賣場是否被停權，預設為搜尋全部，另可輸入 '0' 表示 false、其餘值表示 true

### Response Example
```json
{
    "ok": 1,
    "data": [
      {
        "id": 17,
        "userId": 7,
        "vendorName": "vendor01",
        "address": "台北市中正區重慶南路一段122號",
        "position": {
            "type": "Point",
            "coordinates": [
                24.1604424,
                120.6428043
            ]
        },
        "phone": "09111111",
        "avatarUrl": "https://i.imgur.com/123",
        "bannerUrl": "https://i.imgur.com/123",
        "categoryId": 1,
        "description": "this is description.",
        "openingHour": "openinghour",
        "isOpen": true,
        "isSuspended": false,
        "VendorCategory": {
            "name": "category1"
        }
      },
      {
        "id": 17,
        "userId": 7,
        "vendorName": "vendor01",
        "address": "台北市中正區重慶南路一段122號",
        "position": {
            "type": "Point",
            "coordinates": [
                24.1604424,
                120.6428043
            ]
        },
        "phone": "09111111",
        "avatarUrl": "https://i.imgur.com/123",
        "bannerUrl": "https://i.imgur.com/123",
        "categoryId": 1,
        "description": "this is description.",
        "openingHour": "openinghour",
        "isOpen": true,
        "isSuspended": false,
        "VendorCategory": {
            "name": "category1"
        }
      }
    ] 
}
```


## 更改自己的營業狀態

### Response Example
```json
{
    "ok": 1,
    "data": "Success"
}
```

## 修改單一賣家權限

### Response Example

```json
{
    "ok": 1,
    "data": "Success"
}
```

