Multi Save Data
API for saving multiple game 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/save/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_items | string | Required | List of data to save (JSON string) |
StorageMultiSaveParam Structure (Convert to JSON before sending)
| Field | Type | Required | Description |
|---|---|---|---|
| Items | StorageItems[] | Required | Array of data to save |
StorageItems Structure
| Field | Type | Required | Description |
|---|---|---|---|
| StorageKey | string | Required | Key of the data to save |
| StorageValue | string | Required | Value of the data to save |
| IsPrivate | bool | Required | Whether the data is private |
Response Data
Res Class
| Field | Type | Description |
|---|---|---|
| Status | string | Processing status |
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)
StorageMultiSaveParam Class
[Serializable]
public class StorageMultiSaveParam
{
public List<StorageItems> Items = new List<StorageItems>();
}
[Serializable]
public class StorageItems
{
public string StorageKey;
public string StorageValue;
public bool IsPrivate;
}
Multi Save Data Class
using System;
using System.Collections;
using UnityEngine.Networking;
public class StorageMultiSave
{
static string path = "https://service-storage-api.playnanoo.com/storage/v20221001/save/multi";
[Serializable]
public class Req : DeviceInfo
{
public string storage_items; // Pass StorageMultiSaveParam as JSON string
public IEnumerator Send(string storage_items, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(storage_items)) this.storage_items = storage_items;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string Status;
}
}
Usage Example
public void SaveMultipleData()
{
StorageMultiSave.Req req = new StorageMultiSave.Req();
// Save multiple data at once
StorageMultiSaveParam param = new StorageMultiSaveParam();
param.Items.Add(new StorageItems
{
StorageKey = "player_level",
StorageValue = "10",
IsPrivate = true
});
param.Items.Add(new StorageItems
{
StorageKey = "player_gold",
StorageValue = "5000",
IsPrivate = false
});
param.Items.Add(new StorageItems
{
StorageKey = "player_inventory",
StorageValue = "[sword, armor]",
IsPrivate = false
});
string json = JsonUtility.ToJson(param);
StartCoroutine(req.Send(
storage_items: json,
onSuccess: res =>
{
Debug.Log("Multi data save successful");
},
onError: error =>
{
Debug.LogError($"Multi data save failed: [{error.ErrorCode}] {error.Message}");
}
));
}
Efficient Saving
When you need to save multiple data items simultaneously, using this API can reduce the number of network requests, making it more efficient.
Transactions
All data is saved atomically. If even one fails, the entire operation is treated as failed.