Convert prices

Converts amounts from a source currency to a destination country's local currency using live exchange rates. Returns converted amounts in minor units and locale-formatted display strings.

POST
/sdk/server/prices/convert
X-Stash-Api-Key<token>

API key authentication for server-side SDK operations. Used for secure server-to-server communication.

In: header

ConvertPricesRequest converts amounts from a source currency to a destination country's local currency.

Amounts use "minor units" (the smallest denomination of a currency as defined by ISO 4217) rather than "cents" because not all currencies subdivide into 100ths. The term "cent" implies 1/100th, which is incorrect for many currencies:

  • Zero-decimal currencies have no subdivision at all. JPY, KRW, VND, CLP, ISK, HUF, UGX, RWF, PYG, GNF, XOF, XAF, KMF, DJF, BIF. For these, amount 100 means 100 whole units (e.g., ¥100), not 1.00.

  • Three-decimal currencies subdivide into 1000ths, not 100ths. BHD (fils), KWD (fils), OMR (baisa), JOD (fils), TND (millimes). For these, amount 1000 means 1.000 (one whole unit), not 10.00.

The decimal_places field in the response tells callers how to interpret the destination_amount: divide by 10^decimal_places to get the human-readable value. For example: amount 100 with decimal_places 2 = 1.00, amount 100 with decimal_places 0 = 100, amount 1000 with decimal_places 3 = 1.000.

sourceCurrencystring

ISO-4217 source currency code (e.g., 'USD'). Currently only 'USD' is supported.

destinationCountrystring

ISO-3166-1 alpha-2 destination country code (e.g., 'DE', 'JP', 'PL'). Used to resolve the destination currency via CLDR.

amountsarray<integer>

Amounts in minor units of the source currency per ISO 4217. For USD (2 decimals): 100 = $1.00. For JPY (0 decimals): 100 = ¥100. For BHD (3 decimals): 1000 = 1.000 BHD. All values must be greater than 0. See message comment for why this field uses 'amounts' instead of 'cents'.

Response Body

curl -X POST "https://test-api.stash.gg/sdk/server/prices/convert" \  -H "Content-Type: application/json" \  -d '{    "sourceCurrency": "string",    "destinationCountry": "string",    "amounts": [      0    ]  }'
{
  "sourceCurrency": "string",
  "destinationCurrency": "string",
  "conversions": [
    {
      "sourceAmount": 0,
      "destinationAmount": 0,
      "displayPrice": "string",
      "decimalPlaces": 0
    }
  ]
}
{
  "code": 0,
  "message": "string",
  "details": [
    {
      "@type": "string",
      "property1": null,
      "property2": null
    }
  ]
}

How is this guide?