Skip to content

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.

json
{
  "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.

js
// 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.

LanguageLibrary
JavaScript / TypeScriptdinero.js, Moneta
Pythonpy-moneyed
Rubymoney
PHPmoneyphp/money
Java / KotlinJavaMoney (JSR 354)
Gobojanz/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.

CurrencyCodeSmallest unit
EuroEURCent (รท 100)
Pound sterlingGBPPenny (รท 100)
Swiss francCHFRappen (รท 100)
US dollarUSDCent (รท 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.

json
// โŒ 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.