decimal_places field. The
discriminator rule below
covers both.
This is the single most common integration mistake with the Jinko API, and it is
easy to miss: 15977 is a plausible long-haul business fare, so a page full of
wrong prices looks like real data rather than a unit bug.
Convert it
Not every currency has 2 decimals
decimal_places usually matches the currency’s ISO 4217 digits:
Hardcoding
/ 100 renders JPY and KRW 100× too small and Kuwaiti dinar
10× too high.
One rule: decimal_places is the discriminator
Depending on the endpoint, the integer field may be named value or amount,
and some endpoints return plain decimal numbers. One rule covers everything:
If the money object carriesdecimal_places, its number is an integer in minor units — divide by10 ** decimal_places(whether the field is namedvalueoramount). If there is nodecimal_places— a bare number with a separate currency — it is already in major units: display as-is.
value and amount never appear together on one object — they come from
different backend shapes, not two views of the same number.
Apply the rule to the actual response object, not to the schema or this
table. The OpenAPI schemas mark
decimal_places as optional on every
money shape (they describe the union of endpoints), so generated types
always show decimal_places?: number — including for endpoints that never
send it at runtime, such as checkout totals. Branch on whether the field is
present in the response you received; the endpoint column above only
describes today’s runtime behaviour.Arithmetic: sum before you divide
When totalling several prices — legs of a trip, travelers in a group, a cart with flights and hotels — add the minor-unit integers and convert once at the end. Converting first introduces floating-point drift that shows up as totals being a cent off:currency and a decimal_places —
Jinko can return different currencies in one response (for example a
multi-provider trip), and converted prices can carry a different scale.
Rescale first if the decimal_places differ.
Common mistakes
Using the CLI or SDK?
The same rules apply unchanged.@gojinko/cli output (JSON is its default
format) and @gojinko/api-client responses are the raw API body — neither
converts money for you. A jinko flight-search --format json result carries the
same { value, currency, decimal_places } objects described above; a
jinko checkout total is the same major-units { amount, currency }.
Prices look 100× too high?
That symptom has exactly one common cause:value was rendered without
dividing by 10 ** decimal_places. Check the raw JSON — if you see
"value": 15977, "decimal_places": 2 for a fare you expect to be ~$160, that’s
it.
The mirror symptom — prices looking 100× too small — is usually a hardcoded
/ 100 applied to a decimal_places: 0 currency such as JPY.