> For the complete documentation index, see [llms.txt](https://docs.idosgames.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.idosgames.com/api/api-v1/friend.md).

# Friend

This documentation explains the different endpoints and functionalities of the Friend API that is part of the IDosGamesSDK. This API handles various actions related to friend management.

**Base URL**

```
https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/  
```

**Overview**

The Friend API provides several endpoints to manage friends within the game. Each endpoint requires a specific HTTP method and may require certain parameters to be passed in the request body.

**Endpoints**

## Get My Friends

**Purpose:** Returns a list of the user's friends.

**URL:**

```
GET https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetMyFriends  
```

**Method:** GET

**Response Codes:**

* `200 OK`: Successful retrieval. Returns a list of friends.
* `400 Bad Request`: Invalid `userID`.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetMyFriends', {    
    method: 'GET',    
    headers: {    
        'Content-Type': 'application/json'    
    }  
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Add Friend Request

**Purpose:** Sends a friend request to another user.

**URL:**

```
POST https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/AdditionRequest  
```

**Method:** POST

**Request Parameters (JSON body):**

* `FriendID` (string): The `userID` of the potential friend.

**Response Codes:**

* `200 OK`: Friend request sent successfully.
* `400 Bad Request`: Invalid request parameters.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/AdditionRequest', {    
    method: 'POST',    
    headers: {    
        'Content-Type': 'application/json'    
    },    
    body: JSON.stringify({    
        FriendID: 'user-id-of-friend'    
    })    
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Get Recommended Friends

**Purpose:** Retrieves a list of recommended friends based on similar attributes.

**URL:**

```
GET https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetRecommendedFriends  
```

**Method:** GET

**Response Codes:**

* `200 OK`: Successful retrieval. Returns a list of recommended friends.
* `400 Bad Request`: Invalid `userID`.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetRecommendedFriends', {    
    method: 'GET',    
    headers: {    
        'Content-Type': 'application/json'    
    }  
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Accept Friend Request

**Purpose:** Accepts a pending friend request from another user.

**URL:**

```
POST https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/AcceptRequest  
```

**Method:** POST

**Request Parameters (JSON body):**

* `FriendID` (string): The `userID` of the friend whose request is being accepted.

**Response Codes:**

* `200 OK`: Friend request accepted successfully.
* `400 Bad Request`: Invalid request parameters.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/AcceptRequest', {    
    method: 'POST',    
    headers: {    
        'Content-Type': 'application/json'    
    },    
    body: JSON.stringify({    
        FriendID: 'user-id-of-friend'    
    })    
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Reject Friend Request

**Purpose:** Rejects a pending friend request from another user.

**URL:**

```
POST https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/RejectRequest  
```

**Method:** POST

**Request Parameters (JSON body):**

* `FriendID` (string): The `userID` of the friend whose request is being rejected.

**Response Codes:**

* `200 OK`: Friend request rejected successfully.
* `400 Bad Request`: Invalid request parameters.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/RejectRequest', {    
    method: 'POST',    
    headers: {    
        'Content-Type': 'application/json'    
    },    
    body: JSON.stringify({    
        FriendID: 'user-id-of-friend'    
    })    
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Remove Friend

**Purpose:** Removes an existing friend from the user's friend list.

**URL:**

```
POST https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/RemoveFriend  
```

**Method:** POST

**Request Parameters (JSON body):**

* `FriendID` (string): The `userID` of the friend to be removed.

**Response Codes:**

* `200 OK`: Friend removed successfully.
* `400 Bad Request`: Invalid request parameters.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/RemoveFriend', {    
    method: 'POST',    
    headers: {    
        'Content-Type': 'application/json'    
    },    
    body: JSON.stringify({    
        FriendID: 'user-id-of-friend'    
    })    
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Update User Power

**Purpose:** Updates the user's power level.

**URL:**

```
POST https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/UpdateUserPower  
```

**Method:** POST

**Request Parameters (JSON body):**

* `Power` (int): The new power level to be set.

**Response Codes:**

* `200 OK`: Power level updated successfully.
* `400 Bad Request`: Invalid request parameters.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/UpdateUserPower', {    
    method: 'POST',    
    headers: {    
        'Content-Type': 'application/json'    
    },    
    body: JSON.stringify({    
        Power: 5000    
    })    
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Get Pending Friend Requests

**Purpose:** Retrieves a list of all pending friend requests.

**URL:**

```
GET https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetPendingFriendRequests  
```

**Method:** GET

**Response Codes:**

* `200 OK`: Successful retrieval. Returns a list of pending friend requests.
* `400 Bad Request`: Invalid `userID`.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetPendingFriendRequests', {    
    method: 'GET',    
    headers: {    
        'Content-Type': 'application/json'    
    }  
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Get Submitted Requests

**Purpose:** Retrieves a list of friend requests sent by the user.

**URL:**

```
GET https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetSubmittedRequests  
```

**Method:** GET

**Response Codes:**

* `200 OK`: Successful retrieval. Returns a list of submitted friend requests.
* `400 Bad Request`: Invalid `userID`.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetSubmittedRequests', {    
    method: 'GET',    
    headers: {    
        'Content-Type': 'application/json'    
    }  
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Find User

**Purpose:** Finds and retrieves information about a user.

**URL:**

```
POST https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/FindUser  
```

**Method:** POST

**Request Parameters (JSON body):**

* `FriendID` (string): The `userID` of the user to be found.

**Response Codes:**

* `200 OK`: User found successfully. Returns user details.
* `400 Bad Request`: Invalid request parameters or user not found.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/FindUser', {    
    method: 'POST',    
    headers: {    
        'Content-Type': 'application/json'    
    },    
    body: JSON.stringify({    
        FriendID: 'user-id-to-find'    
    })    
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```

## Get Random User

**Purpose:** Retrieves a random user that matches certain criteria for potential friendship.

**URL:**

```
GET https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetRandomUser  
```

**Method:** GET

**Response Codes:**

* `200 OK`: Successful retrieval. Returns a random user.
* `400 Bad Request`: No matching users found.

**Example Usage:**

```javascript
fetch('https://api.idosgames.com/api/[titleTemplateId]/[titleId]/Client/Friend/GetRandomUser', {    
    method: 'GET',    
    headers: {    
        'Content-Type': 'application/json'    
    }  
})  
.then(response => response.json())    
.then(data => console.log(data))    
.catch(error => console.error('Error:', error));  
```
