Developers & API › Public Data API › Base-unit strings

Public Data API

Base-unit strings

Every wei and token amount is a decimal string of base units: why, how to parse it exactly, and which fields are plain numbers.

Version
1.0
Updated
2026-10-14
Source
Public Data API library

Amounts are decimal strings#

Every wei and token-base-unit quantity is a decimal string, never a JSON number. That is the entire reason the API returns strings: JSON.stringify throws on a bigint, and the obvious repair — Number(wei) — is silently lossy above 253, which is roughly 0.009 ETH. Every figure published here is larger than that.

code
// Right — exact, at any magnitude.
const raised = BigInt(launch.stats.netRaisedWei)          // 1234567890123456789012n

// Wrong — silently rounded, and unrecoverable afterwards.
const raised = Number(launch.stats.netRaisedWei)          // 1.2345678901234568e+21
const raised = parseFloat(launch.stats.netRaisedWei)      // the same loss, quieter

Convert to a display string at the edge, from the bigint, and never in between. A value that arrives from the database as a float is refused rather than published: precision was lost before this API saw it, and publishing it would state a quantity that is not any amount of anything. A bigint that reaches the serialiser throws for the mirror-image reason.

Counts (trades, holders, stakes) and basis-point fields are ordinary JSON numbers — they are bounded and safe. Timestamps are decimal strings of seconds, with an ISO rendering beside them.