Stats API
The Stats API exposes aggregated network statistics from the Blockchain Indexer: overall network numbers, the NOS token price, and per-account spending and earning history.
Usage
ts
import { function createNosanaClient(network: NosanaNetwork | undefined, customConfig: PartialClientConfig & {
connect: ConnectFactoryConfig & {
clientSecret: string;
};
}): NosanaClient & {
connect: ServerConnect;
} (+3 overloads)
createNosanaClient, type NosanaNetwork = "mainnet" | "devnet" | "localnet"
const NosanaNetwork: {
readonly MAINNET: "mainnet";
readonly DEVNET: "devnet";
readonly LOCALNET: "localnet";
}
NosanaNetwork } from '@nosana/kit';
const const client: NosanaClientclient = function createNosanaClient(network?: NosanaNetwork, customConfig?: PartialClientConfig): NosanaClient (+3 overloads)createNosanaClient(const NosanaNetwork: {
readonly MAINNET: "mainnet";
readonly DEVNET: "devnet";
readonly LOCALNET: "localnet";
}
NosanaNetwork.type MAINNET: "mainnet"MAINNET, {
PartialClientConfig.api?: Partial<APIConfig> | undefinedapi: { apiKey?: string | undefinedapiKey: const process: {
env: Record<string, string>;
}
process.env: Record<string, string>env.stringNOSANA_API_KEY },
});
// Latest aggregated network statistics
const const stats: Record<string, unknown>stats = await const client: NosanaClientclient.NosanaClient.api: NosanaApiClientapi.stats: NosanaStatsApistats.NosanaStatsApi.get: () => Promise<Record<string, unknown>>get();
// NOS token price (optionally for a specific date or timestamp)
const const price: {
price: number | null;
}
price = await const client: NosanaClientclient.NosanaClient.api: NosanaApiClientapi.stats: NosanaStatsApistats.NosanaStatsApi.getPrice: (request?: StatsPriceRequest) => Promise<StatsPriceResponse>getPrice();
const const historic: {
price: number | null;
}
historic = await const client: NosanaClientclient.NosanaClient.api: NosanaApiClientapi.stats: NosanaStatsApistats.NosanaStatsApi.getPrice: (request?: StatsPriceRequest) => Promise<StatsPriceResponse>getPrice({ date?: string | undefineddate: '2025-06-01' });
// Spending history for an address over a custom date range
const const spending: Record<string, unknown>spending = await const client: NosanaClientclient.NosanaClient.api: NosanaApiClientapi.stats: NosanaStatsApistats.NosanaStatsApi.getSpendingHistory: (request: StatsHistoryRequest) => Promise<Record<string, unknown>>getSpendingHistory({
address: stringaddress: 'your-wallet-address',
start_date: stringstart_date: '2025-01-01',
end_date?: string | undefinedend_date: '2025-06-30',
});
// Earning history for a node
const const earnings: Record<string, unknown>earnings = await const client: NosanaClientclient.NosanaClient.api: NosanaApiClientapi.stats: NosanaStatsApistats.NosanaStatsApi.getEarningHistory: (request: StatsHistoryRequest) => Promise<Record<string, unknown>>getEarningHistory({
address: stringaddress: 'node-address',
start_date: stringstart_date: '2025-01-01',
group_by?: "month" | "day" | undefinedgroup_by: 'month',
});Methods
| Method | HTTP | Path | Description |
|---|---|---|---|
stats.get() | GET | /stats/ | Latest aggregated statistics |
stats.getPrice(query?) | GET | /stats/price | NOS price for a date or timestamp |
stats.getSpendingHistory(request) | GET | /stats/spending-history | Spending history for an address over a date range |
stats.getEarningHistory(request) | GET | /stats/earning-history | Earning history for a node over a date range |
Job-specific statistics (counts, GPU compute hours over time) live on the Jobs API as jobs.getStats(), jobs.getStatsTimestamps(), and jobs.getStatsTimestampsHours().