先上API文档链接:https://www.juhe.cn/docs/api/id/23,支持人民币牌价、外汇汇率查询;数据仅供参考,交易时以银行柜台成交价为准。

人民币牌价

接口地址:http://web.juhe.cn:8080/finance/exchange/rmbquot
支持格式:json
请求方式:get
请求示例:http://web.juhe.cn:8080/finance/exchange/rmbquot?key=您申请的APPKEY
接口备注:100外币兑人民币
请求参数说明:

名称 类型 必填 说明
key String APP Key
type int 两种格式(0或者1,默认为0)
bank int (0:工商银行,1:招商银行,2:建设银行,3:中国银行,4:交通银行,5:农业银行,默认为:中国银行)

JSON返回示例:

{
"resultcode":"200",
"reason":"SUCCESSED!",
"result":[
{
"data1":{
"name":"英镑", /*货币名称*/
"fBuyPri":"1001.430", /*现汇买入价*/
"mBuyPri":"970.510", /*现钞买入价*/
"fSellPri":"1009.480", /*现汇卖出价*/
"mSellPri":"1009.480", /*现钞卖出价*/
"bankConversionPri":"1014.870", /*银行折算价/中间价*/
"date":"2012-12-13", /*发布日期*/
"time":"16:25:49" /*发布时间*/
},
"data2":{
"name":"港币",
"fBuyPri":"80.210",
"mBuyPri":"79.570",
"fSellPri":"80.520",
"mSellPri":"80.520",
"bankConversionPri":"81.140",
"date":"2012-12-13",
"time":"16:25:49"
},
"data3":{
"name":"美元",
"fBuyPri":"621.650",
"mBuyPri":"616.670",
"fSellPri":"624.150",
"mSellPri":"624.150",
"bankConversionPri":"628.870",
"date":"2012-12-13",
"time":"16:25:49"
},
"data4":{
"name":"瑞士法郎",
"fBuyPri":"670.310",
"mBuyPri":"649.620",
"fSellPri":"675.700",
"mSellPri":"675.700",
"bankConversionPri":"674.350",
"date":"2012-12-13",
"time":"16:25:49"
},
"data5":{
"name":"新加坡元",
"fBuyPri":"508.300",
"mBuyPri":"492.610",
"fSellPri":"512.390",
"mSellPri":"512.390",
"bankConversionPri":"512.000",
"date":"2012-12-13",
"time":"16:25:49"
},
"data6":{
"name":"瑞典克朗",
"fBuyPri":"93.340",
"mBuyPri":"90.450",
"fSellPri":"94.090",
"mSellPri":"94.090",
"bankConversionPri":"93.770",
"date":"2012-12-13",
"time":"16:25:49"
},
"data7":{
"name":"丹麦克朗",
"fBuyPri":"108.920",
"mBuyPri":"105.550",
"fSellPri":"109.790",
"mSellPri":"109.790",
"bankConversionPri":"109.430",
"date":"2012-12-13",
"time":"16:25:49"
},
"data8":{
"name":"挪威克朗",
"fBuyPri":"110.490",
"mBuyPri":"107.080",
"fSellPri":"111.380",
"mSellPri":"111.380",
"bankConversionPri":"111.060",
"date":"2012-12-13",
"time":"16:25:49"
},
"data9":{
"name":"日元",
"fBuyPri":"7.431",
"mBuyPri":"7.201",
"fSellPri":"7.483",
"mSellPri":"7.483",
"bankConversionPri":"7.531",
"date":"2012-12-13",
"time":"16:25:49"
},
"data10":{
"name":"加拿大元",
"fBuyPri":"630.950",
"mBuyPri":"611.470",
"fSellPri":"636.010",
"mSellPri":"636.010",
"bankConversionPri":"638.800",
"date":"2012-12-13",
"time":"16:25:49"
},
"data11":{
"name":"澳大利亚元",
"fBuyPri":"654.900",
"mBuyPri":"634.680",
"fSellPri":"660.160",
"mSellPri":"660.160",
"bankConversionPri":"663.300",
"date":"2012-12-13",
"time":"16:25:49"
},
"data12":{
"name":"欧元",
"fBuyPri":"812.520",
"mBuyPri":"787.430",
"fSellPri":"819.040",
"mSellPri":"819.040",
"bankConversionPri":"821.960",
"date":"2012-12-13",
"time":"16:25:49"
},
"data13":{
"name":"澳门元",
"fBuyPri":"77.910",
"mBuyPri":"75.300",
"fSellPri":"78.210",
"mSellPri":"80.720",
"bankConversionPri":"78.320",
"date":"2012-12-13",
"time":"16:25:49"
},
"data14":{
"name":"菲律宾比索",
"fBuyPri":"15.100",
"mBuyPri":"14.640",
"fSellPri":"15.220",
"mSellPri":"15.690",
"bankConversionPri":"15.220",
"date":"2012-12-13",
"time":"16:25:49"
},
"data15":{
"name":"泰国铢",
"fBuyPri":"20.240",
"mBuyPri":"19.620",
"fSellPri":"20.400",
"mSellPri":"21.030",
"bankConversionPri":"20.390",
"date":"2012-12-13",
"time":"16:25:49"
},
"data16":{
"name":"新西兰元",
"fBuyPri":"524.400",
"mBuyPri":"0.000",
"fSellPri":"528.610",
"mSellPri":"0.000",
"bankConversionPri":"526.770",
"date":"2012-12-13",
"time":"16:25:49"
},
"data17":{
"name":"韩国元",
"fBuyPri":"0.000",
"mBuyPri":"0.560",
"fSellPri":"0.000",
"mSellPri":"0.608",
"bankConversionPri":"0.586",
"date":"2012-12-13",
"time":"16:25:49"
}
}
]
}

外汇汇率

接口地址:http://web.juhe.cn:8080/finance/exchange/frate
支持格式:json
请求方式:get
请求示例:http://web.juhe.cn:8080/finance/exchange/frate?key=您申请的APPKEY

请求参数说明:

名称 类型 必填 说明
key String APP Key
type int 两种格式(0或者1,默认为0)

JSON返回示例:

{
"error_code":0,
"resultcode":"200",
"reason":"SUCCESSED!",
"result":[
{
"data1":{
"code":"JPY", /*货币代码*/
"currency":"美元日元", /*货币名称*/
"closePri":"83.41", /*最新价*/
"diffPer":"0.19%", /*涨跌%*/
"diffAmo":"0.16", /*涨跌金额*/
"openPri":"83.25", /*开盘价*/
"highPic":"83.67", /*最高价*/
"lowPic":"83.1", /*最低价*/
"range":"0.68%", /*震幅%*/
"buyPic":"83.41", /*买入价*/
"sellPic":"83.45", /*卖出价*/
"color":"Red", /*涨跌颜色*/
"date":"2016-07-29", /*日期*/
"datatime":"08:58:39" /*数据时间*/
},
"data2":{
"code":"CHF",
"currency":"美元瑞郎",
"closePri":"0.9241",
"diffPer":"0.06%",
"diffAmo":"0.0006",
"openPri":"0.9234",
"highPic":"0.9243",
"lowPic":"0.9231",
"range":"0.13%",
"buyPic":"0.9241",
"sellPic":"0.9246",
"color":"Red",
"date":"2016-07-29",
"datatime":"09:40:54"
},
......
}
]
}

示例代码

基于php的货币汇率接口调用代码实例

<!--?php
// +----------------------------------------------------------------------
// | JuhePHP [ NO ZUO NO DIE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2010-2015 http://juhe.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: Juhedata <info@juhe.cn-->
// +---------------------------------------------------------------------- //----------------------------------
// 货币汇率调用示例代码 - 聚合数据
// 在线接口文档:http://www.juhe.cn/docs/23
//---------------------------------- header('Content-type:text/html;charset=utf-8'); //配置您申请的appkey
$appkey = "*********************"; //************1.人民币牌价************
$url = "http://web.juhe.cn:8080/finance/exchange/rmbquot";
$params = array(
"key" => $appkey,//APP Key
"type" => "",//两种格式(0或者1,默认为0)
);
$paramstring = http_build_query($params);
$content = juhecurl($url,$paramstring);
$result = json_decode($content,true);
if($result){
if($result['error_code']=='0'){
print_r($result);
}else{
echo $result['error_code'].":".$result['reason'];
}
}else{
echo "请求失败";
}
//************************************************** //************2.外汇汇率************
$url = "http://web.juhe.cn:8080/finance/exchange/frate";
$params = array(
"key" => $appkey,//APP Key
"type" => "",//两种格式(0或者1,默认为0)
);
$paramstring = http_build_query($params);
$content = juhecurl($url,$paramstring);
$result = json_decode($content,true);
if($result){
if($result['error_code']=='0'){
print_r($result);
}else{
echo $result['error_code'].":".$result['reason'];
}
}else{
echo "请求失败";
}
//************************************************** /**
* 请求接口返回内容
* @param string $url [请求的URL地址]
* @param string $params [请求的参数]
* @param int $ipost [是否采用POST形式]
* @return string
*/
function juhecurl($url,$params=false,$ispost=0){
$httpInfo = array();
$ch = curl_init(); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if( $ispost )
{
curl_setopt( $ch , CURLOPT_POST , true );
curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
curl_setopt( $ch , CURLOPT_URL , $url );
}
else
{
if($params){
curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
}else{
curl_setopt( $ch , CURLOPT_URL , $url);
}
}
$response = curl_exec( $ch );
if ($response === FALSE) {
//echo "cURL Error: " . curl_error($ch);
return false;
}
$httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );
$httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );
curl_close( $ch );
return $response;
}

基于Python的货币汇率接口调用代码实例

#!/usr/bin/python
# -*- coding: utf-8 -*-
import json, urllib
from urllib import urlencode #----------------------------------
# 货币汇率调用示例代码 - 聚合数据
# 在线接口文档:http://www.juhe.cn/docs/23
#---------------------------------- def main(): #配置您申请的APPKey
appkey = "*********************" #1.人民币牌价
request1(appkey,"GET") #2.外汇汇率
request2(appkey,"GET") #人民币牌价
def request1(appkey, m="GET"):
url = "http://web.juhe.cn:8080/finance/exchange/rmbquot"
params = {
"key" : appkey, #APP Key
"type" : "", #两种格式(0或者1,默认为0) }
params = urlencode(params)
if m =="GET":
f = urllib.urlopen("%s?%s" % (url, params))
else:
f = urllib.urlopen(url, params) content = f.read()
res = json.loads(content)
if res:
error_code = res["error_code"]
if error_code == 0:
#成功请求
print res["result"]
else:
print "%s:%s" % (res["error_code"],res["reason"])
else:
print "request api error" #外汇汇率
def request2(appkey, m="GET"):
url = "http://web.juhe.cn:8080/finance/exchange/frate"
params = {
"key" : appkey, #APP Key
"type" : "", #两种格式(0或者1,默认为0) }
params = urlencode(params)
if m =="GET":
f = urllib.urlopen("%s?%s" % (url, params))
else:
f = urllib.urlopen(url, params) content = f.read()
res = json.loads(content)
if res:
error_code = res["error_code"]
if error_code == 0:
#成功请求
print res["result"]
else:
print "%s:%s" % (res["error_code"],res["reason"])
else:
print "request api error" if __name__ == '__main__':
main()

基于JAVA的货币汇率接口调用代码实例

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map; import net.sf.json.JSONObject; /**
*货币汇率调用示例代码 - 聚合数据
*在线接口文档:http://www.juhe.cn/docs/23
**/ public class JuheDemo {
public static final String DEF_CHATSET = "UTF-8";
public static final int DEF_CONN_TIMEOUT = 30000;
public static final int DEF_READ_TIMEOUT = 30000;
public static String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36"; //配置您申请的KEY
public static final String APPKEY ="*************************"; //1.人民币牌价
public static void getRequest1(){
String result =null;
String url ="http://web.juhe.cn:8080/finance/exchange/rmbquot";//请求接口地址
Map params = new HashMap();//请求参数
params.put("key",APPKEY);//APP Key
params.put("type","");//两种格式(0或者1,默认为0) try {
result =net(url, params, "GET");
JSONObject object = JSONObject.fromObject(result);
if(object.getInt("error_code")==0){
System.out.println(object.get("result"));
}else{
System.out.println(object.get("error_code")+":"+object.get("reason"));
}
} catch (Exception e) {
e.printStackTrace();
}
} //2.外汇汇率
public static void getRequest2(){
String result =null;
String url ="http://web.juhe.cn:8080/finance/exchange/frate";//请求接口地址
Map params = new HashMap();//请求参数
params.put("key",APPKEY);//APP Key
params.put("type","");//两种格式(0或者1,默认为0) try {
result =net(url, params, "GET");
JSONObject object = JSONObject.fromObject(result);
if(object.getInt("error_code")==0){
System.out.println(object.get("result"));
}else{
System.out.println(object.get("error_code")+":"+object.get("reason"));
}
} catch (Exception e) {
e.printStackTrace();
}
} public static void main(String[] args) { } /**
*
* @param strUrl 请求地址
* @param params 请求参数
* @param method 请求方法
* @return 网络请求字符串
* @throws Exception
*/
public static String net(String strUrl, Map params,String method) throws Exception {
HttpURLConnection conn = null;
BufferedReader reader = null;
String rs = null;
try {
StringBuffer sb = new StringBuffer();
if(method==null || method.equals("GET")){
strUrl = strUrl+"?"+urlencode(params);
}
URL url = new URL(strUrl);
conn = (HttpURLConnection) url.openConnection();
if(method==null || method.equals("GET")){
conn.setRequestMethod("GET");
}else{
conn.setRequestMethod("POST");
conn.setDoOutput(true);
}
conn.setRequestProperty("User-agent", userAgent);
conn.setUseCaches(false);
conn.setConnectTimeout(DEF_CONN_TIMEOUT);
conn.setReadTimeout(DEF_READ_TIMEOUT);
conn.setInstanceFollowRedirects(false);
conn.connect();
if (params!= null && method.equals("POST")) {
try (DataOutputStream out = new DataOutputStream(conn.getOutputStream())) {
out.writeBytes(urlencode(params));
}
}
InputStream is = conn.getInputStream();
reader = new BufferedReader(new InputStreamReader(is, DEF_CHATSET));
String strRead = null;
while ((strRead = reader.readLine()) != null) {
sb.append(strRead);
}
rs = sb.toString();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
reader.close();
}
if (conn != null) {
conn.disconnect();
}
}
return rs;
} //将map型转为请求参数型
public static String urlencode(Map<String,Object>data) {
StringBuilder sb = new StringBuilder();
for (Map.Entry i : data.entrySet()) {
try {
sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue()+"","UTF-8")).append("&");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return sb.toString();
}
}

分享个免费的货币汇率API的更多相关文章

  1. 免费手机号码归属地API查询接口和PHP使用实例分享

    免费手机号码归属地API查询接口和PHP使用实例分享 最近在做全国性的行业分类信息网站,需要用到手机号归属地显示功能,于是就穿梭于各大权威站点之间偷来了API的接口地址. 分享出来,大家可以用到就拿去 ...

  2. 分享几个免费IP地址查询API接口

    几个免费IP地址查询API接口 1.IP地址查询接口:http://apis.juhe.cn/ip/ip2addr要先去https://www.juhe.cn/docs/api/...申请APPKEY ...

  3. 【攻略】百度货币识别API,搞定防诈骗的应用小程序

    1.需求及方案: 近两年用外币进行诈骗的案件很多.例如:2015年12月,一安徽诈骗团伙,用不值1角人民币的50印蒂(intis,秘鲁旧货币,1991年发行新货币后已停止流通,目前无货币价值,仅有&q ...

  4. 开源免费的天气预报接口API以及全国所有地区代码(国家气象局提供)

    天气预报一直是各大网站的一个基本功能,最近小编也想在网站上弄一个,得瑟一下,在网络搜索了很久,终于找到了开源免费的天气预报接口API以及全国所有地区代码(国家气象局提供),具体如下: 国家气象局提供的 ...

  5. 免费安卓IOS测试API接口,后续会陆续增加接口

    各位博友好!开发的安卓或者ios的朋友们,经常会遇到想测试但是没有公开的api接口进行进行测试.但自己又不会开发服务端或者没有服务器,这里我免费提供了一整套API接口.欢迎大家调用,目标是方便大家. ...

  6. 免费手机号码归属地API查询接口

    免费手机号码归属地API查询接口 一.淘宝网API API地址: http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=1585078144 ...

  7. 调用百度汇率api 获取各国的汇率值

    设置一个定时任务,每天更新汇率java代码如下 package com.thinkgem.jeesite.modules.huiLvApi.service; import java.io.Buffer ...

  8. 分享一个免费SSL证书申请网站,给网站开启https协议 | 张戈博客

    这些天,由于公司的业务需求,接触到了ssl证书和https协议.博客前几篇文章也分享了在WEB服务器上安装SSL证书,为网站开启https协议的教程,感兴趣的童鞋可以前往查看相关文章: <Lin ...

  9. 微信分享自定义图片标题摘要-微信官方API

    我们平时在使用微信内置浏览器打开网页想要分享给好友或者发到朋友圈的时候经常会遇到这样的问题, 别人的网页分享的时候是这样的: 而我们自己的网页分享后这这样的: 看到有人说不做任何设置,微信分享时会自动 ...

随机推荐

  1. 二分 by zzt

    #include <bits/stdc++.h> using namespace std; /* Problem description: There is an array A, the ...

  2. Resize operation completed for file#

    Orale 12c RAC环境ALERT LOG中出现Resize operation completed for file# 查看数据库版本: BANNER CON_ID ------------- ...

  3. C#添加编译时间

    using System.Reflection;using UnityEngine;using System.Collections; [assembly:AssemblyVersion( " ...

  4. Codeforces Round #241 (Div. 2) B dp

    B. Art Union time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  5. Linux下对superblock的理解

    对superblock的理解首先从partition structure的结构开始: 开始的,总的来说,block这个概念好理解..下面就是对super block的理解了Super block即为超 ...

  6. jquery 实践操作:load()方法

    最近决定总结下实际项目中的 JS 相关的一些操作,因此开启此系列,记录使用过程中用到的一些实用操作问题和解决方法,给自己一份记录. jquery load方法是对jQuery.ajax()进行封装以方 ...

  7. 运输问题2(cogs 12)

    [问题描述]     一个工厂每天生产若干商品,需运输到销售部门进行销售.从产地到销地要经过某些城镇,有不同的路线可以行走,每条两城镇间的公路都有一定的流量限制.为了保证公路的运营效率,每条公路都有一 ...

  8. t4-editor使用方法 Visual T4

    原文发布时间为:2011-05-17 -- 来源于本人的百度文章 [由搬家工具导入] http://visualstudiogallery.msdn.microsoft.com/40a887aa-f3 ...

  9. MEF 注入[转载]

    领域服务的时候,用到MEF的注入有参构造函数的方法,your master was attracted,打算稍微深挖一下,这篇来对此知识点做个总结. 一.知识点回顾 MEF作为IOC的方式之一,它的主 ...

  10. mysql启动错误1067的解决

    安装后MYSQL5后,发现启动出错,有时启动正常,但加接时马上出错. 出错代码:1067 解决办法如下: 删除%windows%/my.ini    删除其它地方的my.ini    在mysql安装 ...