Skip to main content

Get Friend List

Retrieves the list of registered friends.

URL Confirmation

This API uses the service-api.playnanoo.com domain.

API Information

  • URL: https://service-api.playnanoo.com/friend/v20231201/search
  • Method: PUT
  • Authentication Required: Yes
DeviceInfo Inheritance

The Req class of this API inherits from DeviceInfo. All properties of DeviceInfo are automatically included.

Request Parameters

ParameterTypeRequiredDescription
table_codestringRequiredFriend table code

Response Data

Res Class

FieldTypeDescription
ItemsList<FriendItem>Friend list

FriendItem Class

FieldTypeDescription
RelationshipCodestringRelationship code
UserIdstringUser ID
NicknamestringNickname
TimezonestringTimezone
AccessSecondsdoubleLast access time (in seconds)

Unity C# Implementation

BaseResponse Class

Base class for all API responses.

public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}

Field descriptions:

  • ErrorCode: Error code
  • Message: Error message
  • WithdrawalKey: Key required for recovery if account is in withdrawal grace period (provided only for accounts in withdrawal grace period)
  • BlockKey: Key provided if account is blocked (provided only for blocked accounts)

Friend List Retrieval Class

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;

public class FriendAll
{
static string path = "https://service-api.playnanoo.com/friend/v20231201/search";

[Serializable]
public class Req : DeviceInfo
{
public string table_code;

public IEnumerator Send(string tableCode, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(tableCode)) this.table_code = tableCode;

yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}

[Serializable]
public class Res : BaseResponse
{
public List<FriendItem> Items;
}

[Serializable]
public class FriendItem
{
public string RelationshipCode;
public string UserId;
public string Nickname;
public string Timezone;
public double AccessSeconds;
}
}

Usage Example

Basic Usage

using PlayNANOO;
using System.Collections.Generic;

public class PlayNANOOExample : MonoBehaviour
{
void GetFriendList()
{
FriendAll.Req req = new FriendAll.Req();

StartCoroutine(req.Send(
tableCode: "your-friend-table-code",
onSuccess: res =>
{
Debug.Log($"Friend list retrieved successfully: {res.Items.Count} friends");

foreach (var friend in res.Items)
{
Debug.Log($"Friend: {friend.Nickname} (ID: {friend.UserId})");
Debug.Log($" Relationship Code: {friend.RelationshipCode}");
Debug.Log($" Last Access: {friend.AccessSeconds} seconds ago");
}
},
onError: (error) =>
{
Debug.LogError($"Failed to retrieve friend list: [{error.ErrorCode}] [{error.Message}]");
}
));
}
}

Display Friend List UI

using PlayNANOO;
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;

public class FriendListUI : MonoBehaviour
{
public Transform friendListContainer;
public GameObject friendItemPrefab;

void Start()
{
LoadFriendList();
}

void LoadFriendList()
{
FriendAll.Req req = new FriendAll.Req();

StartCoroutine(req.Send(
tableCode: "friend_table",
onSuccess: res =>
{
DisplayFriendList(res.Items);
},
onError: (error) =>
{
Debug.LogError($"Failed to load friend list: {error.Message}");
}
));
}

void DisplayFriendList(List<FriendAll.FriendItem> friends)
{
// Clear existing list
foreach (Transform child in friendListContainer)
{
Destroy(child.gameObject);
}

// Display friend list
foreach (var friend in friends)
{
GameObject item = Instantiate(friendItemPrefab, friendListContainer);

// Update UI
Text nicknameText = item.transform.Find("Nickname").GetComponent<Text>();
Text statusText = item.transform.Find("Status").GetComponent<Text>();

nicknameText.text = friend.Nickname;

// Display last access time
if (friend.AccessSeconds < 300) // Within 5 minutes
{
statusText.text = "Online";
statusText.color = Color.green;
}
else
{
int minutesAgo = (int)(friend.AccessSeconds / 60);
statusText.text = $"Last seen {minutesAgo} min ago";
statusText.color = Color.gray;
}
}
}
}
using PlayNANOO;
using System.Collections.Generic;
using System.Linq;

public class FriendSearcher : MonoBehaviour
{
private List<FriendAll.FriendItem> allFriends;

void SearchFriend(string searchKeyword)
{
FriendAll.Req req = new FriendAll.Req();

StartCoroutine(req.Send(
tableCode: "friend_table",
onSuccess: res =>
{
allFriends = res.Items;

// Search by nickname
var searchResults = allFriends
.Where(f => f.Nickname.Contains(searchKeyword))
.ToList();

Debug.Log($"Search results: {searchResults.Count} friends");

foreach (var friend in searchResults)
{
Debug.Log($"- {friend.Nickname}");
}
},
onError: (error) =>
{
Debug.LogError($"Friend search failed: {error.Message}");
}
));
}
}
Table Code

Before using the friend feature, you need to generate a friend table code in the PlayNANOO admin console.

Access Time

AccessSeconds represents the elapsed time since last access in seconds. It can be used to determine online status.