Skip to main content

Exact Money and Minor Units API

REAL DATA

Exact ISO 4217 major/minor-unit conversion and weighted allocation using decimal strings and integer arithmetic — no floats, rounding or FX rates.

Authoritative reference data or standards computation

Base URL
/api/money
Capabilities
3 routes
Last updated
July 29, 2026
Data source

GET /api/money/to-minor

Live requestRuns against the public API
No key required
GET/api/money/to-minor?amount=123.45&currency=DKK

Request parameters

Canonical decimal amount string (no exponent, separators or leading zeroes). It must already fit the currency's minor-unit precision; no rounding occurs.

Active ISO 4217 currency code, case-insensitive. XDR is rejected because ISO defines no minor unit for it.

Advanced response options4 options

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/money/to-minor?amount=123.45&currency=DKK"
const res = await fetch("https://randomapi.dev/api/money/to-minor?amount=123.45&currency=DKK");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/money/to-minor?amount=123.45&currency=DKK").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/money/to-minor?amount=123.45&currency=DKK"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 2
amount string required

Canonical decimal amount string (no exponent, separators or leading zeroes). It must already fit the currency's minor-unit precision; no rounding occurs.

allowed: 1 – 72
example: amount=123.45
currency string required

Active ISO 4217 currency code, case-insensitive. XDR is rejected because ISO defines no minor unit for it.

allowed: 3 – 3
example: currency=DKK
Universal parameters Shared response and formatting options 4
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=currency,decimalDigits
exclude list

Return all fields except these (comma-separated).

example: exclude=minorUnits
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 4
currency string

Canonical uppercase ISO 4217 code.

example: DKK

decimalDigits integer

ISO 4217 minor-unit exponent used for the exact conversion.

example: 2

amount string

Canonical fixed-scale major-unit amount.

example: 123.45

minorUnits string (integer)

Exact signed integer minor-unit value.

example: 12345

Documented examples

Build-generated requests and complete responses
3
Danish kroner to øre
GET /api/money/to-minor?amount=123.45&currency=DKK
{
  "data": {
    "currency": "DKK",
    "decimalDigits": 2,
    "amount": "123.45",
    "minorUnits": "12345"
  },
  "meta": {
    "endpoint": "money",
    "route": "/to-minor",
    "params": {
      "amount": "123.45",
      "currency": "DKK"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Whole Japanese yen
GET /api/money/to-minor?amount=2500&currency=JPY
{
  "data": {
    "currency": "JPY",
    "decimalDigits": 0,
    "amount": "2500",
    "minorUnits": "2500"
  },
  "meta": {
    "endpoint": "money",
    "route": "/to-minor",
    "params": {
      "amount": "2500",
      "currency": "JPY"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Three-decimal Kuwaiti dinar
GET /api/money/to-minor?amount=-12.345&currency=KWD
{
  "data": {
    "currency": "KWD",
    "decimalDigits": 3,
    "amount": "-12.345",
    "minorUnits": "-12345"
  },
  "meta": {
    "endpoint": "money",
    "route": "/to-minor",
    "params": {
      "amount": "-12.345",
      "currency": "KWD"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}

GET /api/money/from-minor

Live requestRuns against the public API
No key required
GET/api/money/from-minor?minor=12345&currency=DKK

Request parameters

Canonical signed integer minor-unit string without decimal point, exponent or leading zeroes.

Active ISO 4217 currency code, case-insensitive. XDR is rejected because ISO defines no minor unit for it.

Advanced response options4 options

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/money/from-minor?minor=12345&currency=DKK"
const res = await fetch("https://randomapi.dev/api/money/from-minor?minor=12345&currency=DKK");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/money/from-minor?minor=12345&currency=DKK").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/money/from-minor?minor=12345&currency=DKK"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 2
minor string required

Canonical signed integer minor-unit string without decimal point, exponent or leading zeroes.

allowed: 1 – 72
example: minor=12345
currency string required

Active ISO 4217 currency code, case-insensitive. XDR is rejected because ISO defines no minor unit for it.

allowed: 3 – 3
example: currency=DKK
Universal parameters Shared response and formatting options 4
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=currency,decimalDigits
exclude list

Return all fields except these (comma-separated).

example: exclude=amount
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 4
currency string

Canonical uppercase ISO 4217 code.

example: DKK

decimalDigits integer

ISO 4217 minor-unit exponent used for the exact conversion.

example: 2

minorUnits string (integer)

Canonical signed integer minor-unit value.

example: 12345

amount string

Exact fixed-scale major-unit amount.

example: 123.45

Documented examples

Build-generated requests and complete responses
3
Øre to Danish kroner
GET /api/money/from-minor?minor=12345&currency=DKK
{
  "data": {
    "currency": "DKK",
    "decimalDigits": 2,
    "minorUnits": "12345",
    "amount": "123.45"
  },
  "meta": {
    "endpoint": "money",
    "route": "/from-minor",
    "params": {
      "minor": "12345",
      "currency": "DKK"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Yen has no decimal minor unit
GET /api/money/from-minor?minor=2500&currency=JPY
{
  "data": {
    "currency": "JPY",
    "decimalDigits": 0,
    "minorUnits": "2500",
    "amount": "2500"
  },
  "meta": {
    "endpoint": "money",
    "route": "/from-minor",
    "params": {
      "minor": "2500",
      "currency": "JPY"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
One negative Kuwaiti fils
GET /api/money/from-minor?minor=-1&currency=KWD
{
  "data": {
    "currency": "KWD",
    "decimalDigits": 3,
    "minorUnits": "-1",
    "amount": "-0.001"
  },
  "meta": {
    "endpoint": "money",
    "route": "/from-minor",
    "params": {
      "minor": "-1",
      "currency": "KWD"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}

GET /api/money/allocate

Live requestRuns against the public API
No key required
GET/api/money/allocate?amount=10.00&currency=USD&weights=1%2C1%2C1

Request parameters

Canonical decimal amount string (no exponent, separators or leading zeroes). It must already fit the currency's minor-unit precision; no rounding occurs.

Active ISO 4217 currency code, case-insensitive. XDR is rejected because ISO defines no minor unit for it.

Comma-separated positive integer weights (1–20 entries, each at most 999999999).

Advanced response options4 options

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/money/allocate?amount=10.00&currency=USD&weights=1,1,1"
const res = await fetch("https://randomapi.dev/api/money/allocate?amount=10.00&currency=USD&weights=1,1,1");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/money/allocate?amount=10.00&currency=USD&weights=1,1,1").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/money/allocate?amount=10.00&currency=USD&weights=1,1,1"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 3
amount string required

Canonical decimal amount string (no exponent, separators or leading zeroes). It must already fit the currency's minor-unit precision; no rounding occurs.

allowed: 1 – 72
example: amount=123.45
currency string required

Active ISO 4217 currency code, case-insensitive. XDR is rejected because ISO defines no minor unit for it.

allowed: 3 – 3
example: currency=DKK
weights string required

Comma-separated positive integer weights (1–20 entries, each at most 999999999).

allowed: 1 – 199
example: weights=1,1,1
Universal parameters Shared response and formatting options 4
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=currency,decimalDigits
exclude list

Return all fields except these (comma-separated).

example: exclude=allocations
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 6
currency string

Canonical uppercase ISO 4217 code.

example: DKK

decimalDigits integer

ISO 4217 minor-unit exponent used for the exact conversion.

example: 2

amount string

Canonical amount that was allocated.

example: 10.00

minorUnits string (integer)

Exact total in minor units.

example: 1000

totalWeight string (integer)

Sum of all normalized positive weights.

example: 3

allocations object[]

Input-order shares with index, weight, exact minorUnits and fixed-scale amount; their sum equals the input exactly.

example: [{"index":0,"weight":"1","minorUnits":"334","amount":"3.34"},{"index":1,"weight":"1","minorUnits":"333","amount":"3.33"},{"index":2,"weight":"1","minorUnits":"333","amount":"3.33"}]

Documented examples

Build-generated requests and complete responses
3
Split ten dollars three ways
GET /api/money/allocate?amount=10.00&currency=USD&weights=1,1,1
{
  "data": {
    "currency": "USD",
    "decimalDigits": 2,
    "amount": "10.00",
    "minorUnits": "1000",
    "totalWeight": "3",
    "allocations": [
      {
        "index": 0,
        "weight": "1",
        "minorUnits": "334",
        "amount": "3.34"
      },
      {
        "index": 1,
        "weight": "1",
        "minorUnits": "333",
        "amount": "3.33"
      },
      {
        "index": 2,
        "weight": "1",
        "minorUnits": "333",
        "amount": "3.33"
      }
    ]
  },
  "meta": {
    "endpoint": "money",
    "route": "/allocate",
    "params": {
      "amount": "10.00",
      "currency": "USD",
      "weights": "1,1,1"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Weighted Danish invoice shares
GET /api/money/allocate?amount=999.95&currency=DKK&weights=3,2,1
{
  "data": {
    "currency": "DKK",
    "decimalDigits": 2,
    "amount": "999.95",
    "minorUnits": "99995",
    "totalWeight": "6",
    "allocations": [
      {
        "index": 0,
        "weight": "3",
        "minorUnits": "49997",
        "amount": "499.97"
      },
      {
        "index": 1,
        "weight": "2",
        "minorUnits": "33332",
        "amount": "333.32"
      },
      {
        "index": 2,
        "weight": "1",
        "minorUnits": "16666",
        "amount": "166.66"
      }
    ]
  },
  "meta": {
    "endpoint": "money",
    "route": "/allocate",
    "params": {
      "amount": "999.95",
      "currency": "DKK",
      "weights": "3,2,1"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Allocate a negative adjustment
GET /api/money/allocate?amount=-0.05&currency=EUR&weights=1,1
{
  "data": {
    "currency": "EUR",
    "decimalDigits": 2,
    "amount": "-0.05",
    "minorUnits": "-5",
    "totalWeight": "2",
    "allocations": [
      {
        "index": 0,
        "weight": "1",
        "minorUnits": "-3",
        "amount": "-0.03"
      },
      {
        "index": 1,
        "weight": "1",
        "minorUnits": "-2",
        "amount": "-0.02"
      }
    ]
  },
  "meta": {
    "endpoint": "money",
    "route": "/allocate",
    "params": {
      "amount": "-0.05",
      "currency": "EUR",
      "weights": "1,1"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}

About this API

Coverage & behavior

Exact money arithmetic for the operations that should never pass through binary floating point. The endpoint reuses the platform's active ISO 4217 table and performs every calculation with decimal strings and integer arithmetic.

  • /to-minor converts a major-unit string such as 123.45 DKK to 12345. The input must be exactly representable at the currency's ISO minor-unit precision. Excess non-zero decimals are a 400; the API never rounds.
  • /from-minor converts an integer minor-unit string back to a fixed-scale amount (12345 USD123.45; 123 JPY123).
  • /allocate splits an exact amount by 1–20 positive integer weights. It uses largest-remainder allocation with input order as the deterministic tie-breaker, so every returned minor unit sums exactly to the original — including negative amounts.

Amounts are strings on input and output, so values are not constrained by JavaScript's safe-integer range. Scientific notation, grouping separators, leading zeroes and whitespace are rejected instead of guessed. XDR is deliberately unsupported: ISO 4217 defines no minor unit for the Special Drawing Right. This is currency-unit arithmetic only, not exchange-rate conversion, tax advice or localized display formatting.

Use it for

  • Convert checkout amounts to gateway-safe integer minor units without floating-point drift
  • Render stored integer cents, yen or fils as exact fixed-scale decimal strings
  • Allocate invoice totals or discounts proportionally while preserving every final minor unit

Frequently asked questions

Does the API round amounts with too many decimal places?

No. /to-minor rejects any non-zero precision beyond the currency's ISO 4217 minor unit, so no hidden rounding can change the amount.

Can it split an amount without losing a cent?

Yes. /allocate works in integer minor units and distributes remainders deterministically, so the allocations always sum exactly to the input.

Does this endpoint convert between currencies?

No. It converts major and minor units within one currency and performs exact allocation; it never supplies or invents FX rates.

Standards & references