首页
Web开发
Windows程序
编程语言
数据库
移动开发
系统相关
微信
其他好文
会员
首页
>
其他好文
> 详细
货币汇率转换之笔记
时间:
2015-05-29 12:03:12
阅读:
367
评论:
0
收藏:
0
[点我收藏+]
标签:
汇率转换,这个汇率的转换接口文档是英文的,最近一个项目需要汇率查询,特意看了下文档,顺便简单介绍下,
写的很简陋,将就着看吧;实际上直接看Demo就可以了
官方地址:http://jsonrates.com/docs/rates/
使用方法: 注册帐号,获取免费的apiKey; 注册帐号时,需要邮件激活注册连接,推荐使用雅虎邮箱,qq邮箱接受邮件的熟读较慢,有时还会接受不到邮件。
1,接口调用方式:按需求选择
(1),以EUR为兑换基:
a),请求参数说明:
base: 定义基础货币的汇率。
from: 定义货币的汇率进行计算。
to: 定义货币的汇率进行计算。
prettify: 如果这个参数的值为“是”,JSON结果将读者友好的格式。
apiKey: 你的API的Key。注册并得到你的钥匙。
b),以欧元为基底,计算对应的其他货币汇率:
请求:http://jsonrates.com/get/?base=EUR&apiKey=
返回json数据:
{"utctime":"2015-05-29T04:00:02+02:00","base":"EUR","rates":
{"AED":"4.02613759","AFN":"65.22887433","ALL":"141.10033804","AMD":"525.39332103","ANG":"1.96201796","AOA":"120.76823416","ARS":"9.86182571",
"AUD":"1.43009955","AWG":"1.96201796","AZN":"1.15232932","BAM":"1.95708552","BBD":"2.19219884","BDT":"85.03862326","BGN":"1.95598942","BHD":"0.41330621",
"BIF":"1709.91509614","BMD":"1.09609942","BND":"1.47710358","BOB":"7.56308600","BRL":"3.46526351","BSD":"1.09609942","BTN":"69.95854662","BWP":"10.82507788",
"BYR":"16222.27142491","BZD":"2.18671834","CAD":"1.36151990","CDF":"1012.24781493","CHF":"1.03327648","CLF":"0.02696405","CLP":"675.73980682",
"CNH":"6.79948834","CNY":"6.79899510","COP":"2774.83054193","CRC":"582.57684205","CUP":"1.09609942","CVE":"110.35528967","CYP":"0.58570073",
"CZK":"27.46606038","DEM":"1.95708552","DJF":"193.93286281","DKK":"7.46027188","DOP":"49.17650270","DZD":"109.09477424","ECS":"27402.48551505",
"EGP":"8.36126560","ERN":"16.74839915","ETB":"22.55388973","EUR":"1.00000000","FJD":"2.28394236","FKP":"0.69964026","FRF":"6.56371736","GBP":"0.71483987",
"GEL":"2.52102867","GHS":"4.40631967","GIP":"0.71553370","GMD":"47.04458494","GNF":"8010.29456576","GTQ":"8.42187990","GYD":"227.12276862",
"HKD":"8.49822322","HNL":"23.98090266","HRK":"7.57651322","HTG":"52.59874431","HUF":"309.30281281","IDR":"14474.54089876","IEP":"0.78807904",
"ILS":"4.24058944","INR":"69.95739681","IQD":"1275.91445054","IRR":"31599.45019653","ISK":"147.58431087","ITL":"1937.50638588","JMD":"126.99407997",
"JOD":"0.77647683","JPY":"135.56064280","KES":"107.19907029","KGS":"63.74979887","KHR":"4444.13510083","KMF":"492.28193979","KPW":"986.48947854",
"KRW":"1213.82601066","KWD":"0.33192083","KYD":"0.89880152","KZT":"203.84709632","LAK":"8882.29624608","LBP":"1652.36987656","LKR":"146.57041562",
"LRD":"92.79578133","LSL":"13.30856514","LTL":"3.21595570","LVL":"0.70325739","LYD":"1.49721700","MAD":"10.76736824","MDL":"19.81199812",
"MGA":"3471.45658241","MKD":"61.61174734","MMK":"1200.50289041","MNT":"2096.83819161","MOP":"8.75344997","MRO":"345.27131749","MUR":"38.85672556",
"MVR":"16.84704809","MWK":"481.08351510","MXN":"16.79350364","MXV":"3.08003937","MYR":"3.99747459","MZN":"40.88450729","NAD":"13.30856514",
"NGN":"218.17859296","NIO":"29.74090402","NOK":"8.54847938","NPR":"111.93367612","NZD":"1.53352091","OMR":"0.42194347","PAB":"1.09609942",
"PEN":"3.46093392","PGK":"2.98385665","PHP":"48.88055476","PKR":"111.71993673","PLN":"4.14205010","PYG":"5598.11424425","QAR":"3.98947306",
"RON":"4.44605327","RSD":"120.69698551","RUB":"57.76389251","RWF":"751.92420253","SAR":"4.11086607","SBD":"8.53047266","SCR":"14.53477156",
"SDG":"6.53823304","SEK":"9.27552213","SGD":"1.47664322","SHP":"0.71553370","SIT":"239.79300601","SLL":"4764.74418136","SOS":"772.53085849",
"SRD":"3.61712809","STD":"24510.42719379","SVC":"9.58538943","SYP":"206.96769137","SZL":"13.30856514","THB":"36.96705125","TJS":"6.87089922",
"TMT":"3.83634797","TND":"2.15399978","TOP":"2.17647201","TRY":"2.91047279","TTD":"6.95135292","TWD":"33.60366689","TZS":"2285.03840842",
"UAH":"23.01808783","UGX":"3343.10323284","USD":"1.09609942","UYU":"29.43026944","UZS":"2775.69650322","VEF":"6.96023132","VND":"23884.00637491",
"VUV":"119.14600373","WST":"2.74733155","XAF":"656.37582947","XAG":"0.06581967","XAU":"0.00092182","XBT":"0.00461686","XCD":"2.95946844",
"XCP":"0.39258555","XDR":"0.78793107","XOF":"656.37582947","XPD":"0.00139643","XPF":"119.40791998","XPT":"0.00098211","YER":"235.54080340",
"ZAR":"13.31037370","ZMW":"8.01248676","ZWL":"353.33314079"}}
c), 两种货币之间的汇率计算:
请求:http://jsonrates.com/get/?from=XBT&to=USD&apiKey=
返回json数据:
{
"utctime": "2014-06-27T14:20:02+02:00",
"from": "XBT",
"to": "USD",
"rate": "584.16674456"
}
(2), 以2.99欧元兑换为其他货币:
a),请求参数说明:
base: 定义了基础货币的汇率是返回所有可用的。
from: 定义货币的汇率进行计算。
to: 定义货币的汇率进行计算。
amount: 定义的金额将转换。
inverse: 如果这个参数的值为“是”,转换的方向将倒。
prettify: 如果这个参数的值为“是”,JSON结果将读者友好的格式。
apiKey: 你的API的关键。注册并得到你的钥匙。
b), 将2.99欧元转换为其他货币:
请求:http://jsonrates.com/convert/?base=EUR&amount=2.99&apiKey=
返回json数据:
{"utctime":"2015-05-29T04:10:02+02:00","base":"EUR","amounts":
{"AED":"12.0404609598","AFN":"195.0717523924","ALL":"421.9709521027","AMD":"1571.2274186206","ANG":"5.8675591962",
"AOA":"361.1662981095",
"ARS":"29.4887463702","AUD":"4.2741956413","AWG":"5.8675591962","AZN":"3.446125696","BAM":"5.8493665113","BBD":"6.5559320658",
"BDT":"254.3142654273","BGN":"5.8482192184","BHD":"1.236022645","BIF":"5113.6270200847","BMD":"3.2779660329","BND":"4.4165675411",
"BOB":"22.6179656599","BRL":"10.3631257366","BSD":"3.2779660329","BTN":"209.2161856954","BWP":"32.3731925829","BYR":"48513.897370072",
"BZD":"6.5395422612","CAD":"4.0705126553","CDF":"3027.2016365708","CHF":"3.0894502106","CLF":"0.0806379678","CLP":"2020.8496565166",
"CNH":"20.3322399475","CNY":"20.3273230121","COP":"8298.3350854417","CRC":"1742.2389494614","CUP":"3.2779660329","CVE":"330.0256207521",
"CYP":"1.7504338761","CZK":"82.1064933234","DEM":"5.8493665113","DJF":"579.9705082535","DKK":"22.3042643083","DOP":"147.0659528858","DZD":"326.2559565447",
"ECS":"81949.15096294","EGP":"25.0049805226","ERN":"50.087321076","ETB":"67.4490682021","EUR":"2.99","FJD":"6.8302978445","FKP":"2.0923257251",
"FRF":"19.6178072545","GBP":"2.1367355971","GEL":"7.5393218966","GHS":"13.1774234696","GIP":"2.1398562302","GMD":"140.6902958136","GNF":"23955.375809486",
"GTQ":"25.1862520533","GYD":"679.2273657793","HKD":"25.4145787688","HNL":"71.716655465","HRK":"22.6666434579","HTG":"157.300418444","HUF":"924.615903419",
"IDR":"43336.350012211","IEP":"2.3553693904","ILS":"12.6817949999","INR":"209.2127471057","IQD":"3815.7161278392","IRR":"94500.482924442",
"ISK":"441.1322698081","ITL":"5790.8191098771","JMD":"379.7851484869","JOD":"2.322111142","JPY":"405.3205072293","KES":"320.5867142712",
"KGS":"190.6484682947","KHR":"13290.513303162","KMF":"1471.3320821459","KPW":"2950.1694346631","KRW":"3629.6755488435","KWD":"0.9926336849",
"KYD":"2.6879321404","KZT":"609.6197536676","LAK":"26563.161052241","LBP":"4941.5338030734","LKR":"438.3296219523","LRD":"277.5126179241",
"LSL":"39.7994246663","LTL":"9.6175523431","LVL":"2.1018318321","LYD":"4.4775377075","MAD":"32.1979853104","MDL":"59.2492394286","MGA":"10381.646561831",
"MKD":"184.1561320339","MMK":"3590.1923037006","MNT":"6260.9151335731","MOP":"26.1768534053","MRO":"1032.5593021276","MUR":"116.2038993362",
"MVR":"50.3823380073","MWK":"1438.71568087","MXN":"50.212211582","MXV":"9.2110845671","MYR":"11.9547421448","MZN":"122.2681299684","NAD":"39.7994246663",
"NGN":"652.4791498056","NIO":"88.9423637206","NOK":"25.5615791587","NPR":"334.7459016993","NZD":"4.5841502837","OMR":"1.2618530158","PAB":"3.2779660329",
"PEN":"10.3501777808","PGK":"8.9234430389","PHP":"146.097307343","PKR":"334.1066983033","PLN":"12.3848112765","PYG":"16741.57291528","QAR":"11.9308129954",
"RON":"13.3001833016","RSD":"360.7893385837","RUB":"172.7471745324","RWF":"2248.6847024265","SAR":"12.2938477324","SBD":"25.5110067173",
"SCR":"43.4673047588","SDG":"19.5530674157","SEK":"27.7301175918","SGD":"4.4154202482","SHP":"2.1398562302","SIT":"716.693340805","SLL":"14249.318369445",
"SOS":"2310.3104246222","SRD":"10.8172879295","STD":"73300.237570318","SVC":"28.6658130057","SYP":"618.9521229801","SZL":"39.7994246663",
"THB":"110.5051455534","TJS":"20.5479301157","TMT":"11.4728811301","TND":"6.4416949597","TOP":"6.5088998143","TRY":"8.7029998471","TTD":"20.7885328144",
"TWD":"100.2729811291","TZS":"6833.5756398637","UAH":"68.8372868105","UGX":"9997.7964174777","USD":"3.2779660329","UYU":"88.0133881224",
"UZS":"8300.9248064275","VEF":"20.8150843433","VND":"71492.439300079","VUV":"356.3148985461","WST":"8.2160973037","XAF":"1961.7760439771",
"XAG":"0.196838577","XAU":"0.00275678","XBT":"0.0138089861","XCD":"8.8505082978","XCP":"1.1740559714","XDR":"2.3553824866","XOF":"1961.7760439771",
"XPD":"0.004176133","XPF":"356.8862513073","XPT":"0.0029370471","YER":"704.4021187411","ZAR":"39.7964744931","ZMW":"23.9619317301","ZWL":"1056.6687783977"}}
c), 两种货币之间的转换,仅仅将2.99欧元转换为美元:
请求:http://jsonrates.com/convert/?from=EUR&to=USD&amount=2.99
返回json数据:
{
"utctime": "2014-06-27T14:50:04+02:00",
"from": "EUR",
"to": "USD",
"amount": "4.0742910884"
}
(3),两种货币之间的兑换:
请求:http://jsonrates.com/get/?from=USD&to=EUR&apiKey=
返回json数据:
{"utctime":"2015-05-29T04:00:02+02:00","from":"USD","to":"EUR","rate":"0.91232600"}
(4),查询以前的汇率:
a),请求参数说明:
base: 定义基础货币的汇率。
from: 定义货币的汇率进行计算。
to: 定义货币的汇率进行计算。
date: 日期日期的定义,历史汇率返回。
dateStart: datestart定义时间序列的历史汇率返回开始日期。
dateEnd: dateend定义时间序列的历史汇率返回结束日期。
period: 期间限定的时期,这决定了时间序列分。可能的值:‘天‘(默认),‘周‘,‘月‘,‘年‘
prettify: 如果这个参数的值为“是”,JSON结果将读者友好的格式。
apiKey: 你的API的关键。注册并得到你的钥匙。
b), 让所有的汇率为基础的货币历史日期,使下面的调用:
请求: http://jsonrates.com/historical/?base=USD&date=2014-06-23&apiKey=
返回的json数据:
{
"base": "USD",
"rates": {
"2014-06-23": {
"utctime": "2014-06-23T23:50:03+02:00",
"AED": "3.67320000",
"AFN": "56.72000100",
"ALL": "103.04000100",
"AMD": "409.00000000",
"ANG": "1.79000000",
"AOA": "97.65000200",
--- other historical rates ---
"XPF": "88.30000300",
"XPT": "0.00068600",
"YER": "214.85499600",
"ZAR": "10.58960000",
"ZMW": "6.09000000",
"ZWL": "322.35501100"
}
}
}
c), 用两货币历史时序的速率,使下面的调用:
请求: http://jsonrates.com/historical/?from=XBT&to=USD&dateStart=2014-06-23&dateEnd=2014-06-28&apiKey=
返回的json数据:
{
"from": "XBT",
"to": "USD",
"rates": {
"2014-06-23": {
"utctime": "2014-06-23T23:50:03+02:00",
"rate": "585.60009370"
},
"2014-06-24": {
"utctime": "2014-06-24T23:50:02+02:00",
"rate": "583.90069017"
},
"2014-06-25": {
"utctime": "2014-06-25T23:50:01+02:00",
"rate": "564.45831758"
},
"2014-06-26": {
"utctime": "2014-06-26T23:50:02+02:00",
"rate": "570.98809490"
},
"2014-06-27": {
"utctime": "2014-06-27T23:50:02+02:00",
"rate": "582.10267127"
},
"2014-06-28": {
"utctime": "2014-06-28T23:50:02+02:00",
"rate": "596.43095715"
}
}
}
(5),根据地区兑换:
a), 请求参数说明:
base: 定义了基础货币的汇率是返回所有可用的。
from: 定义货币的汇率进行计算。
to: 定义货币的汇率进行计算。
prettify: 如果这个参数的值为“是”,JSON结果将读者友好的格式。
apiKey: 你的API的关键。注册并得到你的钥匙。
b),To request all exchange rates for en_US, make the following call:
请求: http://jsonrates.com/locale/?base=en_US&apiKey=
返回数据:
{
"utctime": "2014-06-30T14:40:03+02:00",
"base": {
"locale": "en_US",
"currency": "USD"
},
"rates": {
"AED": "3.67300000",
"AFN": "57.15000200",
"ALL": "102.69500000",
"AMD": "407.27999900",
"ANG": "1.79000000",
"AOA": "97.58000200",
--- other rates ---
"XPF": "87.40000200",
"XPT": "0.00067600",
"YER": "214.80499300",
"ZAR": "10.61235000",
"ZMW": "6.20000000",
"ZWL": "322.35501100"
}
}
c), To get only one exchange rate for two locales, make the following call:
请求:http://jsonrates.com/locale/?from=en_GB&to=ar_AE&apiKey=
返回的json数据:
{
"utctime": "2014-06-30T14:40:03+02:00",
"from": {
"locale": "en_GB",
"currency": "GBP"
},
"to": {
"locale": "ar_AE",
"currency": "AED"
},
"rate": "6.26224360"
}
2,货币代号与货币名称之间的对应关系:
AED
阿联酋迪拉姆
AFN
阿富汗阿富汗尼
ALL
列克
AMD
亚美尼亚德拉姆
ANG
荷属安的列斯盾
AOA
安哥拉宽扎
ARS
阿根廷比索
AUD
澳元兑美元
AWG
阿鲁巴盾
AZN
阿塞拜疆新马纳特
BAM
波黑可兑换马克
BBD
巴巴多斯元
BDT
孟加拉塔卡
BGN
保加利亚列弗
BHD
巴林第纳尔
BIF
布隆迪法郎
BMD
百慕大元
BND
文莱元
BOB
玻利维亚
BRL
巴西
BSD
巴哈马美元
BTN
不丹努扎姆
BWP
博茨瓦纳普拉
BYR
白俄罗斯卢布
BZD
伯利兹元
CAD
加拿大元
CDF
刚果法郎
CHF
瑞士法郎
CLF
Unidad de Fomento
CLP
智利比索
CNH
离岸人民币
CNY
元人民币
COP
哥伦比亚比索
CRC
哥斯达黎加科朗
CUP
古巴比索
CVE
佛得角埃斯库多
CZK
捷克克朗
DJF
吉布提法郎
DKK
丹麦克朗
DOP
多米尼加比索
DZD
阿尔及利亚第纳尔
EGP
埃及镑
ERN
厄立特里亚纳克法
ETB
埃塞俄比亚比尔
EUR
欧元
FJD
斐济元
FKP
福克兰群岛镑
GBP
英镑
GEL
格鲁吉亚拉里
GHS
加纳塞地
GIP
直布罗陀镑
GMD
冈比亚达拉西
GNF
几内亚法郎
GTQ
危地马拉格查尔
GYD
圭亚那元
HKD
香港美元
HNL
宏都拉斯伦皮拉
HRK
库纳
HTG
海地古德
HUF
匈牙利福林
IDR
印尼盾
IEP
爱尔兰镑(取而代之的欧元)
ILS
以色列新谢克尔
INR
印度卢比
IQD
伊拉克第纳尔
IRR
伊朗里亚尔
ISK
冰岛克朗
JMD
牙买加美元
JOD
约旦第纳尔
JPY
日元
KES
肯尼亚先令
KGS
吉尔吉斯斯坦索姆
KHR
柬埔寨瑞尔
KMF
科摩罗法郎
KPW
朝鲜圆
KRW
韩元
KWD
科威特第纳尔
KYD
开曼群岛元
KZT
哈萨克斯坦坚戈
LAK
老挝基普
LBP
黎巴嫩镑
LKR
斯里兰卡卢比
LRD
利比里亚元
LSL
莱索托洛蒂
LTL
立特
LVL
拉脱维亚语
LYD
利比亚第纳尔
MAD
摩洛哥迪拉姆
MDL
摩尔多瓦列伊
MGA
马达加斯加河马
MKD
马其顿代纳尔
MMK
缅元
MNT
蒙古图格里克
MOP
澳门元
MRO
毛里塔尼亚乌吉亚
MUR
毛里求斯卢比
MVR
马尔代夫拉菲亚
MWK
马拉维克瓦查
MXN
墨西哥比索
MXV
墨西哥Unidad de反演
MYR
马来西亚林吉特
MZN
莫桑比克金属
NAD
纳米比亚元
NGN
尼日利亚奈拉
NIO
尼加拉瓜科尔多瓦奥罗
NOK
挪威克朗
NPR
尼泊尔卢比
NZD
新西兰元
OMR
阿曼里亚尔
PAB
巴拿马巴波亚
PEN
秘鲁索尔
PGK
巴布亚新几内亚基那
PHP
菲律宾比索
PKR
巴基斯坦卢比
PLN
波兰
PYG
巴拉圭瓜拉尼
QAR
卡塔尔里亚尔
RON
罗马尼亚新列伊
RSD
塞尔维亚第纳尔
RUB
俄罗斯卢布
RWF
卢旺达法郎
SAR
沙特里亚尔
SBD
所罗门岛元
SCR
塞舌尔卢比
SDG
苏丹镑
SEK
瑞典克朗
SGD
新加坡元
SHP
圣海伦娜庞德
SLL
塞拉利昂利昂
SOS
索马里先令
SRD
苏里南元
STD
汤姆的?é和公关í圣多美和普林西比多布拉
SVC
萨尔瓦多结肠
SYP
叙利亚磅
SZL
斯威士兰里兰吉尼
THB
泰铢
TJS
塔吉克索莫尼
TMT
turkmenistani马纳特
TND
突尼斯美元
TOP
同安潘加
TRY
土耳其里拉
TTD
特立尼达和多巴哥元
TWD
台湾元
TZS
坦桑尼亚先令
UAH
乌克兰格里夫纳
UGX
乌干达先令
USD
美元
UYU
乌拉圭比索
UZS
乌兹别克斯坦森
VEF
委内瑞拉玻利瓦尔
VND
越南盾
VUV
瓦努阿图瓦图
WST
萨摩亚塔拉
XAF
CFA法郎BEAC
XAG
银盎司
XAU
黄金每盎司
XBT
比特币
XCD
东加勒比元
XCP
一盎司铜
XDR
国际货币基金组织的特别提款权
XOF
西非法郎
XPD
钯盎司
XPF
CFP法郎
XPT
铂盎司
YER
也门里亚尔
ZAR
南非兰特
ZMW
赞比亚克瓦查
ZWL
津巴布韦元
货币汇率转换之笔记
标签:
原文地址:http://blog.csdn.net/u014289186/article/details/46226815
踩
(
0
)
赞
(
0
)
举报
评论
一句话评论(
0
)
登录后才能评论!
分享档案
更多>
2021年07月29日 (22)
2021年07月28日 (40)
2021年07月27日 (32)
2021年07月26日 (79)
2021年07月23日 (29)
2021年07月22日 (30)
2021年07月21日 (42)
2021年07月20日 (16)
2021年07月19日 (90)
2021年07月16日 (35)
周排行
更多
分布式事务
2021-07-29
OpenStack云平台命令行登录账户
2021-07-29
getLastRowNum()与getLastCellNum()/getPhysicalNumberOfRows()与getPhysicalNumberOfCells()
2021-07-29
【K8s概念】CSI 卷克隆
2021-07-29
vue3.0使用ant-design-vue进行按需加载原来这么简单
2021-07-29
stack栈
2021-07-29
抽奖动画 - 大转盘抽奖
2021-07-29
PPT写作技巧
2021-07-29
003-核心技术-IO模型-NIO-基于NIO群聊示例
2021-07-29
Bootstrap组件2
2021-07-29
友情链接
兰亭集智
国之画
百度统计
站长统计
阿里云
chrome插件
新版天听网
关于我们
-
联系我们
-
留言反馈
© 2014
mamicode.com
版权所有 联系我们:gaon5@hotmail.com
迷上了代码!