Multi Load Data
API for loading multiple saved data items 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/load/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 keys 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 Load Data Class
using System;
using System.Collections;
using UnityEngine.Networking;
public class StorageMultiLoad
{
static string path = "https://service-storage-api.playnanoo.com/storage/v20221001/load/multi";
[Serializable]
public class StorageItem
{
public string PlayerId;
public string StorageKey;
public string StorageValue;
}
[Serializable]
public class Req : DeviceInfo
{
public string[] storage_keys; // List of data keys to load
public IEnumerator Send(string[] storage_keys, Action<Res> onSuccess, Action<BaseResponse> onError)
{
this.storage_keys = storage_keys;
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;
}
}
Usage Example
public void LoadMultipleData()
{
StorageMultiLoad.Req req = new StorageMultiLoad.Req();
// List of data keys to load
string[] keys = new string[]
{
"player_level",
"player_gold",
"player_inventory"
};
StartCoroutine(req.Send(
storage_keys: keys,
onSuccess: res =>
{
Debug.Log("Multi data loading successful");
foreach (var item in res.Items)
{
Debug.Log($"Player ID: {item.PlayerId}");
Debug.Log($"{item.StorageKey}: {item.StorageValue}");
}
},
onError: error =>
{
Debug.LogError($"Multi data loading failed: [{error.ErrorCode}] {error.Message}");
}
));
}
Efficient Loading
When you need to load multiple data items simultaneously, using this API can reduce the number of network requests, making it more efficient.
Non-existent Keys
No error occurs even if some of the requested keys do not exist, and only existing data is returned.