实时获取汇率

Ever wanted an accurate and reliable currency data that can be easily integrated into your business; be it CRM, ERP, accounting applications etc., built in any programming languages? Then say hello to currencylayer.

曾经想过可以将其轻松集成到您的业务中的准确可靠的货币数据; 以任何编程语言构建的CRM,ERP,会计应用程序等? 然后向currencylayer打个招呼。

In this article, I will show you how to use two of currencylayer’s services: live exchange rates and historical exchange rates.

在本文中,我将向您展示如何使用currencylayer的两项服务:实时汇率和历史汇率。

什么是currencylayer? ( What is currencylayer? )

Currencylayer provides a reliable exchange rates and currency conversion for your business. It does these by providing an easy to integrate REST API with real-time and historical exchange rates for 168 world currencies and precious metals, delivered in universally usable and easily parseable JSON format, and compatible with any application.

Currencylayer为您的业务提供可靠的汇率和货币换算。 它通过提供一种易于集成的REST API和168种世界货币和贵金属的实时和历史汇率来实现这些目标,它们以通用且易于解析的JSON格式提供,并且与任何应用程序兼容。

The universal real-time exchange rate data solution

通用实时汇率数据解决方案

In addition to providing update to date real-time exchange rates, currencylayer also provides historical exchange rates for all of their supported 168 world currencies. They provide historical exchange rates for way back as the past 16 years.

除了提供最新的实时汇率之外,currencylayer还提供其支持的所有168种世界货币的历史汇率。 他们提供了过去16年的历史汇率。

So what makes currencylayer perfect for your business? Well, here are some reasons:

那么,什么使currencylayer适合您的业务呢? 好吧,这是一些原因:

  • Reliable forex rates可靠的外汇汇率
  • Easy-to-integrate API易于集成的API
  • 256-bit HTTPS256位HTTPS
  • Advanced data coverage先进的数据覆盖
  • Real-time updates实时更新
  • Extended usage statistics扩展使用情况统计
  • Easy on your budget轻松节省预算
  • Interactive documentation互动文件

Did I mention that you can use most of these services completely for free? Sure you can! currencylayer has a free plan. With the free plan, you can make update to 1,000 API requests and the data are updated every hour.

我是否提到您可以完全免费使用其中大多数服务? 你当然可以! currencylayer有免费计划。 使用免费计划,您可以更新到1,000个API请求,并且每小时更新一次数据。

入门 ( Getting started )

To start using the services provided by currencylayer, you need to first create an account with them. So head over to the subscription plans page and signup for a free plan.

要开始使用currencylayer提供的服务,您需要首先使用它们创建一个帐户。 因此,请转到订阅计划页面并注册免费计划。

Once you have signed up, you will be presented with a 3-step quickstart guide. Step 1 contains your Access Key, which you will use to interact with ****the currencylayer API. In step 2, you are presented with the base URL of the currencylayer API:

注册后,将为您提供3个步骤的快速入门指南。 第1步包含您的访问密钥 ,您将使用该访问密钥与currencylayer API进行交互。 在第2步中,向您显示currencylayer API的基本URL:

@media (max-width: 1280px) { .go-go-gadget-react img:first-child { display: none; } }@media (max-width: 780px) {.go-go-gadget-react { flex-direction: column; }.go-go-gadget-react img { margin-left: 0 !important; margin-bottom: 12px !important; }.header-thingy { margin-top: 20px; }.button-thingy { margin-left: 0 !important; margin-top: 12px !important; }} @media (max-width: 1280px) { .go-go-gadget-react img:first-child { display: none; } }@media (max-width: 780px) {.go-go-gadget-react { flex-direction: column; }.go-go-gadget-react img { margin-left: 0 !important; margin-bottom: 12px !important; }.header-thingy { margin-top: 20px; }.button-thingy { margin-left: 0 !important; margin-top: 12px !important; }}

http://apilayer.net/api/

Take note of your access key and the base URL as we’ll be using them in the next section.

记下您的访问密钥和基本URL,因为我们将在下一部分中使用它们。

获取实时汇率 ( Fetching live exchange rates )

To get live exchange rates, we need to make request to the live endpoint of the currencylayer API. That is:

要获取实时汇率,我们需要向currencylayer API的live端点发出请求。 那是:

http://apilayer.net/api/live

We need to pass our access key to the above URL.

我们需要将访问密钥传递到上述URL。

The sample code in this article will be in Node.js and using Axios as the HTTP client:

本文中的示例代码将位于Node.js中,并将Axios用作HTTP客户端:

const axios = require('axios')const ACCESS_KEY = 'YOUR_ACCESS_KEY'axios.get(`http://apilayer.net/api/live?access_key=${ACCESS_KEY}&currencies=USD,EUR,GBP,AUD,NGN`).then(response => {console.log(response.data)
})

Here, we specify we want to get the exchange rates for five currencies: USD, EUR, GBP, AUD, and NGN. By default, USD will be used as the source. That is, the currency to which all exchange rates are relative. We can as well specify as different source:

在这里,我们指定要获取五种货币的汇率: USDEURGBPAUDNGN 。 默认情况下, USD将用作来源 。 也就是说,所有汇率都是相对的货币。 我们也可以指定不同的来源:

http://apilayer.net/api/live?access_key=YOUR_ACCESS_KEY&source=GBP

Below is the response gotten from the above request:

以下是从上述请求获得的响应:

{"success": true,"terms": 'https://currencylayer.com/terms',"privacy": 'https://currencylayer.com/privacy',"timestamp": 1526743687,"source": 'USD',"quotes": {"USDUSD": 1,"USDEUR": 0.849404,"USDGBP": 0.74245,"USDAUD": 1.331041,"USDNGN": 358.000344}
}

The response is pretty straightforward. The exchange rates are inside the quotes object.

响应非常简单。 汇率在quotes对象内。

获取历史汇率 ( Fetching historical exchange rates )

We have seen how to get live exchange rates. Now, let’s see how to fetch exchange rates from the past. For this, we make request to the historical of the currencylayer API, passing in our access key and a date in the past:

我们已经看到了如何获取实时汇率。 现在,让我们看看如何获​​取过去的汇率。 为此,我们向currencylayer API的historical记录发出请求,并传递访问密钥和过去的日期:

const axios = require('axios')const ACCESS_KEY = 'YOUR_ACCESS_KEY'axios.get(`http://apilayer.net/api/historical?access_key=${ACCESS_KEY}&date=2010-05-19&currencies=USD,EUR,GBP,AUD,NGN`).then(response => {console.log(response.data)
})

Here, we specify we want to get the exchange rates for a particular date (2010-05-19) in the past.

在此,我们指定要获取过去特定日期(2010-05-19)的汇率。

Below is the response gotten:

以下是得到的响应:

{"success": true,"terms": "https://currencylayer.com/terms","privacy": "https://currencylayer.com/privacy","historical": true,"date": "2010-05-19","timestamp": 1274313599,"source": "USD","quotes": {"USDUSD": 1,"USDEUR": 0.809694,"USDGBP": 0.69632,"USDAUD": 1.184999,"USDNGN": 152.073107}
}

In addition to the standard result sets, an historical API response contains an historical key with a value of true and the specified date.

除标准结果集外,历史API响应还包含一个具有true值和指定datehistorical键。

结论 ( Conclusion )

In this article, we have seen what currencylayer is, the service it provides and some reasons to use it in your business. Though, we only looked at two of the services currencylayer provides. In addition to live and historical exchange rates, currencylayer can also handle currency conversion and lot more.

在本文中,我们了解了什么是currencylayer,它提供的服务以及在您的业务中使用它的一些原因。 不过,我们只研究了currencylayer提供的两项服务。 除了实时汇率和历史汇率外,currencylayer还可以处理货币换算等。

For more information about currencylayer, do check out their website and their easy to understand documentation.

有关currencylayer的更多信息,请查看其网站和易于理解的文档 。

翻译自: https://scotch.io/tutorials/realtime-exchange-rates-with-currencylayer

实时获取汇率

实时获取汇率_Currencylayer实时汇率相关推荐

  1. python中美元人汇率_Python获取美元人民币实时汇率

    本文介绍如何如使用Python3获取美元人民币实时汇率. 一.数据来源 经过查找分析多种数据渠道,我们最终选定使用和讯外汇的行情数据.其网页地址为 http://quote.forex.hexun.c ...

  2. 获取美元人民币实时汇率-Python版

    本文介绍如何使用Python获取美元人民币实时汇率 # -*- coding: utf-8 -*- # @Author: 比特量化 # @Date: 2017-08-26import re impor ...

  3. python 人民币兑美元汇率代码_Python获取美元人民币实时汇率

    本文介绍如何如使用Python3获取美元人民币实时汇率. 一.数据来源 经过查找分析多种数据渠道,我们最终选定使用和讯外汇的行情数据.其网页地址为 http://quote.forex.hexun.c ...

  4. Python获取美元人民币实时汇率

    本文介绍如何如使用Python3获取美元人民币实时汇率. 一.数据来源 经过查找分析多种数据渠道,我们最终选定使用和讯外汇的行情数据.其网页地址为 http://quote.forex.hexun.c ...

  5. html汇率转换器,PHP_利用yahoo汇率接口实现实时汇率转换示例 汇率转换器,代码如下: 复制代码 代码如 - phpStudy...

    利用yahoo汇率接口实现实时汇率转换示例 汇率转换器 代码如下: function getExchangeRate($from_Currency,$to_Currency) { $amount = ...

  6. ceph bluestore源码分析:admin_socket实时获取内存池数据

    环境: 版本:ceph 12.2.1 部署完cephfs 使用ceph-fuse挂载,并写入数据 关键参数: debug_mempool = true 将该参数置为true即可查看详细的blustor ...

  7. jquery的实时触发事件(textarea实时获取中文个数)

    jquery的实时触发事件(textarea实时获取中文个数) (2014-09-16 11:49:50) 转载▼ 标签: 实时触发事件 中文个数 onpropertychange oninput o ...

  8. php 获取鼠标的坐标,如何实时获取鼠标的当前坐标-

    本文来做一个简单的实时获取鼠标坐标的功能,在canvas动画开发中,获取鼠标的坐标,键盘的按键等等,都是常用的操作,我们就慢慢得把他们封装成一个公共库. 一.事件的兼容:function bindEv ...

  9. MySQL-获取有性能问题SQL的方法_慢查询 实时获取

    文章目录 生猛干货 官方文档 使用慢查询获取慢SQL 慢查询的相关参数 slow_query_log 是否开启了慢查询 开启慢查询 slow_query_log_file 指定慢查询日志的存储路径及文 ...

最新文章

  1. ACMNO.39 分解质因数 求出区间[a,b]中所有整数的质因数分解。蓝桥杯训练!
  2. 【前端笔记】Vuex 是什么,为什么需要
  3. 为何倡导以质量为导向的项目管理?
  4. 2019年年初iOS招人心得笔记(附面试题)
  5. boot.ini文件解密
  6. 关于数据访问模式(三)—— Data Accessor模式
  7. python rpa_(RPA学习)Python 之 Pathlib 模块
  8. css优先级机制说明
  9. 洛谷 P2725 邮票题解
  10. Oracle 数据库和监听器开机自启动两种实现方法
  11. php 去掉字符串的最后一个字符
  12. Redis基础(十二)——缓存读写策略
  13. 基于AUTOSAR的AP平台的应用开发
  14. jpg、jpeg、png... 的区别
  15. 正常图片转灰色图片——灰度图
  16. UVA 123 Searching Quickly
  17. 这座研究所出了8位菲尔兹奖得主: 教授没有发论文压力,不指定方向,不必教课...
  18. LeetCode-75. 颜色分类(荷兰国旗问题)
  19. java 不能回滚_在Java 8中回滚()语句执行失败的最佳方法是什么?
  20. 国基北盛-openstack-容器云-环境搭建

热门文章

  1. python删除文件夹内打不开的图片
  2. 搜索长度未知的有序数组
  3. python代码:生成器
  4. 特征选择, 经典三刀
  5. Java编程中有哪些很酷的技巧?
  6. freemarker三元运算
  7. Flutter长图显示,自定义显示图片的指定区域
  8. android auto必须连接蓝牙吗,在Android中将autoConnect设置为true时,为什么应用程序不会重新连接到BLE设备?...
  9. windows10远程桌面粘贴板失效
  10. Spring:一、Spring的发展史-“富二代”公司成就了一个Spring帝国?