比较跨地区报价的折算成本
POST
/fx/compare公开访问curl
合并消费税、换汇费、礼品卡折扣、手工汇率与计费周期。按折算成本从低到高排名。baseline 是基准报价的零起始索引。税费和折扣使用百分数,手工汇率表示每单位报价货币可换得的基准货币数量。一次性报价单独比较。 访问类别:匿名 API,可携带 Token 使用独立额度
请求参数
_formatquery- 响应格式为 json 或 text;_format=svg 返回 JSON。plain 是 text 的别名。未识别的值继续按 Accept 协商。
- string · 可选:json、text
_colorquery- 控制 text 响应的 ANSI 颜色。0、false、off、no 关闭;省略或其他值保留。
- string · 可选:0、false、off、no
请求体
application/jsonbase必填- string · 格式:^[A-Z0-9]{2,12}$/i
basis必填- string · 可选:once、month、year
baseline- integer · 默认值:0 · 最小值:0
tax- 消费税百分比,例如 8.5 表示 8.5%
fee- 换汇手续费用百分比
discount- 礼品卡折扣百分比,例如 15 表示实际支付 85%
quotes必填- array
响应
application/json
{
"type": "object",
"properties": {
"base": {
"type": "string",
"pattern": "^[A-Z0-9]{2,12}$/i"
},
"basis": {
"type": "string",
"enum": [
"once",
"month",
"year"
]
},
"baseline": {
"type": "integer"
},
"snapshot": {
"type": [
"object",
"null"
],
"properties": {
"base": {
"type": "string",
"pattern": "^[A-Z0-9]{2,12}$/i"
},
"source": {
"type": "string",
"enum": [
"fawaz-jsdelivr",
"fawaz-pages",
"ecb"
]
},
"rateDate": {
"type": "string",
"format": "date"
},
"updatedAt": {
"type": "string",
"format": "date-time"
},
"stale": {
"type": "boolean"
}
},
"required": [
"base",
"source",
"rateDate",
"updatedAt",
"stale"
]
},
"rows": {
"type": "array",
"items": {
"type": "object",
"properties": {
"index": {
"type": "integer"
},
"rank": {
"type": "integer"
},
"region": {
"type": "string"
},
"currency": {
"type": "string",
"pattern": "^[A-Z0-9]{2,12}$/i"
},
"amount": {
"type": "string"
},
"period": {
"type": "string",
"enum": [
"once",
"day",
"week",
"month",
"quarter",
"year"
]
},
"total": {
"type": "string"
},
"rate": {
"type": "string"
},
"rateSource": {
"type": "string",
"enum": [
"identity",
"manual",
"snapshot"
]
},
"versusBaseline": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"percent": {
"type": [
"string",
"null"
]
}
},
"required": [
"amount",
"percent"
]
},
"versusHighest": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"percent": {
"type": [
"string",
"null"
]
}
},
"required": [
"amount",
"percent"
]
}
},
"required": [
"index",
"rank",
"region",
"currency",
"amount",
"period",
"total",
"rate",
"rateSource",
"versusBaseline",
"versusHighest"
]
}
}
},
"required": [
"base",
"basis",
"baseline",
"snapshot",
"rows"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}响应示例
成功响应
printf '%s' '{"base":"CNY","basis":"month","tax":"0","fee":"0","discount":"0","baseline":0,"quotes":[{"region":"美区","currency":"USD","amount":"20","period":"month"},{"region":"土区","currency":"TRY","amount":"499.99","period":"month","discount":"15"}]}' | curl -sS --json @- https://oit.sh/fx/compareHTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"base": "CNY",
"basis": "month",
"baseline": 0,
"snapshot": {
"base": "USD",
"source": "fawaz-jsdelivr",
"updatedAt": "2026-11-16T03:23:16.950Z",
"rateDate": "2026-11-15",
"stale": false
},
"rows": [
{
"index": 1,
"rank": 1,
"region": "土区",
"currency": "TRY",
"amount": "499.99",
"period": "month",
"total": "56.22313297728378",
"rate": "0.1322923704998424",
"rateSource": "snapshot",
"versusBaseline": {
"amount": "77.21069242271622",
"percent": "57.86"
},
"versusHighest": {
"amount": "77.21069242271622",
"percent": "57.86"
}
},
{
"index": 0,
"rank": 2,
"region": "美区",
"currency": "USD",
"amount": "20",
"period": "month",
"total": "133.4338254",
"rate": "6.67169127",
"rateSource": "snapshot",
"versusBaseline": {
"amount": "0",
"percent": "0.00"
},
"versusHighest": {
"amount": "0",
"percent": "0.00"
}
}
]
}错误示例
curl -sS --json '{}' https://oit.sh/fx/compareHTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"error": {
"code": "INVALID_INPUT",
"message": "参数无效",
"issues": [
{
"location": "body",
"field": "base",
"code": "invalid_type",
"message": "需要 字符串 类型"
},
{
"location": "body",
"field": "basis",
"code": "invalid_value",
"message": "允许值:once、month、year"
},
{
"location": "body",
"field": "quotes",
"code": "invalid_type",
"message": "需要 数组 类型"
}
]
}
}curl 访问示例
curl、wget、HTTPie 默认得到 text/plain。示例展示纯文本输出。
命令与输出
printf '%s' '{"base":"CNY","basis":"month","tax":"0","fee":"0","discount":"0","baseline":0,"quotes":[{"region":"美区","currency":"USD","amount":"20","period":"month"},{"region":"土区","currency":"TRY","amount":"499.99","period":"month","discount":"15"}]}' | curl -sS --json @- 'https://oit.sh/fx/compare?_color=0&_format=text'HTTP 200 content-type: text/plain; charset=utf-8 content-encoding: gzip cache-control: no-store 排名 | 地区 | CNY · 等效每月 | 较基准节省 | 较最高节省 -----+------+-------------------+----------------------------+--------------------------- 1 | 土区 | 56.22313297728378 | 77.21069242271622 (57.86%) | 77.21069242271622 (57.86%) Best Deal 2 | 美区 | 133.4338254 | 0 (0.00%) | 0 (0.00%) 汇率来源: fawaz-jsdelivr 报价日期: 2026-11-15 更新时间: 2026-11-16T03:23:16.950Z
在线调试
curl -X POST 'https://oit.sh/fx/compare' \
-H 'Content-Type: application/json' \
--data-raw '{"base":"CNY","basis":"month","baseline":0,"tax":"0","fee":"0","discount":"0","quotes":[{"region":"美区","currency":"USD","amount":"20","period":"month"},{"region":"土区","currency":"TRY","amount":"499.99","period":"month","discount":"15"}]}'响应
等待发送请求