需要在金融仪表板或计算中使用央行利率吗?Current Interest Rates API 可通过一次请求返回利率记录。读完本指南后,你就可以调用端点、读取其 JSON 响应,并在 Python 集成中使用这些数据。
API 返回的内容
Current Interest Rates API 通过 Zyla API Hub 提供利率信息。示例响应将央行利率与其他命名利率分开,并包含一条关于优质利率访问权限的消息。
每条央行记录都包含银行名称、国家、百分比利率和最后更新日期。金融仪表板可以按国家/地区显示这些记录;报告工具则可以将其作为参考数据,与自身计算结果一同使用。
示例响应是历史样本,并不代表当前利率。判断某条记录是否适用于你的应用时,请检查返回的日期。
在 Zyla API Hub 上开始使用
- 打开本文末尾链接所指向的 The Current Interest Rates API 市场页面。
- 如有需要,创建一个免费的 Zyla 账户,然后在可用时选择 Subscribe 或 Start Free Trial。
- 获取 API 密钥,并在向 Hub 端点发送请求时将其用作 bearer token。
Zyla 采用订阅和配额模式,而非按次付费。对于首个 API,访问权限可能包含 7 天试用或 50 次请求;请查看 API 页面,了解当前的访问选项和定价。不要将 API 密钥提交到源代码管理系统,也不要放入客户端代码。
获取利率信息
Get Interest Rate 端点使用 GET 方法。运行该端点即可获取利率信息;此请求需要授权标头,本示例中没有记录请求参数。
将 YOUR_API_KEY 替换为你的 Zyla API 密钥:
curl -s -X GET "https://zylalabs.com/api/2083/the-current-interest-rates-api/1866/get-interest-rate" \
-H "Authorization: Bearer YOUR_API_KEY"
以下是官方示例响应:
{
"central_bank_rates": [
{
"central_bank": "Australian Central Bank",
"country": "Australia",
"rate_pct": 4.35,
"last_updated": "11-08-2023"
},
{
"central_bank": "British Central Bank",
"country": "United Kingdom",
"rate_pct": 4.75,
"last_updated": "11-07-2024"
},
{
"central_bank": "Chilean Central Bank",
"country": "Chile",
"rate_pct": 5,
"last_updated": "12-17-2024"
},
{
"central_bank": "Chinese Central Bank",
"country": "China",
"rate_pct": 3.1,
"last_updated": "10-21-2024"
},
{
"central_bank": "Czech Central Bank",
"country": "Czech Republic",
"rate_pct": 4,
"last_updated": "11-07-2024"
},
{
"central_bank": "Danish Central Bank",
"country": "Denmark",
"rate_pct": 2.75,
"last_updated": "12-12-2024"
},
{
"central_bank": "Japanese Central Bank",
"country": "Japan",
"rate_pct": 0.25,
"last_updated": "07-31-2024"
},
{
"central_bank": "Mexican Central Bank",
"country": "Mexico",
"rate_pct": 10,
"last_updated": "12-19-2024"
},
{
"central_bank": "New Zealand Central Bank",
"country": "New Zealand",
"rate_pct": 4.25,
"last_updated": "11-27-2024"
},
{
"central_bank": "Norwegian Central Bank",
"country": "Norway",
"rate_pct": 4.5,
"last_updated": "12-14-2023"
},
{
"central_bank": "Polish Central Bank",
"country": "Poland",
"rate_pct": 5.75,
"last_updated": "10-04-2023"
},
{
"central_bank": "Russian Central Bank",
"country": "Russia",
"rate_pct": 21,
"last_updated": "10-25-2024"
},
{
"central_bank": "Saudi Arabian Central Bank",
"country": "Saudi Arabia",
"rate_pct": 5,
"last_updated": "12-18-2024"
},
{
"central_bank": "Swedish Central Bank",
"country": "Sweden",
"rate_pct": 2.5,
"last_updated": "12-19-2024"
},
{
"central_bank": "Swiss Central Bank",
"country": "Switzerland",
"rate_pct": 0.5,
"last_updated": "12-12-2024"
},
{
"central_bank": "Turkish Central Bank",
"country": "Türkiye",
"rate_pct": 47.5,
"last_updated": "12-27-2024"
}
],
"non_central_bank_rates": [
{
"name": "ESTER",
"rate_pct": 2.917,
"last_updated": "01-10-2025"
},
{
"name": "SARON",
"rate_pct": 0.432889,
"last_updated": "01-09-2025"
},
{
"name": "SONIA",
"rate_pct": 4.7,
"last_updated": "01-09-2025"
},
{
"name": "TONAR",
"rate_pct": 0.232,
"last_updated": "01-09-2025"
}
],
"prime_rates": "Prime rates are only available to premium subscribers."
}
对于以 central_bank 和 country 标识的记录,请使用 central_bank_rates。对于以 name 标识的记录,请使用 non_central_bank_rates。在这两个数组中,rate_pct 均以百分比表示,last_updated 则是对应的日期。
样本日期不包含时间或时区,因此不要将其视为精确时间戳。样本还将 prime_rates 作为消息而非利率列表返回;请据此处理该值,并查看 API 页面了解访问选项。
在 Python 中读取利率
此示例使用 Python 标准库调用相同的 Hub URL。它会分别打印央行和非央行记录,并保留每条记录的返回日期及利率。
import json
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
url = "https://zylalabs.com/api/2083/the-current-interest-rates-api/1866/get-interest-rate"
request = Request(url, method="GET")
request.add_header("Authorization", "Bearer YOUR_API_KEY")
try:
with urlopen(request, timeout=30) as response:
data = json.load(response)
except HTTPError as exc:
sys.exit("API request failed with HTTP status: " + str(exc.code))
except URLError as exc:
sys.exit("Could not reach the API: " + str(exc.reason))
except (json.JSONDecodeError, UnicodeDecodeError):
sys.exit("The API response could not be read as JSON.")
for rate in data.get("central_bank_rates", []):
print(
rate.get("country"),
rate.get("central_bank"),
rate.get("rate_pct"),
rate.get("last_updated"),
)
for rate in data.get("non_central_bank_rates", []):
print(
rate.get("name"),
rate.get("rate_pct"),
rate.get("last_updated"),
)
print("Prime rates:", data.get("prime_rates"))
运行脚本前,请替换 YOUR_API_KEY。对于已部署的服务,请从服务器的密钥存储中读取密钥,而不要将其提交到应用程序中。此示例中的超时是客户端设置,并非 API 限制。
如果应用只需要某个国家/地区的数据,请在本地按 country 筛选返回的 central_bank_rates。请将银行名称和日期与数值一同保留,避免界面显示的百分比缺少上下文。
在金融工作流中使用数据
央行利率仪表板可以同时显示国家/地区、银行、百分比和最后更新日期。请将单独的非央行数组放在独立区域中:不能仅仅因为两者都使用 rate_pct,就把命名参考利率和央行利率当作可以互换的数据来展示。
对于内部财务报告,请保留每条记录显示的响应日期,并单独记录应用检索数据的时间。检索时间描述的是你的集成情况,不能替代 API 的 last_updated 值。
如果缓存响应,请根据用户对数据的依赖程度和订阅配额选择刷新策略。在界面中显示返回的日期,并避免暗示缓存值反映了刚刚公布的利率。示例并未说明更新计划,也不保证所有记录的更新日期相同。
进行计算时,请记住返回的数值是百分比。仅在自身公式需要时进行转换;在缺少其他背景信息的情况下,不要将央行利率视为客户的贷款利率或存款利率。
从 AI 智能体调用
Zyla API 也可以从兼容 MCP 的客户端调用,包括 Claude Code、Cursor 和 Windsurf。将客户端配置为使用 https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY,并将 YOUR_API_KEY 替换为你的密钥。请参阅 MCP,了解 Hub 端点。
请让智能体检索利率信息,并报告银行或利率名称、百分比和返回日期。在将其答案用于金融计算前,请核实日期和利率类别;智能体的摘要不应将样本中关于优质利率访问权限的消息误作数值利率。
常见问题
我可以只请求某个国家/地区的利率吗?
文档示例中没有国家/地区请求参数。请获取响应,然后在应用中筛选 central_bank_rates 数组。
rate_pct 是小数还是百分比?
它表示百分比。显示数值时请明确标注单位;如果计算需要小数,则应显式转换。
响应是否包含时间戳或时区?
示例中的 last_updated 是日期字符串,不包含时间或时区。不要据此推断精确的更新时间。
响应中包含优质利率吗?
示例返回一条消息,说明优质利率仅对高级订阅用户开放。请查看 API 页面了解当前访问选项和定价,不要将示例消息误认为利率。
在市场商品页面创建免费账户并获取 API 密钥。查看可用的访问选项,然后开始试用 The Current Interest Rates API,享受 7 天试用期。