---
# System prepended metadata

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

---

# API Details - User
###### tags: `API Details`

## 註冊使用者

### Request Example

FormData:
```formdata
{
    "nickname": "Mike",
    "username": "iammike",
    "password": "abcde",
    "email": "abc@gmail.com",
    "phone": "091111111",
    "avatar": <file>
}
```

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

## 登入使用者

### Request Example

```json
{
    "username": "iammike",
    "password": "abcde",
}
```

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

## 取得自己的使用者資料

### Response Example
```json
{
    "ok": 1,
    "data": {
        "username": "iammike",
        "nickname": "Mike",
        "email": "abc@gmail.com", 
        "phone": "09111111"
        "role": "member",
        "avatarURL": "https://i.imgur.com/32145",
        "vendorId": null
    }
}
```

## 修改自己的使用者資料

### Request Example

FormData: 
```formData
{
    "nickname": "123",
    "email": "123@gmail.com",
    "address": "456",
    "phone": "09xxxxxx",
    "avatar": <file>,
}
```

### Response Example
```json
{
    "ok": 1,
    "data": "Success"
}
```
## 修改自己的密碼

### Request Example
```json
{
	"oldPassword": "123",
	"newPassword": "test",
	"confirmPassword": "test"
}
```
### Response  Example
```json
{
    "ok": 1,
    "data": "Success"
}
```

## 取得單一使用者資料

### Response Example
```json
{
    "ok": 1,
    "data": {
        "nickname": "Mike",
        "username": "iammike",
        "phone": "0911111",
        "email": "123@gmail",
        "avatarURL":  "https://i.imgur.com/32145",
        "role": "member"
    }
}
```

## 修改單一使用者資料

### Request Example

FormData:
```formdata
{
    "nickname": "Mike123",
    "email": "123@gmail.com",
    "phone": "09xxxxxx",
    "avatar": <file>,
}
```

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

## 取得所有使用者資料

### query 參數：
- `_page` 頁數，預設為 1
- `_limit` 查詢筆數，預設為 10
- `_sort` 依...排序，預設為 'id'，另可輸入 'username'、'nickname'、'role'
- `_order` 正序/反序，預設為 'DESC'，另可輸入 'ASC'
- `role` 取得該身份的使用者

### Response Example
```json
{
    "ok": 1,
    "data": [
      {
        "username": "iammike",
        "nickname": "Mike",
        "email": "abc@gmail.com", 
        "phone": "09111111"

        "role": "member",
        "avatarURL": "https://i.imgur.com/32145",
        "vendorId": null
      },
      {
        "username": "iammike",
        "nickname": "Mike",
        "email": "abc@gmail.com", 
        "phone": "09111111"
        "role": "member",
        "avatarURL": "https://i.imgur.com/32145",
        "vendorId": null
      }
    ] 
}
```

## 更改使用者權限

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