跳到主要内容

Accounts(账户)

Account 资源用于查询你在 GStable 下的账户详情。

访问账户 API

GStableClient 实例上通过 client.account 调用账户相关方法。

只读资源

SDK 中的 Account 资源为只读。若要创建或修改账户设置,请使用 GStable 控制台(Dashboard)

TypeScript 类型

账户相关类型可从包根路径导入:

import type { Account, AccountStatus, AccountType } from 'gstable-js';

list

单次响应返回当前 API 密钥可见的全部账户(服务端无分页)。

client.account.list()

参数

名称类型必填说明
无参数。

返回值

Promise<Account[]> — 账户对象数组(accountIdaccountNameaccountAddressaccountTypesettlementCurrenciesversionstatus,以及可选 createAt / updateAt)。

示例

import { GStableClient } from 'gstable-js';

const client = new GStableClient({ apiKey: process.env.GSTABLE_API_KEY! });
const accounts = await client.account.list();
console.log(accounts.map((a) => a.accountId));

detail

按 id 加载单个账户。

client.account.detail(accountId)

参数

名称类型必填说明
accountIdstring账户标识符。

返回值

Promise<Account> — 单条 Account

示例

import { GStableClient } from 'gstable-js';

const client = new GStableClient({ apiKey: process.env.GSTABLE_API_KEY! });
const account = await client.account.detail('acc_xxxxxxxx');
console.log(account.settlementCurrencies);