首页 开发文档 存款利息计算

存款利息计算

存款利息计算工具。支持活期(按日计息、季度结息)、定期整存整取、大额存单与通知存款四种类型,可指定存期天数或月数,并可选择单利或复利计息。采用银行业惯例的 360 天计息基准,利息 = 本金 × 年利率 × 实际天数 ÷ 360。适合存款收益对比与理财规划。

请求信息
请求地址 https://cx4.cn/openApi/finance/deposit 复制
请求方式 GET / POST
接口标识 finance_deposit
鉴权方式 必须
四种方式任选其一:Header「X-Api-Key」/ Header「Authorization: Bearer 你的key」/ URL 参数「?key=你的key」/ POST 参数「key」
请求参数
参数名 类型 必填 说明 示例
amount float 是 存款本金 100000
annual_rate float 是 年利率百分比,0-100(也可用 rate 传) 1.75
type string 否 current 活期 / fixed 定期整存整取 / large 大额存单 / notice 通知存款 fixed
days int 否 实际存款天数,优先于 months 180
months int 否 存期月数,days 为空时生效 12
compound int 否 是否复利计息:1 复利 / 0 单利(默认) 0
返回参数

下表字段位于返回结构的 data 内;外层 code / message 为全平台统一格式,不在此重复列出。

参数名 类型 说明 示例
ok bool 是否成功 true
type string 存款类型 fixed
amount float 本金 100000
annual_rate float 年利率百分比 1.75
days int 计息天数 360
years float 折算年数 0.99
compound bool 是否复利 false
interest float 利息 1730.14
total float 到期本息合计 101730.14
daily_interest float 日均利息 4.81
note string 规则说明 按 360 天计息,不足整年按实际天数折算
返回示例

成功

{
    "code": 200,
    "message": "操作成功",
    "data": {
        "ok": true,
        "type": "fixed",
        "amount": 100000,
        "annual_rate": 1.75,
        "days": 360,
        "years": 1,
        "compound": false,
        "interest": 1750,
        "total": 101750,
        "daily_interest": 4.86,
        "note": "人民币存款计息按年 360 天、每月 30 天计算,未扣除利息税(目前暂免征收)"
    }
}

失败

{
    "code": 400,
    "message": "本金必须大于 0",
    "data": null
}
平台通用状态码
状态码 说明
200调用成功
400缺少必填参数或参数格式有误
401密钥缺失或无效
402余额不足,请充值后重试
403未开通该接口,请在本页开通后调用
404接口不存在或已下架
429触发限流,请稍后重试
500接口调用失败(已扣款的会自动退款)
调用示例

cURL 复制

curl -X POST "https://cx4.cn/openApi/finance/deposit" -H "X-Api-Key: 你的SecretKey" -d "amount=100000&annual_rate=1.75&type=fixed&days=180&months=12&compound=0"

JavaScript 复制

fetch('https://cx4.cn/openApi/finance/deposit', {
  method: 'POST',
  headers: {
    'X-Api-Key': '你的SecretKey',
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: 'amount=100000&annual_rate=1.75&type=fixed&days=180&months=12&compound=0'
})
.then(res => res.json())
.then(data => console.log(data));

PHP 复制

post('https://cx4.cn/openApi/finance/deposit', [
    'headers' => ['X-Api-Key' => '你的SecretKey'],
    'form_params' => ['amount' => '100000', 'annual_rate' => '1.75', 'type' => 'fixed', 'days' => '180', 'months' => '12', 'compound' => '0'],
]);
echo $response->getBody();

Java 复制

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://cx4.cn/openApi/finance/deposit"))
    .header("X-Api-Key", "你的SecretKey")
    .header("Content-Type", "application/x-www-form-urlencoded")
    .POST(HttpRequest.BodyPublishers.ofString("amount=100000&annual_rate=1.75&type=fixed&days=180&months=12&compound=0"))
    .build();
HttpResponse response = client.send(
        request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

Python 复制

import requests

res = requests.post('https://cx4.cn/openApi/finance/deposit',
    headers={'X-Api-Key': '你的SecretKey'},
    data={'amount': '100000', 'annual_rate': '1.75', 'type': 'fixed', 'days': '180', 'months': '12', 'compound': '0'})
print(res.json())
在线测试 (使用你的密钥真实调用,计费与正常调用一致)

登录后可在线测试: 立即登录

计费说明

¥0.0010

每次调用


每日免费额度:100 次

累计调用:6 次


快速上手

1. 注册并完成邮箱验证:立即注册

2. 登录后复制 Secret Key:去登录

3. 点击右侧「开通接口」按钮

4. 用下方「在线测试」一键体验,或复制下方示例代码直接调用