首页 开发文档 个税计算

个税计算

按 2019 年起施行的累计预扣法计算工资薪金个人所得税:累计收入减去累计减除费用(起征点 × 月数)、三险一金、专项附加扣除与其他扣除后得到累计应纳税所得额,套用年度税率表算出累计税额,再减去前期已缴得到本月应缴。action=year 时一次性返回 12 个月明细与全年合计,可直观看到税率跳档月份。

请求信息
请求地址 https://cx4.cn/openApi/finance/tax 复制
请求方式 GET / POST
接口标识 finance_tax
鉴权方式 必须
四种方式任选其一:Header「X-Api-Key」/ Header「Authorization: Bearer 你的key」/ URL 参数「?key=你的key」/ POST 参数「key」
请求参数
参数名 类型 必填 说明 示例
monthly float 是 月税前收入(元) 15000
social float 否 每月三险一金等专项扣除 1500
special float 否 每月专项附加扣除(房贷、子女教育等) 2000
other float 否 每月其他扣除 0
threshold float 否 起征点(元) 5000
month int 否 计算第几个月 1-12,action=month 时生效 6
action string 否 month 指定月份 / year 全年 12 个月明细 month
返回参数

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

参数名 类型 说明 示例
ok bool 是否成功 true
action string 计算方式 month
month int 计算的月份 6
monthly float 月税前收入 15000
threshold float 起征点 5000
cum_income float 累计收入 90000
cum_deduction float 累计扣除 51000
cum_taxable float 累计应纳税所得额 39000
rate float 适用税率 0.1
quick_deduction float 速算扣除数 2520
cum_tax float 累计应缴税额 1380
current_tax float 本月应缴税额 630
after_tax float 本月到手(已扣社保) 12870
effective_rate float 实际税负百分比 4.2
year_tax float 全年税额,action=year 时返回 5280
detail array 12 个月明细,action=year 时返回 []
返回示例

成功

{
    "code": 200,
    "message": "操作成功",
    "data": {
        "ok": true,
        "action": "month",
        "month": 6,
        "monthly": 15000,
        "social": 1500,
        "special": 2000,
        "other": 0,
        "threshold": 5000,
        "cum_income": 90000,
        "cum_deduction": 51000,
        "cum_taxable": 39000,
        "rate": 0.1,
        "quick_deduction": 2520,
        "cum_tax": 1380,
        "current_tax": 405,
        "after_tax": 13095,
        "effective_rate": 2.7
    }
}

失败

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

cURL 复制

curl -X POST "https://cx4.cn/openApi/finance/tax" -H "X-Api-Key: 你的SecretKey" -d "monthly=15000&social=1500&special=2000&other=0&threshold=5000&month=6&action=month"

JavaScript 复制

fetch('https://cx4.cn/openApi/finance/tax', {
  method: 'POST',
  headers: {
    'X-Api-Key': '你的SecretKey',
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: 'monthly=15000&social=1500&special=2000&other=0&threshold=5000&month=6&action=month'
})
.then(res => res.json())
.then(data => console.log(data));

PHP 复制

post('https://cx4.cn/openApi/finance/tax', [
    'headers' => ['X-Api-Key' => '你的SecretKey'],
    'form_params' => ['monthly' => '15000', 'social' => '1500', 'special' => '2000', 'other' => '0', 'threshold' => '5000', 'month' => '6', 'action' => 'month'],
]);
echo $response->getBody();

Java 复制

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://cx4.cn/openApi/finance/tax"))
    .header("X-Api-Key", "你的SecretKey")
    .header("Content-Type", "application/x-www-form-urlencoded")
    .POST(HttpRequest.BodyPublishers.ofString("monthly=15000&social=1500&special=2000&other=0&threshold=5000&month=6&action=month"))
    .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/tax',
    headers={'X-Api-Key': '你的SecretKey'},
    data={'monthly': '15000', 'social': '1500', 'special': '2000', 'other': '0', 'threshold': '5000', 'month': '6', 'action': 'month'})
print(res.json())
在线测试 (使用你的密钥真实调用,计费与正常调用一致)

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

计费说明

¥0.0010

每次调用


每日免费额度:100 次

累计调用:8 次


快速上手

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

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

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

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