# Search accounts

## &#x20;Search accounts

<mark style="color:blue;">`GET`</mark> `https://abc.hoola.vn/manage/api/users/search-user`

To execute the query, there must be at least 1 parameter, either the email or username of the account. When there are both email and username parameters at the same time, the account will be prioritized to search by email first. If there is no match by email, it will continue to search for accounts by username.

#### Query Parameters

| Name     | Type   | Description                       |
| -------- | ------ | --------------------------------- |
| token    | string | Your Account Authentication Token |
| email    | string | Email                             |
| username | string | Username                          |

{% tabs %}
{% tab title="200 Query successfully" %}

```javascript
// Response Code "00". Query successfully.
// Return data:
{
    "respCode": "00",
    "user": {
        "_id": "73chhLtPnxpPoekrx",
        "createdAt": "2021-05-27T08:38:15.067Z",
        "username": "vuvanhoang",
        "emails": [
            {
                "address": "hoangvuvan@abc.com",
                "verified": false
            }
        ],
        "profile": {
            "name": "Vu Van Hoang"
        },
        "myCourses": [
            {
                "courseId": "wSZpqbtWowmpLC68L",
                "activatedDate": "2021-05-29T06:19:24.107Z",
                "expiredAt": "2121-05-05T06:19:24.107Z"
            }
        ],
        "myCart": [
            {
                "courseId": "vivPteJNNC2P94Es8",
                "status": "DELETED"
            }
        ],
        "myTransactions": [
            "nTv5XgDMNcMLBuRM5"
        ]
    },
    "msg": "Success"
}
```

{% endtab %}

{% tab title="400 Query is missing request parameters or cannot find the requested account." %}

```javascript
// Response Code "02". No token provided.
// Return data:
{
    "respCode": "02",
    "user": null,
    "msg": "No token"
}


// Response Code "03". No email or username provided.
// Return data:
{
    "respCode": "03",
    "user": null,
    "msg": "Search user require email or username parameter"
}


// Response Code "07". Account not found.
// Return data:
{
    "respCode": "07",
    "user": null,
    "msg": "User not found"
}

```

{% endtab %}

{% tab title="401 Fail to verify your account" %}

```javascript
// Response Code "05". Token is invalid or has expired.
// Return data:
{
    "respCode": "05",
    "user": null,
    "msg": "Invalid token || Token has expired"
}
```

{% endtab %}

{% tab title="403 Your account is not authorized to perform the query." %}

```javascript
// Response Code "06". Your account is not authorized to perform the query.
// Return data:
{
    "respCode": "06",
    "user": null,
    "msg": "Your account does not have permission"
}
```

{% endtab %}

{% tab title="405 Wrong request method" %}

```javascript
// Response Code "01". Wrong request method.
// Return data:
{
    "respCode": "01",
    "user": null,
    "msg": "Request method should be GET"
}
```

{% endtab %}

{% tab title="500 Server error" %}

```javascript
// Response Code "04". Server not able to authenticate your account.
// Return data:
{
    "respCode": "04",
    "user": null,
    "msg": "Server not able to authenticate your account"
}
```

{% endtab %}
{% endtabs %}

Example

```javascript
// Search for an account by email
// GET:
https://abc.hoola.vn/manage/api/users/search-user?token=sdhg23797sdbv9186jdvk58&email=abc@abc.com


// Search for an account by username
// GET:
https://abc.hoola.vn/manage/api/users/search-user?token=sdhg23797sdbv9186jdvk58&username=abc


// Search for an account by both email and username
// GET:
https://abc.hoola.vn/manage/api/users/search-user?token=sdhg23797sdbv9186jdvk58&email=abc@abc.com&username=abc
```

&#x20;
