如何通过API(如Google Finance)获取货币汇率?

如何通过API(如Google Finance)获取货币汇率?,api,google-finance-api,Api,Google Finance Api,现在,我确实找到了,并开始查看,但我发现了很多关于投资组合、交易、头寸和其他我一无所知的信息 我看错医生了吗?我需要做什么才能从GF那里获得汇率信息?这可能吗 编辑 让事情更清楚一点。我对技术性的东西不感兴趣,也不想要任何代码 据我所知,欧洲央行(ECB)也有最可靠的免费信息。它包含大约28种货币,并且至少每天更新一次 有关更多格式和工具,请参阅ECB参考页: 谢谢你的回答 自由兑换货币兑换商API: 费率每30分钟更新一次 免费服务器现在需要API密钥 示例转换URL为: 对于子孙后代

现在,我确实找到了,并开始查看,但我发现了很多关于投资组合、交易、头寸和其他我一无所知的信息

我看错医生了吗?我需要做什么才能从GF那里获得汇率信息?这可能吗

编辑

让事情更清楚一点。我对技术性的东西不感兴趣,也不想要任何代码

据我所知,欧洲央行(ECB)也有最可靠的免费信息。它包含大约28种货币,并且至少每天更新一次

有关更多格式和工具,请参阅ECB参考页:
谢谢你的回答

自由兑换货币兑换商API:

  • 费率每30分钟更新一次
  • 免费服务器现在需要API密钥
示例转换URL为:


对于子孙后代来说,这些问题还有其他可能的答案:

  • 雅虎财经API于2017年11月6日停播###
  • 自2017年11月06日起停产,信息为

    我们注意到,这项服务正在 违反雅虎的服务条款。因此,这项服务正在进行中 中止。对于所有未来市场和股票数据研究, 请访问finance.yahoo.com

    请求:
    这个CSV被一个名为jQuery的插件使用。由于稳定性问题,Curry从2017年8月29日开始改用fixer.io。 如果您需要的不仅仅是CSV,那么它可能会很有用

  • ()Yahoo查询语言允许您以XML或JSON格式一次获取大量货币。数据在第二天更新(而欧洲央行有一天以前的数据),并在周末停止。不需要任何形式的注册
  • 这是YQL查询生成器,您可以在其中测试查询并复制url:(不再可用)

  • 开源汇率API
  • (每月点击1000次)
    不允许在免费帐户中更改“基数”(从“美元”)
    需要注册。
    请求:
    答复:

       <!-- language: lang-js -->
    
        {
          "disclaimer": "This data is collected from various providers ...",
          "license": "all code open-source under GPL v3 ...",
          "timestamp": 1323115901,
          "base": "USD",
          "rates": {
              "AED": 3.66999725,
              "ALL": 102.09382091,
              "ANG": 1.78992886,
              // 115 more currency rates here ...
          }
        }
    
       <!-- language: lang-js -->
    
        {
          [...]
          "timestamp": 1436284516,
          "source": "USD",
          "quotes": {
              "USDAUD": 1.345352401,
              "USDCAD": 1.27373397,
              "USDCHF": 0.947845302,
              "USDEUR": 0.91313905,
              "USDGBP": 0.647603397,
              // 168 world currencies
              }
          }
    
    {
        "date": "2020-10-08 12:29:00+00",
        "base": "USD",
        "rates": {
            "FJD": "2.139",
            "MXN": "21.36942",
            "STD": "21031.906016",
            "LVL": "0.656261",
            "SCR": "18.106031",
            "CDF": "1962.53482",
            "BBD": "2.0",
            "GTQ": "7.783265",
            "CLP": "793.0",
            "HNL": "24.625383",
            "UGX": "3704.50271",
            "ZAR": "16.577611",
            "TND": "2.762",
            "CUC": "1.000396",
            "BSD": "1.0",
            "SLL": "9809.999914",
            "SDG": 55.325,
            "IQD": "1194.293591",
              .
              .
              .
        [179 currencies]
        }
    }
    
       <!-- language: lang-xml -->
    
        <Cube>
          <Cube time="2015-07-07">
          <Cube currency="USD" rate="1.0931"/>
          <Cube currency="JPY" rate="133.88"/>
          <Cube currency="BGN" rate="1.9558"/>
          <Cube currency="CZK" rate="27.100"/>
        </Cube>
    
        {
          "valid": true,
          "updated": 1567957373,
          "base": "USD",
          "rates": {
                  "AED": 3.673042,
                  "AFN": 77.529504,
                  "ALL": 109.410403,
                  // 165 currencies + some cryptos
              }
          }
    
    JSON响应:

       <!-- language: lang-js -->
    
        {
          "disclaimer": "This data is collected from various providers ...",
          "license": "all code open-source under GPL v3 ...",
          "timestamp": 1323115901,
          "base": "USD",
          "rates": {
              "AED": 3.66999725,
              "ALL": 102.09382091,
              "ANG": 1.78992886,
              // 115 more currency rates here ...
          }
        }
    
       <!-- language: lang-js -->
    
        {
          [...]
          "timestamp": 1436284516,
          "source": "USD",
          "quotes": {
              "USDAUD": 1.345352401,
              "USDCAD": 1.27373397,
              "USDCHF": 0.947845302,
              "USDEUR": 0.91313905,
              "USDGBP": 0.647603397,
              // 168 world currencies
              }
          }
    
    {
        "date": "2020-10-08 12:29:00+00",
        "base": "USD",
        "rates": {
            "FJD": "2.139",
            "MXN": "21.36942",
            "STD": "21031.906016",
            "LVL": "0.656261",
            "SCR": "18.106031",
            "CDF": "1962.53482",
            "BBD": "2.0",
            "GTQ": "7.783265",
            "CLP": "793.0",
            "HNL": "24.625383",
            "UGX": "3704.50271",
            "ZAR": "16.577611",
            "TND": "2.762",
            "CUC": "1.000396",
            "BSD": "1.0",
            "SLL": "9809.999914",
            "SDG": 55.325,
            "IQD": "1194.293591",
              .
              .
              .
        [179 currencies]
        }
    }
    
       <!-- language: lang-xml -->
    
        <Cube>
          <Cube time="2015-07-07">
          <Cube currency="USD" rate="1.0931"/>
          <Cube currency="JPY" rate="133.88"/>
          <Cube currency="BGN" rate="1.9558"/>
          <Cube currency="CZK" rate="27.100"/>
        </Cube>
    
        {
          "valid": true,
          "updated": 1567957373,
          "base": "USD",
          "rates": {
                  "AED": 3.673042,
                  "AFN": 77.529504,
                  "ALL": 109.410403,
                  // 165 currencies + some cryptos
              }
          }
    
  • Fixer.io API(欧洲央行数据)
  • 每月点击1000次的免费计划
    免费帐户中不允许更改“来源”(从“美元”) 需要注册。

    此API端点已弃用,将于2018年6月1日停止工作。有关更多信息,请访问:https://github.com/fixerAPI/fixer#readme)


    网站:http://fixer.io/
    请求示例: [http://api.fixer.io/latest?base=USD][7]
    每天只收集一个值
  • 欧洲中央银行提要
  • 文件:
    请求:

    XML响应:

       <!-- language: lang-js -->
    
        {
          "disclaimer": "This data is collected from various providers ...",
          "license": "all code open-source under GPL v3 ...",
          "timestamp": 1323115901,
          "base": "USD",
          "rates": {
              "AED": 3.66999725,
              "ALL": 102.09382091,
              "ANG": 1.78992886,
              // 115 more currency rates here ...
          }
        }
    
       <!-- language: lang-js -->
    
        {
          [...]
          "timestamp": 1436284516,
          "source": "USD",
          "quotes": {
              "USDAUD": 1.345352401,
              "USDCAD": 1.27373397,
              "USDCHF": 0.947845302,
              "USDEUR": 0.91313905,
              "USDGBP": 0.647603397,
              // 168 world currencies
              }
          }
    
    {
        "date": "2020-10-08 12:29:00+00",
        "base": "USD",
        "rates": {
            "FJD": "2.139",
            "MXN": "21.36942",
            "STD": "21031.906016",
            "LVL": "0.656261",
            "SCR": "18.106031",
            "CDF": "1962.53482",
            "BBD": "2.0",
            "GTQ": "7.783265",
            "CLP": "793.0",
            "HNL": "24.625383",
            "UGX": "3704.50271",
            "ZAR": "16.577611",
            "TND": "2.762",
            "CUC": "1.000396",
            "BSD": "1.0",
            "SLL": "9809.999914",
            "SDG": 55.325,
            "IQD": "1194.293591",
              .
              .
              .
        [179 currencies]
        }
    }
    
       <!-- language: lang-xml -->
    
        <Cube>
          <Cube time="2015-07-07">
          <Cube currency="USD" rate="1.0931"/>
          <Cube currency="JPY" rate="133.88"/>
          <Cube currency="BGN" rate="1.9558"/>
          <Cube currency="CZK" rate="27.100"/>
        </Cube>
    
        {
          "valid": true,
          "updated": 1567957373,
          "base": "USD",
          "rates": {
                  "AED": 3.673042,
                  "AFN": 77.529504,
                  "ALL": 109.410403,
                  // 165 currencies + some cryptos
              }
          }
    
  • CurrencyApi.net
  • 每月点击1250次
    150加密货币和实物货币-实时更新
    自由账户的基础货币设置为美元
    需要注册。
    文档:

    JSON响应:

       <!-- language: lang-js -->
    
        {
          "disclaimer": "This data is collected from various providers ...",
          "license": "all code open-source under GPL v3 ...",
          "timestamp": 1323115901,
          "base": "USD",
          "rates": {
              "AED": 3.66999725,
              "ALL": 102.09382091,
              "ANG": 1.78992886,
              // 115 more currency rates here ...
          }
        }
    
       <!-- language: lang-js -->
    
        {
          [...]
          "timestamp": 1436284516,
          "source": "USD",
          "quotes": {
              "USDAUD": 1.345352401,
              "USDCAD": 1.27373397,
              "USDCHF": 0.947845302,
              "USDEUR": 0.91313905,
              "USDGBP": 0.647603397,
              // 168 world currencies
              }
          }
    
    {
        "date": "2020-10-08 12:29:00+00",
        "base": "USD",
        "rates": {
            "FJD": "2.139",
            "MXN": "21.36942",
            "STD": "21031.906016",
            "LVL": "0.656261",
            "SCR": "18.106031",
            "CDF": "1962.53482",
            "BBD": "2.0",
            "GTQ": "7.783265",
            "CLP": "793.0",
            "HNL": "24.625383",
            "UGX": "3704.50271",
            "ZAR": "16.577611",
            "TND": "2.762",
            "CUC": "1.000396",
            "BSD": "1.0",
            "SLL": "9809.999914",
            "SDG": 55.325,
            "IQD": "1194.293591",
              .
              .
              .
        [179 currencies]
        }
    }
    
       <!-- language: lang-xml -->
    
        <Cube>
          <Cube time="2015-07-07">
          <Cube currency="USD" rate="1.0931"/>
          <Cube currency="JPY" rate="133.88"/>
          <Cube currency="BGN" rate="1.9558"/>
          <Cube currency="CZK" rate="27.100"/>
        </Cube>
    
        {
          "valid": true,
          "updated": 1567957373,
          "base": "USD",
          "rates": {
                  "AED": 3.673042,
                  "AFN": 77.529504,
                  "ALL": 109.410403,
                  // 165 currencies + some cryptos
              }
          }
    
  • 来自LabStack的货币
  • 网站:
    文档:
    定价:
    请求:
    答复:

    ```js
     {
       "time": "2019-10-09T21:15:00Z",
       "amount": 71.1488
     }
     ```
    
    :*来自yahoo.finance.xchange,成对输入(“USDEUR”、“USDJPY”、“USDBGN”、“USDCZK”、“USDDKK”、“USDGBP”、“USDHUF”、“USDLTL”、“USDLVL”、“USDPLN”、“USDRON”、“USDSEK”、“USDCHF”、“USDNOK”、“USDHRK”、“USDRUB”、“USDTRY”、“USDAUD”、“USDBRL”、“USDCAD”、“USDCNY”、“USDHKD”、“USDIDR”、“USDILS”、“USDINR”、“USDKRW”、“USDMXN”、“USDMYR”、“USDNZD”、“USDPHP”美元兑新加坡元、美元兑泰铢、美元兑南非兰特、美元兑冰岛克朗)和环境=store://datatables.org/alltableswithkeys

  • 货币api
    • 使用CDN实现自由快速响应
    • 没有利率限制
    • 150多种货币,包括通用加密货币
    • 每日更新
    网站:
    请求:
    答复:

       <!-- language: lang-js -->
    
        {
          "disclaimer": "This data is collected from various providers ...",
          "license": "all code open-source under GPL v3 ...",
          "timestamp": 1323115901,
          "base": "USD",
          "rates": {
              "AED": 3.66999725,
              "ALL": 102.09382091,
              "ANG": 1.78992886,
              // 115 more currency rates here ...
          }
        }
    
       <!-- language: lang-js -->
    
        {
          [...]
          "timestamp": 1436284516,
          "source": "USD",
          "quotes": {
              "USDAUD": 1.345352401,
              "USDCAD": 1.27373397,
              "USDCHF": 0.947845302,
              "USDEUR": 0.91313905,
              "USDGBP": 0.647603397,
              // 168 world currencies
              }
          }
    
    {
        "date": "2020-10-08 12:29:00+00",
        "base": "USD",
        "rates": {
            "FJD": "2.139",
            "MXN": "21.36942",
            "STD": "21031.906016",
            "LVL": "0.656261",
            "SCR": "18.106031",
            "CDF": "1962.53482",
            "BBD": "2.0",
            "GTQ": "7.783265",
            "CLP": "793.0",
            "HNL": "24.625383",
            "UGX": "3704.50271",
            "ZAR": "16.577611",
            "TND": "2.762",
            "CUC": "1.000396",
            "BSD": "1.0",
            "SLL": "9809.999914",
            "SDG": 55.325,
            "IQD": "1194.293591",
              .
              .
              .
        [179 currencies]
        }
    }
    
       <!-- language: lang-xml -->
    
        <Cube>
          <Cube time="2015-07-07">
          <Cube currency="USD" rate="1.0931"/>
          <Cube currency="JPY" rate="133.88"/>
          <Cube currency="BGN" rate="1.9558"/>
          <Cube currency="CZK" rate="27.100"/>
        </Cube>
    
        {
          "valid": true,
          "updated": 1567957373,
          "base": "USD",
          "rates": {
                  "AED": 3.673042,
                  "AFN": 77.529504,
                  "ALL": 109.410403,
                  // 165 currencies + some cryptos
              }
          }
    
    {
    “日元”:130.345642
    }
    
    如果您正在寻找一个基于ruby的解决方案来解决这个问题,我建议使用Google Calculator方法,一个类似以下的解决方案:

    需要“法拉第”
    需要“法拉第中间件”
    需要“json”
    #调试:
    #需要“撬动”
    国家代码(USD)
    国家代码=“印度卢比”
    连接=法拉第。获取(“http://www.google.com/ig/calculator?hl=en&q=1#{country_code_src}=?#{country_code_dst}”)
    currency_comparison_hash=eval connection.body#谷歌的输出不是JSON,而是一个散列
    dst_currency_value,*dst_currency_text=*currency_comparison_hash[:rhs]。拆分(“”)
    dst_currency_value=dst_currency_value.to_f
    dst_currency_text=dst_currency_text.join(“”)
    将“#{country_code_dst}->#{dst_currency_value}(#{dst_currency_text}放到1#{country_code_src}”)
    
    这里有一个简单的PHP脚本,可以获取英镑和美元之间的汇率

    我从


    雅虎有一个YQL功能,可以同时以XML或JSON格式获取一整套货币。我注意到数据在欧洲央行有一天的数据的那一分钟是最新的,并在周末停止

    这是他们的查询生成器,您可以在其中测试查询并复制url:


    对于所有搜索货币兑换提示的新手,请查看此链接

    这对我自己在C#的项目帮助很大。为了防止网站消失,我将添加下面的代码。只需将以下步骤添加到您自己的项目中。很抱歉格式化

    const string fromCurrency=“USD”;
    const string to currency=“EUR”;
    常数双倍金额=49.95;
    //有关其他货币符号,请参见http://finance.yahoo.com/currency-converter/
    //清除输出编辑器//可选使用,AFAIK
    Output.Clear();
    //构造URL来查询Yahoo!财务API
    常量字符串URL模式=”http://finance.yahoo.com/d/quotes.csv?s={0}{1}=X&f=l1”;
    字符串url=string.Format(urlPattern,fromCurrency,toCurrency);
    //以字符串形式获取响应
    字符串响应=新建WebClient()。下载字符串(url);
    //将字符串转换为数字
    双重汇率=
    解析(响应、系统、全球化、文化信息、不变量文化);
    //输出结果