Skip to main content

Query Ranking

API for querying rankings within a specific range from the leaderboard.

URL Verification

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

API Information

  • URL: https://service-api.playnanoo.com/leaderboard/v20240301/range
  • 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
uidstringRequiredTable code
range_startintRequiredStarting rank (starts from 1)
range_endintRequiredEnding rank

Response Data

Res Class

FieldTypeDescription
ItemsList<RangeItemModel>Ranking list

RangeItemModel Class

FieldTypeDescription
RankintRank
RotationCountintSeason number
RecordIdstringRecord ID
ScoreintScore
ExtraDatastringAdditional data (JSON string)

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 in withdrawal grace period (only provided for accounts in withdrawal grace period)
  • BlockKey: Key provided if account is blocked (only provided for blocked accounts)

Query Ranking Class

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

public class Range
{
static string path = "https://service-api.playnanoo.com/leaderboard/v20240301/range";

[Serializable]
public class Req : DeviceInfo
{
public string uid;
public int range_start;
public int range_end;

public IEnumerator Send(string table_code, int rangeStart, int rangeEnd, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(table_code)) this.uid = table_code;
this.range_start = rangeStart;
this.range_end = rangeEnd;

yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
}

[Serializable]
public class Res : BaseResponse
{
public List<RangeItemModel> Items;
}

[Serializable]
public class RangeItemModel
{
public int Rank;
public int RotationCount;
public string RecordId;
public int Score;
public string ExtraData;
}
}

Usage Example

public void GetLeaderboardRange()
{
Range.Req req = new Range.Req();

StartCoroutine(req.Send(
table_code: "my_leaderboard_table",
rangeStart: 1, // From rank 1
rangeEnd: 10, // To rank 10
onSuccess: res =>
{
Debug.Log("Rankings retrieved successfully");
Debug.Log($"Records retrieved: {res.Items.Count}");

foreach (var item in res.Items)
{
Debug.Log($"Rank: {item.Rank}");
Debug.Log($"Player ID: {item.RecordId}");
Debug.Log($"Score: {item.Score}");
Debug.Log($"Season: {item.RotationCount}");

if (!string.IsNullOrEmpty(item.ExtraData))
{
Debug.Log($"Additional data: {item.ExtraData}");
}
}
},
onError: error =>
{
Debug.LogError($"Ranking retrieval failed: [{error.ErrorCode}] {error.Message}");
}
));
}
Ranking Range

You can specify your desired ranking range using range_start and range_end. For example, to query the top 10 players, set range_start=1 and range_end=10.

Efficient Querying

Querying too many rankings at once can impact performance. It's recommended to query only the range you need.