Multi Player Data Load
API for loading multiple public data items from other players at once.
URL Verification
This API uses the service-storage-api.playnanoo.com domain.
API Information
- URL:
https://service-storage-api.playnanoo.com/storage/v20221001/playerDataLoad/multi - 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| storage_keys | string | Required | List of data to query (JSON string) |
storage_keys JSON Structure (MultiLoadParam)
| Field | Type | Required | Description |
|---|---|---|---|
| Items | MultiLoadParamValue[] | Required | List of data to query |
MultiLoadParamValue Structure
| Field | Type | Required | Description |
|---|---|---|---|
| PlayerId | string | Required | Player ID to query |
| StorageKey | string | Required | Key of the data to load |
Response Data
Res Class
| Field | Type | Description |
|---|---|---|
| Items | StorageItem[] | List of loaded data |
StorageItem Structure
| Field | Type | Description |
|---|---|---|
| PlayerId | string | Player ID |
| StorageKey | string | Key of the data |
| StorageValue | string | Value of the data |
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 codeMessage: Error messageWithdrawalKey: 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)
Multi Player Data Load Class
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;
[Serializable]
public class MultiLoadParam
{
public List<MultiLoadParamValue> Items = new List<MultiLoadParamValue>();
}
[Serializable]
public class MultiLoadParamValue
{
public string PlayerId;
public string StorageKey;
}
public class StorageMultiPlayerDataLoad
{
static string path = "https://service-storage-api.playnanoo.com/storage/v20221001/playerDataLoad/multi";
[Serializable]
public class Req : DeviceInfo
{
public string storage_keys;
public IEnumerator Send(
MultiLoadParam storageKeys,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (storageKeys != null) this.storage_keys = JsonUtility.ToJson(storageKeys);
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public StorageItem[] Items;
}
[Serializable]
public class StorageItem
{
public string PlayerId;
public string StorageKey;
public string StorageValue;
}
}
Usage Example
public void LoadOtherPlayerMultipleData()
{
StorageMultiPlayerDataLoad.Req req = new StorageMultiPlayerDataLoad.Req();
// Create players and data list to query
MultiLoadParam storageKeys = new MultiLoadParam();
storageKeys.Items.Add(new MultiLoadParamValue { PlayerId = "PLAYER_ID_1", StorageKey = "public_profile" });
storageKeys.Items.Add(new MultiLoadParamValue { PlayerId = "PLAYER_ID_2", StorageKey = "achievement_list" });
storageKeys.Items.Add(new MultiLoadParamValue { PlayerId = "PLAYER_ID_1", StorageKey = "ranking_info" });
StartCoroutine(req.Send(
storageKeys: storageKeys,
onSuccess: res =>
{
Debug.Log("Other player multi data loading successful");
foreach (var item in res.Items)
{
Debug.Log($"Player ID: {item.PlayerId}");
Debug.Log($"{item.StorageKey}: {item.StorageValue}");
// Process each data
switch (item.StorageKey)
{
case "public_profile":
var profile = JsonUtility.FromJson<PublicProfile>(item.StorageValue);
Debug.Log($"Player name: {profile.name}");
break;
case "achievement_list":
// Process achievements
break;
}
}
},
onError: error =>
{
Debug.LogError($"Data loading failed: [{error.ErrorCode}] {error.Message}");
}
));
}
[Serializable]
public class PublicProfile
{
public string name;
public int level;
public string avatar;
}
Efficient Querying
When querying multiple public data items from other players, using this API can reduce the number of network requests.
Security Caution
This API queries data from other players, so only data that is safe to be public should be stored. Never store sensitive personal information.
Ranking and Friend Systems
This API is useful for efficiently fetching information about multiple players in ranking systems or friend lists.