汇率查询
<p>[TOC]</p>
<h3>接口调用说明</h3>
<ul>
<li>提供主流银行汇率查询,支持外汇币种列表查询、历史汇率查询。同时也支持币种之间的汇率转换。这些服务广泛应用于国际结算、银行汇率查询、跨国贸易、投资等领域。本数据整理于网络,有不定滞后时间,仅供参考使用。</li>
</ul>
<h4>请求方式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>POST</strong></p>
<h4>请求格式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>application/x-www-form-urlencoded</strong></p>
<h4>请求参数</h4>
<p>请求参数包括公共参数和业务参数(业务参数见具体接口说明)
调用接口时,需要把<strong>公共参数</strong>和<strong>业务参数</strong>一并放在<strong>请求参数</strong>中提交</p>
<h5>公共请求参数</h5>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>appId</td>
<td>String</td>
<td>是</td>
<td>服务商分配的唯一标识</td>
</tr>
<tr>
<td>timestamp</td>
<td>Long</td>
<td>是</td>
<td>当前时间戳(毫秒)</td>
</tr>
<tr>
<td>sign</td>
<td>String</td>
<td>是</td>
<td>签名,详见<a href="#签名算法">签名算法说明</a></td>
</tr>
</tbody>
</table>
<p><a name="签名算法"></a></p>
<h5>签名算法说明</h5>
<pre><code>sign = sha256(appId + appSecret + timestamp)</code></pre>
<p>用服务商分配的 <strong>appId</strong>、服务商分配的 <strong>appSecret</strong>,当前时间戳(毫秒) <strong>timestamp</strong>,按上述顺序拼接成字符串,再进行 <strong>sha256</strong> 哈希得到。如下:</p>
<pre><code class="language-java">String appId = &quot;xyzxy2121zxyz&quot;;
String timestamp = &quot;1555378976238&quot;;
String appSecret = &quot;efcefcef1121cefcefc1212121&quot;;
String str = appId + appSecret + timestamp;
String sign = sha256(str);</code></pre>
<h4>返回说明</h4>
<h5>公共返回字段说明</h5>
<p>所有接口均返回以下公共字段:</p>
<table>
<thead>
<tr>
<th>字段名</th>
<th><div style="width:420px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>返回码,详见:code返回码说明</td>
</tr>
<tr>
<td>msg</td>
<td>code对应的描述</td>
</tr>
<tr>
<td>charge</td>
<td>计费标志 true为计费,false为不计费</td>
</tr>
<tr>
<td>taskNo</td>
<td>本次请求号</td>
</tr>
<tr>
<td>data</td>
<td>返回具体结果,object类型,详见data返回字段描述</td>
</tr>
</tbody>
</table>
<p><a name="公共code返回码说明"></a></p>
<h5>公共code返回码说明</h5>
<p>所有接口公共返回码如下:</p>
<table>
<thead>
<tr>
<th>code</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>成功</td>
</tr>
<tr>
<td>400</td>
<td>参数错误</td>
</tr>
<tr>
<td>404</td>
<td>接口地址不正确</td>
</tr>
<tr>
<td>500</td>
<td>系统维护,请稍候再试</td>
</tr>
<tr>
<td>601</td>
<td>接口未开通</td>
</tr>
<tr>
<td>602</td>
<td>账号停用</td>
</tr>
<tr>
<td>604</td>
<td>接口停用</td>
</tr>
<tr>
<td>606</td>
<td>调用超限,请稍候再试</td>
</tr>
<tr>
<td>607</td>
<td>ip不在白名单</td>
</tr>
<tr>
<td>609</td>
<td>请求过于频繁,请稍候再试</td>
</tr>
<tr>
<td>610</td>
<td>请求超时</td>
</tr>
<tr>
<td>999</td>
<td>其他,以实际返回为准</td>
</tr>
</tbody>
</table>
<h3>外汇牌价币种列表</h3>
<h4>接口描述</h4>
<ul>
<li>查询所有支持的外汇列表。</li>
</ul>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/exchange-rate/type-list</code></p>
<h4>业务参数</h4>
<p>无</p>
<h4>成功返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 200, // 详见code返回码说明
&quot;msg&quot;: &quot;成功&quot;, // code 对应的描述
&quot;charge&quot;: true, // 计费标志
&quot;taskNo&quot;: &quot;51168811490923554212&quot;, // 本次请求号
&quot;data&quot;: {
&quot;list&quot;: [
{
&quot;code&quot;: &quot;GBP&quot;,//货币代码
&quot;flag&quot;: &quot;https://xxxxxxx.png&quot;,//旗帜
&quot;name&quot;: &quot;英镑&quot; //货币名称
},
{
&quot;code&quot;: &quot;HKD&quot;,
&quot;flag&quot;: &quot;https://xxxxxx.png&quot;,
&quot;name&quot;: &quot;港币&quot;
}
]
}
}</code></pre>
<h4>失败返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;系统维护,请稍候再试&quot;,
&quot;code&quot;: 500
}</code></pre>
<h3>汇率转换</h3>
<h4>接口描述</h4>
<ul>
<li>币种间的汇率转换,比如金额人民币100元,可以转为多少美元(或其他外币)。</li>
</ul>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/exchange-rate/convert</code></p>
<h4>业务参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>fromCode</td>
<td>String</td>
<td>是</td>
<td>源货币类型</td>
</tr>
<tr>
<td>toCode</td>
<td>String</td>
<td>是</td>
<td>目标货币类型</td>
</tr>
<tr>
<td>money</td>
<td>String</td>
<td>是</td>
<td>转换的金额,单位元</td>
</tr>
</tbody>
</table>
<h4>成功返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;成功&quot;,//code对应的描述
&quot;code&quot;: 200,//返回码,详见code返回码说明
&quot;taskNo&quot;: &quot;687882815162227863699691&quot;,//本次唯一请求号
&quot;charge&quot;: true, //计费标志
&quot;data&quot;: {
&quot;money&quot;: &quot;115.5415&quot; //转换后的金额,单位元
}
}</code></pre>
<h4>失败返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;参数不正确&quot;,
&quot;code&quot;: 400
}</code></pre>
<h3>查询历史汇率</h3>
<h4>接口描述</h4>
<ul>
<li>外币历史汇率(100外币兑人民币),最早可查到2009年1月,支持英镑、港币、美元、瑞士法郎、新加坡元、瑞典克朗、林吉特、新台币、丹麦克朗、挪威克朗、日元、加拿大元、澳大利亚元、欧元、澳门元、菲律宾比索、泰国铢、新西兰元、韩国元、卢布、印尼卢比、巴西里亚尔、阿联酋迪拉姆、印度卢比、南非兰特、沙特里亚尔、土耳其里拉。</li>
</ul>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/exchange-rate/history</code></p>
<h4>业务参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>String</td>
<td>否</td>
<td>货币编号,货币编号或货币名称必须输入其中一个</td>
</tr>
<tr>
<td>name</td>
<td>String</td>
<td>否</td>
<td>货币名称,货币编号或货币名称必须输入其中一个</td>
</tr>
<tr>
<td>month</td>
<td>String</td>
<td>否</td>
<td>查询年月(yyyyMM),month和startDate、endDate不能同时为空</td>
</tr>
<tr>
<td>startDate</td>
<td>String</td>
<td>否</td>
<td>查询起始时间yyyyMMdd,month和startDate、endDate不能同时为空</td>
</tr>
<tr>
<td>endDate</td>
<td>String</td>
<td>否</td>
<td>查询结束时间yyyyMMdd,month和startDate、endDate不能同时为空</td>
</tr>
</tbody>
</table>
<h4>成功返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;成功&quot;,//code对应的描述
&quot;code&quot;: 200,//返回码,详见code返回码说明
&quot;taskNo&quot;: &quot;687882815162227863699691&quot;,//本次唯一请求号
&quot;charge&quot;: true, //计费标志
&quot;data&quot;: {
&quot;currencyCode&quot;: &quot;USD&quot;,//货币编号
&quot;currencyName&quot;: &quot;美元&quot;,//货币名称
&quot;startDate&quot;: &quot;20191001&quot;,//开始日期
&quot;endDate&quot;: &quot;20191101&quot;,//结束日期
&quot;month&quot;: &quot;201910&quot;,//结束日期
&quot;list&quot;: [
{
&quot;middle_rate&quot;: &quot;705.33&quot;,//中行折算价
&quot;selling_rate&quot;: &quot;705.55&quot;,//现汇卖出价
&quot;cash_buying_rate&quot;: &quot;696.86&quot;,//现钞买入价
&quot;buying_rate&quot;: &quot;702.58&quot;,//现汇买入价
&quot;cash_selling_rate&quot;: &quot;705.55&quot;,//现钞卖出价
&quot;publish_time&quot;: &quot;2019-10-31&quot; //发布日期
},
{
&quot;middle_rate&quot;: &quot;705.82&quot;,
&quot;selling_rate&quot;: &quot;707.26&quot;,
&quot;cash_buying_rate&quot;: &quot;698.54&quot;,
&quot;buying_rate&quot;: &quot;704.27&quot;,
&quot;cash_selling_rate&quot;: &quot;707.26&quot;,
&quot;publish_time&quot;: &quot;2019-10-30&quot;
}
]
}
}</code></pre>
<h4>失败返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;参数不正确&quot;,
&quot;code&quot;: 400
}</code></pre>
<h3>中国银行汇率查询</h3>
<h4>接口描述</h4>
<ul>
<li>包括常见国家货币的汇率:菲律宾比索,瑞典克朗,新加坡元,阿联酋迪拉姆,澳大利亚元,巴西里亚尔,加拿大元,瑞士法郎,丹麦克朗,欧元,英镑,港币,印尼卢比,印度卢比,日元,韩国元,澳门元,林吉特,挪威克朗,新西兰元,卢布,泰国铢,新台币,美元,南非兰特,人民币。数据来源网络,仅供参考。</li>
</ul>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/exchange-rate/query-china-bank</code></p>
<h4>业务参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>String</td>
<td>否</td>
<td>需要查询的货币缩写。比如人民币是CNY,美元是USD,如果不输入,则返回全部。</td>
</tr>
</tbody>
</table>
<h4>成功返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;成功&quot;,//code对应的描述
&quot;code&quot;: 200,//返回码,详见code返回码说明
&quot;taskNo&quot;: &quot;687882815162227863699691&quot;,//本次唯一请求号
&quot;charge&quot;: true, //计费标志
&quot;data&quot;: {
&quot;listSize&quot;: 1,//返回的数据列表长度
&quot;list&quot;: [
{
&quot;hui_in&quot;: &quot;729.93&quot;,//现汇买入价
&quot;zhesuan&quot;: &quot;717.98&quot;,//中行折算价
&quot;code&quot;: &quot;USD&quot;,//货币简码
&quot;name&quot;: &quot;美元&quot;,//货币名称
&quot;hui_out&quot;: &quot;732.84&quot;,//现汇卖出价
&quot;chao_out&quot;: &quot;732.84&quot;,//现钞卖出价
&quot;chao_in&quot;: &quot;723.99&quot;,//现钞买入价
&quot;time&quot;: &quot;15:08:08&quot;,//发布时间
&quot;day&quot;: &quot;2023-10-16&quot; //发布日
}
]
}
}</code></pre>
<h4>失败返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;参数不正确&quot;,
&quot;code&quot;: 400
}</code></pre>
<h3>十大银行汇率查询</h3>
<h4>接口描述</h4>
<ul>
<li>包括工商银行、中国银行、农业银行、交通银行、建设银行、招商银行、光大银行、浦发银行、兴业银行、中信银行十大银行的外汇牌价。数据来源网络,仅供参考。</li>
</ul>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/exchange-rate/query-ten-bank</code></p>
<h4>业务参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>bankCode</td>
<td>String</td>
<td>是</td>
<td>银行编码,工商银行:ICBC ,中国银行:BOC ,农业银行:ABCHINA ,交通银行:BANKCOMM ,建设银行:CCB ,招商银行:CMBCHINA ,光大银行:CEBBANK ,浦发银行:SPDB ,兴业银行:CIB ,中信银行:ECITIC</td>
</tr>
</tbody>
</table>
<h4>成功返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;成功&quot;,//code对应的描述
&quot;code&quot;: 200,//返回码,详见code返回码说明
&quot;taskNo&quot;: &quot;687882815162227863699691&quot;,//本次唯一请求号
&quot;charge&quot;: true, //计费标志
&quot;data&quot;: {
&quot;listSize&quot;: 25,//货币数量(种)
&quot;list&quot;: [
{
&quot;hui_in&quot;: &quot;807.9300&quot;,//现汇买入价
&quot;code&quot;: &quot;CHF&quot;,//货币简码
&quot;name&quot;: &quot;瑞士法郎&quot;,//货币名称
&quot;hui_out&quot;: &quot;813.6800&quot;,//现汇卖出价
&quot;chao_out&quot;: &quot;813.6800&quot;,//现钞卖出价
&quot;chao_in&quot;: &quot;791.8100&quot;,//现钞买入价
&quot;mid_price&quot;: &quot;--&quot; //中间价
},
{
&quot;hui_in&quot;: &quot;1.5013&quot;,
&quot;code&quot;: &quot;KZT&quot;,
&quot;name&quot;: &quot;&quot;,
&quot;hui_out&quot;: &quot;1.5933&quot;,
&quot;chao_out&quot;: &quot;1.5933&quot;,
&quot;chao_in&quot;: &quot;1.4962&quot;,
&quot;mid_price&quot;: &quot;--&quot;
},
……
],
&quot;time&quot;: &quot;15:27:30&quot;,//时间
&quot;name&quot;: &quot;ICBC&quot;,//银行编码
&quot;day&quot;: &quot;2023-10-16&quot; //日期
}
}</code></pre>
<h4>失败返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;参数不正确&quot;,
&quot;code&quot;: 400
}</code></pre>