Money and currencies โ
All monetary amounts in the Quarzo API are represented as integers in the smallest currency unit โ cents for EUR, pence for GBP, and so on. There are no decimals, no floating-point numbers.
{
"amount": 10050,
"currency": "EUR"
}This represents โฌ100.50, not 10 050 euros.
Why integers โ
Floating-point arithmetic is notoriously unreliable for financial calculations. 0.1 + 0.2 does not equal 0.3 in most programming environments. Storing amounts as integers eliminates rounding errors entirely.
Formatting for display โ
Never display raw integer amounts to your users. Always divide by the correct exponent for the currency before rendering.
// EUR, GBP, USD โ exponent 2 (cents)
function formatAmount(amount, currency) {
return new Intl.NumberFormat('fr-FR', {
style: 'currency',
currency,
}).format(amount / 100)
}
formatAmount(10050, 'EUR') // โ "100,50 โฌ"
formatAmount(599, 'EUR') // โ "5,99 โฌ"Money libraries โ
Rather than managing integer arithmetic yourself, consider using a dedicated money library for your language. These libraries handle subunit conversion, currency-aware formatting, and safe arithmetic out of the box.
You can find some proposed libraries below. These are provided for guidance only and should not be considered recommendations.
| Language | Library |
|---|---|
| JavaScript / TypeScript | dinero.js, Moneta |
| Python | py-moneyed |
| Ruby | money |
| PHP | moneyphp/money |
| Java / Kotlin | JavaMoney (JSR 354) |
| Go | bojanz/currency |
Supported currencies โ
All amounts must be paired with an explicit currency field using the ISO 4217 three-letter code.
Currency others than EUR could be used to show information about underlying assets of Unit Linked funds.
| Currency | Code | Smallest unit |
|---|---|---|
| Euro | EUR | Cent (รท 100) |
| Pound sterling | GBP | Penny (รท 100) |
| Swiss franc | CHF | Rappen (รท 100) |
| US dollar | USD | Cent (รท 100) |
Zero-decimal currencies
Some currencies โ like JPY โ have no subunit. For these, pass the amount as-is: { "amount": 1200, "currency": "JPY" } represents ยฅ1,200.
Common mistakes โ
Do not pass floats. The API will reject non-integer values.
// โ Invalid
{ "amount": 100.50, "currency": "EUR" }
// โ
Correct
{ "amount": 10050, "currency": "EUR" }Do not omit currency. Every amount field must be accompanied by a currency code. Requests missing currency will return a 422 Unprocessable Entity error.