技术博客
银行汇率查询:用"币种列表"接入点为前端做货币选择器

银行汇率查询:用"币种列表"接入点为前端做货币选择器

作者: 万维易源
2026-08-27
银行汇率查询币种列表货币选择器
# 银行汇率查询:用"币种列表"接入点为前端做货币选择器 > 接口:银行汇率查询(apiCode=105)· 接入点:外汇牌价币种列表(105-35)· 免费 · 请求方式:POST/GET · 返回格式:JSON · 适用人群:前端 / 全栈开发者 · 阅读时间:约 4 分钟 ## TL;DR - 币种列表接入点(105-35)无业务参数,返回全部支持货币的 `flag`(国旗图)、`name`、`code`。 - 用它动态生成下拉框,避免硬编码货币代码导致与接口不一致。 - 返回结构与实时/转换接入点解耦,可独立缓存。 ## Why 做汇率查询页、换算器时,下拉框里的货币选项从哪来?硬编码一份容易和接口支持的货币对不上。币种列表接入点直接把官方支持的全部货币(含国旗图、中文名、ISO 代码)给你,前端拿它渲染即可,后续接口扩货币你无需改代码。 ## What | 项目 | 说明 | |------|------| | 接口地址 | `https://route.showapi.com/105-35?appKey=YOUR_APPKEY` | | 业务参数 | 无 | | 返回字段 | `exchange_list[].{flag, name, code}` | | 用途 | 动态生成货币选择器、校验用户输入的 code 是否合法 | ## How ### 步骤:拉取币种全集并渲染下拉框 **Python(requests)** ```python import requests js = requests.post( "https://route.showapi.com/105-35", params={"appKey": "YOUR_APPKEY"}, timeout=10 ).json() codes = {} if js.get("showapi_res_code") == 0 and js["showapi_res_body"].get("ret_code") == 0: for item in js["showapi_res_body"]["exchange_list"]: codes[item["code"]] = item["name"] print(item["code"], item["name"], item["flag"]) ``` **cURL** ```bash curl -X POST "https://route.showapi.com/105-35?appKey=YOUR_APPKEY" \ -H "content-type: application/x-www-form-urlencoded" ``` **Node.js(fetch)** ```javascript const res = await fetch("https://route.showapi.com/105-35?appKey=YOUR_APPKEY", { method: "POST" }); const js = await res.json(); if (js.showapi_res_code === 0 && js.showapi_res_body.ret_code === 0) { for (const it of js.showapi_res_body.exchange_list) { console.log(it.code, it.name); } } ``` ### 前端下拉框片段 ```html <select id="currency"></select> <script> fetch("https://route.showapi.com/105-35?appKey=YOUR_APPKEY", { method: "POST" }) .then(r => r.json()) .then(js => { const sel = document.getElementById("currency"); for (const it of js.showapi_res_body.exchange_list) { const o = document.createElement("option"); o.value = it.code; o.textContent = `${it.name} (${it.code})`; sel.appendChild(o); } }); </script> ``` ## 返回示例与解析 ```json { "showapi_res_body": { "ret_code": 0, "exchange_list": [ { "flag": "http://res-showapi.oss-cn-hangzhou.aliyuncs.com/exchange/英国国旗.png", "name": "英镑", "code": "GBP" } ] } } ``` | 字段 | 含义 | |------|------| | `flag` | 货币对应国旗图片地址(OSS 链接) | | `name` | 货币中文名 | | `code` | 货币 ISO 代码(如 GBP) | ## 进阶 / 边界 - `flag` 是外链图片,前端直接 `<img src>` 即可,但注意跨域与加载失败兜底(可回退到文字 code)。 - 币种集合变化频率极低,可缓存较长时间(如一天),配合[缓存策略](https://www.showapi.com/guides/exchange-rate-cache-105)减少调用。 ## FAQ **Q:币种列表会和实时查询的货币对不上吗?** 应以本接入点返回的 code 集合为准;实时/转换接入点只接受其中支持的货币。 **Q:flag 图片加载慢或失败怎么办?** 用文字 code 兜底展示,或在本地维护一份 code→国旗的映射缓存。 **Q:这个接入点要传参数吗?** 不需要业务参数,直接 POST 即可。 ## 相关能力 / 下一步阅读 - [银行汇率查询:用 HTML+JS 做一个实时汇率查询小工具(可直接运行 Demo)](https://www.showapi.com/guides/exchange-rate-web-demo-105) - [银行汇率查询:5 分钟接入——从注册到第一次实时汇率查询](https://www.showapi.com/guides/exchange-rate-quickstart-105) - **本系列共 13 篇**:查看[银行汇率查询指南总目录](https://www.showapi.com/guides/exchange-rate-guides-105)