跳转到内容
POST AI agent ready /v1/number/format

数字格式 API - 免费区域设置格式

使用小数点分隔符、分组、货币符号和百分比表示法的区域设置特定规则来格式化数字。 由 Intl.NumberFormat 标准提供支持。

Parameters

numberrequired

The number to format.

string

BCP 47 locale tag.

string

Formatting style.

string

ISO 4217 currency code (required when style is "currency").

Code examples

curl -X POST https://api.botoi.com/v1/number/format \
  -H "Content-Type: application/json" \
  -d '{"number":1234567.89,"locale":"de-DE","style":"currency","currency":"EUR"}'

When to use this API

国际化定价显示

在用户区域设置产品价格格式,以便德国客户看到 1.234,56 欧元,而美国客户看到 1,234.56 美元。

报告生成

在客户端 Intl API 不可用的情况下,在服务器端 PDF 或电子邮件报告中格式化财务数据。

Frequently asked questions

支持哪些区域设置?
ICU 库支持的所有 BCP 47 区域设置标记,包括 en-US、de-DE、ja-JP、ar-SA 等数百个。
使用货币样式时需要传递货币吗?
是的。 当样式为“货币”时,需要货币参数。 如果缺少,API 将返回错误。
我可以设置百分比格式吗?
是的。 将样式设置为“百分比”并将数字作为小数传递(例如,0.85 表示 85%)。
这可以处理非常大的数字吗?
是的。 API 支持最大 Number.MAX_SAFE_INTEGER (9,007,199,254,740,991) 的数字。 对于较大的值,请将它们作为字符串传递。

Get your API key

Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.