Skip to main content

Public Data Load

API for loading game data set as public.

URL Verification

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

API Information

  • URL: https://service-storage-api.playnanoo.com/storage/v20211101/load/public
  • 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
storage_keystringRequiredKey of the data to load

Response Data

Res Class

FieldTypeDescription
StorageKeystringKey of the saved data
StorageValuestringValue 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 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)

Public Data Load Class

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

public class StoragePublicLoad
{
static string path = "https://service-storage-api.playnanoo.com/storage/v20211101/load/public";

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

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 StorageKey;
public string StorageValue;
}
}

Usage Example

public void LoadPublicData()
{
StoragePublicLoad.Req req = new StoragePublicLoad.Req();

StartCoroutine(req.Send(
storage_key: "public_ranking_data",
onSuccess: res =>
{
Debug.Log("Public data loading successful");
Debug.Log($"Storage Key: {res.StorageKey}");

// JSON deserialization
var rankingData = JsonUtility.FromJson<RankingData>(res.StorageValue);
Debug.Log($"Number of top players: {rankingData.topPlayers.Length}");
},
onError: error =>
{
Debug.LogError($"Data loading failed: [{error.ErrorCode}] {error.Message}");
}
));
}

[Serializable]
public class RankingData
{
public string[] topPlayers;
public int[] scores;
}
Public Data Usage

This API is used to load public data that all players can access, such as rankings, announcements, and event information.

isPrivate Setting

Only data saved with isPrivate set to false or "off" can be loaded with this API.