跳转到主要内容

查询货币

查询特定货币持有数量的 API。

URL 确认

此 API 使用 service-api.playnanoo.com 域名。

API 信息

  • URL: https://service-api.playnanoo.com/currency/v20250301/get
  • Method: PUT
  • 需要认证: 是
DeviceInfo 继承

此 API 的 Req 类继承自 DeviceInfo。DeviceInfo 的所有属性将自动包含。

请求参数

参数类型必填说明
currency_codestring必填要查询的货币代码

响应数据

Res 类

字段类型说明
currency_amountdouble持有货币数量

Unity C# 实现

BaseResponse 类

所有 API 响应的基类。

public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}

字段说明:

  • ErrorCode: 错误代码
  • Message: 错误消息
  • WithdrawalKey: 处于注销等待状态时用于恢复的密钥 (仅在注销等待中的账户提供)
  • BlockKey: 账户被封禁时提供的密钥 (仅在被封禁的账户提供)

查询货币类

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

public class CurrencyGet
{
static string path = "https://service-api.playnanoo.com/currency/v20250301/get";

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

public IEnumerator Send(string currencyCode, Action<Res> onSuccess, Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(currencyCode)) this.currency_code = currencyCode;

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

[Serializable]
public class Res : BaseResponse
{
public double currency_amount;
}
}

使用示例

public void GetCurrency()
{
CurrencyGet.Req req = new CurrencyGet.Req();

StartCoroutine(req.Send(
currencyCode: "GOLD",
onSuccess: res =>
{
Debug.Log("재화 조회 성공");
Debug.Log($"GOLD 보유량: {res.currency_amount}");
},
onError: error =>
{
Debug.LogError($"재화 조회 실패: [{error.ErrorCode}] {error.Message}");
}
));
}
货币查询

通过指定特定货币代码来查询该货币的当前持有数量。