| 参数 | 值 |
|---|---|
| appid | 开通后系统自动分配 |
| sign | 开通后系统自动分配 |
| 参数 | 是否必填 | 类型 | 可选值范围 | 说明 |
|---|---|---|---|---|
| keywords | 是 | string | 银行名称中的关键词 | 如:招行深圳前海。 注意:不少于5位汉字 |
| page | 否 | int | 1~10 | 分页信息, 第几页, 最多10页。 每页最多展示10条数据 |
function get_cnaps_ai($keywords = '', $page = 1) {
// 1. 基础 URL
$baseUrl = 'https://api.cwjyz.com.cn/bank/cnaps_ai';
// 【重要】请替换为你真实的 AppId 和 Sign
$appid = "你的真实AppId";
$sign = "你的真实Sign";
// 2. 构建参数字典
$params = array(
'appid' => $appid,
'sign' => $sign,
'keywords' => $keywords,
'page' => $page
);
// 3. 拼接查询字符串
$queryString = http_build_query($params);
$fullUrl = $baseUrl . '?' . $queryString;
// 4. 初始化 CURL
$curl = curl_init();
// 5. 设置 CURL 选项
curl_setopt($curl, CURLOPT_URL, $fullUrl);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 开发环境跳过证书验证
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, null);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
// 6. 执行请求
$output = curl_exec($curl);
// 7. 网络层错误处理
if ($output === false) {
$error = curl_error($curl);
curl_close($curl);
return ["success" => false, "error" => "网络连接失败: " . $error];
}
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
// 8. 业务层状态码处理
if ($httpCode != 200) {
return ["error" => "HTTP Status: " . $httpCode, "response" => $output];
}
// 9. 解析 JSON
return = json_decode($output, true);
}
import okhttp3.*;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class CnapsAiClient {
// 创建全局 OkHttpClient 实例 (建议单例,可复用连接池)
private static final OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(5, TimeUnit.SECONDS)
.build();
public static void main(String[] args) {
String host = "api.cwjyz.com.cn"; // 注意:host 不需要带 https://
String path = "/bank/cnaps_ai"; // 接口路径
// 【重要】请替换为你真实的 AppId 和 Sign
String appid = "你的真实AppId";
String sign = "你的真实Sign";
// 构建带有查询参数的 URL
HttpUrl url = new HttpUrl.Builder()
.scheme("https")
.host(host)
.addPathSegments(path.substring(1)) // 去掉路径开头的 "/"
.addQueryParameter("appid", appid)
.addQueryParameter("sign", sign)
.addQueryParameter("keywords", "浦发银行深圳南山支行")
.addQueryParameter("page", "1")
.build();
// 构建请求对象
Request request = new Request.Builder()
.url(url)
.get()
.build();
try {
// 执行请求
try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new IOException("请求失败,HTTP 状态码: " + response.code() +
", 响应内容: " + response.body().string());
}
String responseBody = response.body().string();
System.out.println("请求成功,返回结果:");
System.out.println(responseBody);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
import urllib.request
import urllib.parse
import json
# API 配置
host = 'https://api.cwjyz.com.cn'
path = '/bank/cnaps_ai'
# 替换为你的实际凭证和查询条件
appid = '您自己的Appid'
sign = '您自己的Sign'
keywords = "招商银行上海宝山支行"
page = 1
# 构建查询参数(自动 URL 编码)
params = {
'appid': appid,
'sign': sign,
'keywords': keywords,
'page': page
}
query_string = urllib.parse.urlencode(params)
url = host + path + '?' + query_string
# 创建请求对象
request = urllib.request.Request(url)
with urllib.request.urlopen(request) as response:
content = response.read().decode('utf-8')
# 解析 JSON 响应
data = json.loads(content)
# 打印格式化后的响应
print("原始响应内容:")
print(json.dumps(data, ensure_ascii=False, indent=2))
| 字段 | 是否必备 | 类型 | 说明 |
|---|---|---|---|
| code | 是 | int | 状态码: - 200 请求成功,返回数据 - 203 请求成功,但page当前页超总页数 - 204 请求成功,查无数据 |
| msg | 是 | string | 提示信息 |
| query_id | 是 | bigint | 唯一的请求编号 |
| remaining | 否 | int | 该API接口剩余可使用次数。注:调用成功且返回数据才扣减次数 |
| result | 否 | array | 数据结果 |
| + total_items | 否 | int | 符合条件的元素总数 |
| + page_items | 否 | int | 当前页包含元素个数 |
| + curr_page | 否 | int | 当前页 |
| + total_page | 否 | int | 总页数 |
| + data | 否 | array[] | 符合条件的银行信息 |
| ++ bank | 否 | string | 所属银行总行 |
| ++ provi | 否 | string | 所在省份 |
| ++ city | 否 | string | 所在城市 |
| ++ name | 否 | string | 具体银行完整名称 |
| ++ cnaps | 否 | int | 联行号 |
| ++ status | 否 | int | 状态 0:停业 1:现用名 2:曾用名 |
| ++ address | 否 | string | 地址 |
| ++ tel | 否 | string | 电话 |
| ++ open_date | 否 | string | 成立时期 |
{
"code": 200,
"msg": "success",
"query_id": "651737541812",
"remaining": 78,
"result": {
"total_items": 2,
"page_items": 2,
"curr_page": 1,
"total_page": 1,
"data": [
{
"bank": "招商银行股份有限公司",
"provi": "广东省",
"city": "深圳市",
"name": "招商银行股份有限公司深圳前海分行营业部",
"cnaps": 308584001768,
"status": "1",
"address": "深圳市前海深港合作区南山街道桂湾片区二单元前海卓越金融中心(一期)09栋A101商业亭8号楼25层2505",
"tel": "0755-26677519",
"open_date": "2013-05-27"
},
{
"bank": "招商银行股份有限公司",
"provi": "广东省",
"city": "深圳市",
"name": "招商银行股份有限公司深圳前海企业公馆支行",
"cnaps": 308584001864,
"status": "1",
"address": "深圳市前海深港合作区前湾一路63号前海企业公馆25C栋一层及二层",
"tel": "0755-86939083",
"open_date": "2015-10-27"
}
]
}
}
| 代码 | 说明 |
|---|---|
| 401 | 无效app id |
| 403 | 签名sign验证错误 |
| 405 | 剩余可使用次数为0 |
| 4001 | 缺少参数keywords,或参数值少于5个汉字 |
| 4002 | Page参数错误,page须小于等于10,最多展示10页 |
©2026 财务加油站 粤ICP备2022016929号 深圳晓芽科技有限公司增值电信业务经营许可证:粤B2-20221644