Load Data
API for loading saved game data.
URL Verification
This API uses the service-storage-api.playnanoo.com domain.
API Information
- URL:
https://service-storage-api.playnanoo.com/storage/v20221001/load - 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_key | string | Required | Key of the data to load |
Response Data
Res Class
| Field | Type | Description |
|---|---|---|
| PlayerId | string | Player ID |
| StorageKey | string | Key of the saved data |
| StorageValue | string | Value of the saved 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)
Load Data Class
using System;
using System.Collections;
using UnityEngine.Networking;
public class StorageLoad
{
static string path = "https://service-storage-api.playnanoo.com/storage/v20221001/load";
[Serializable]
public class Req : DeviceInfo
{
public string storage_key; // Key of the data to load
public IEnumerator Send(string storage_key, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(storage_key)) this.storage_key = storage_key;
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}
[Serializable]
public class Res : BaseResponse
{
public string PlayerId;
public string StorageKey;
public string StorageValue;
}
}
Usage Example
public void LoadGameData()
{
StorageLoad.Req req = new StorageLoad.Req();
StartCoroutine(req.Send(
storage_key: "player_game_data",
onSuccess: res =>
{
Debug.Log("Data loading successful");
Debug.Log($"Player ID: {res.PlayerId}");
Debug.Log($"Storage Key: {res.StorageKey}");
// JSON deserialization
var gameData = JsonUtility.FromJson<GameData>(res.StorageValue);
Debug.Log($"Level: {gameData.level}");
Debug.Log($"Score: {gameData.score}");
},
onError: error =>
{
Debug.LogError($"Data loading failed: [{error.ErrorCode}] {error.Message}");
}
));
}
[Serializable]
public class GameData
{
public int level;
public int score;
public string[] items;
}
Data Deserialization
If you saved storage_value as JSON, you can restore it to its original object using JsonUtility.FromJson<T>().
Handling Missing Data
An error is returned if there is no saved data. For initial players, handle this by setting default values.