现在,我确实找到了 Google Finance API 并开始查看这一点,但我发现了很多有关投资组合,交易,职位和其他我一无所知的东西的信息。

我在看错误的文档吗?我需要做什么才能从GF获取汇率?这甚至可能吗?

编辑

使事情变得更加清晰。我对技术知识不感兴趣,也不需要任何代码。

有帮助吗?

解决方案

感谢您的所有答案。

免费的货币转换:

  • 费率每30分钟更新一次
  • 现在,免费服务器需要API密钥。

样本转换URL是: http://free.currencyconverterapi.com/api/v5/convert?q=eur_usd&compact=y


对于后代,他们还有其他可能的答案:

  1. 雅虎金融API 停产2017-11-06

    截至2017-11-06,已停产

    引起我们的注意,这项服务被用于违反Yahoo服务条款。因此,该服务正在停产。有关所有未来的市场和股票数据研究,请参阅finance.yahoo.com。

    要求: http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=usdinr=x
    此CSV正在由名为的jQuery插件使用 咖喱. 。库里(Curry)自(2017-08-29)以来一直在使用fixer.io而改为稳定性问题。如果您不仅需要CSV,可能会有用。

  2. (感谢Keyo) 雅虎查询语言 让您在XML或JSON中立即获得一堆货币。数据更新第二次(欧洲中央银行有一整天的数据),并在周末停止。不需要任何类型的注册。

    http://query.yahooapis.com/v1/public/YQL?q=select *来自yahoo.finance.xchange where Pair In(“ USDEUR”,“ USDJPY”,“ USDJPY”,“ USDBGN”,“ “ USDGBP”,“ USDHUF”,“ USDLTL”,“ USDLVL”,“ USDPLN”,“ USDRON”,“ USDSEK”,“ USDCHF”,“ USDNOK”,“ USDHRK”,“ USDHRK” ”,“ USDBRL”,“ USDCAD”,“ USDCNY”,“ USDHKD”,“ USDIDR”,“ USDILS”,“ USDINR”,“ USDKRW”,“ USDMXN”,“ USDMXN”,“ USDMYR”,“ USDMYR”,“ USDNZD”,“ USDNZD”,“ USDPHP”,“”,“”,“”,“”,“ “ USDSGD”,“ USDTHB”,“ USDZAR”,“ USDISK”)&ENV = Store://datatables.org/alltableswithableswithkeys

    这里是 YQL查询构建器, ,您可以在其中测试查询并复制URL :(不再可用)

    http://develveper.yahoo.com/yql/console/?q=show%20Tables&env=Store://datatables.org/alltableswithableswithekeys#select%20* %%20*%20*%20 fom%20from%20yahoo.finance.finance.xchange; xchange%20WerwhandWerwhera; 20in%20%28%22USDMXN%22%2C%20%22USDCHF%22%29

enter image description here

  1. 开源汇率API

    免费用于个人用途 (每月1000次命中)
    更改“基础”(从“美元”)不允许在免费帐户中
    需要注册。
    要求: http://openexchangerates.org/latest.json
    回复:

    {
      "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 ...
      }
    }
    
  2. 货币套件API

    免费计划 每月250次命中
    免费帐户中不允许更改“源”(从“ USD”)
    需要注册。
    文档: 货币layer.com/documentation

    JSON回应:

    {
      [...]
      "timestamp": 1436284516,
      "source": "USD",
      "quotes": {
          "USDAUD": 1.345352401,
          "USDCAD": 1.27373397,
          "USDCHF": 0.947845302,
          "USDEUR": 0.91313905,
          "USDGBP": 0.647603397,
          // 168 world currencies
          }
      }
    
  3. FIXER.IO API(欧洲中央银行数据)

    每月1000次打击的免费计划
    在免费帐户中不允许更改“源”(从“ USD”)需要注册。

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


    网站 : http://fixer.io/
    示例请求:http://api.fixer.io/latest?base=usd
    每天只收集一个价值

  4. 欧洲中央银行饲料

    文档:http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html#dev
    要求: http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml

    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>
    
  5. Exchangeratesapi.io

    根据网站:

    汇率API是欧洲中央银行发布的当前和历史外汇率的免费服务
    该服务与Fixer.io兼容,并且确实易于使用:无需API密钥。例如(这使用卷曲,但是您可以使用自己喜欢的请求工具):

    > curl https://api.exchangeratesapi.io/latest?base=GBP&symbols=USD
    {"base":"GBP","rates":{"USD":1.264494191},"date":"2019-05-29"}
    
  6. CurrencyApi.net

    免费计划 对于1250个每月命中
    基本货币被设置为免费帐户上的美元
    需要注册。
    文档: Currencyapi.net/documentation

    JSON回应:

    {
      "valid": true,
      "timestamp": 1567957373,
      "base": "USD",
      "rates": {
              "AED": 3.673042,
              "AFN": 77.529504,
              "ALL": 109.410403,
              // 165 currencies + some cryptos
          }
      }
    

其他提示

欧洲中央银行(ECB)也拥有我所知道的最可靠的免费饲料。它包含大约28个货币,至少每天更新。

http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml

有关更多格式和工具,请参见欧洲央行参考页:http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html

如果您需要免费而简单的API将一种货币转换为另一种货币,请尝试 Free.CurrencyConverterapi.com.

免责声明,我是该网站的作者,我将其用于其他网站之一。

该服务即使用于商业应用程序也可以免费使用,但不提供任何保修。出于绩效原因,每小时仅更新值。

样本转换URL是: http://free.currencyconverterapi.com/api/v6/convert?q=eur_php&compact=ultra&apikey=sample-api-key 它将返回JSON形式的值,例如{“ EUR_PHP”:60.849184}

我从中得到了这个内容 http://www.scriptarticle.com/2012/05/03/get-live-currency-rates-rates-and-currency-conversion-using-php-and-apis/

<?php

function get_currency($from_Currency, $to_Currency, $amount) {
    $amount = urlencode($amount);
    $from_Currency = urlencode($from_Currency);
    $to_Currency = urlencode($to_Currency);

    $url = "http://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency";

    $ch = curl_init();
    $timeout = 0;
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt ($ch, CURLOPT_USERAGENT,
                 "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $rawdata = curl_exec($ch);
    curl_close($ch);
    $data = explode('bld>', $rawdata);
    $data = explode($to_Currency, $data[1]);

    return round($data[0], 2);
}

// Call the function to get the currency converted
echo get_currency('USD', 'INR', 1);

?>

这是一些带有PHP示例的交换API。

[ 开放汇率API ]

每月免费提供1,000条请求。您必须注册并获取应用程序ID。基本货币美元免费帐户。检查 支持的货币文档.

// open exchange URL // valid app_id * REQUIRED *
$exchange_url = 'https://openexchangerates.org/api/latest.json';
$params = array(
    'app_id' => 'YOUR_APP_ID'
);

// make cURL request // parse JSON
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => $exchange_url . '?' . http_build_query($params),
    CURLOPT_RETURNTRANSFER => true
));
$response = json_decode(curl_exec($curl));
curl_close($curl);

if (!empty($response->rates)) {
    // convert 150 USD to JPY ( Japanese Yen )
    echo $response->rates->JPY * 150;
}

150 USD = 18039.09015 JPY

[ 货币层API ]

每月免费提供1,000条请求。您必须注册并获取访问密钥。自定义基本货币是 不是 在免费帐户中支持。检查 文档.

$exchange_url = 'http://apilayer.net/api/live';
$params = array(
    'access_key' => 'YOUR_ACCESS_KEY',
    'source' => 'USD',
    'currencies' => 'JPY',
    'format' => 1 // 1 = JSON
);

// make cURL request // parse JSON
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => $exchange_url . '?' . http_build_query($params),
    CURLOPT_RETURNTRANSFER => true
));
$response = json_decode(curl_exec($curl));
curl_close($curl);

if (!empty($response->quotes)) {
    // convert 150 USD to JPY ( Japanese Yen )
    echo '150 USD = ' . $response->quotes->USDJPY * 150 . ' JPY';
}

150 USD = 18036.75045 JPY

你可以试试 地理流线

除了IP完成的地理位置外(但是IP是提供商IP,因此不是那么准确),它们还返回货币并具有货币转换器:请参见示例。

他们有111次货币更新。

如果您正在寻找此问题的基于Ruby的解决方案,建议使用Google Carculator方法与以下方面的类似解决方案: http://j.mp/QIC564

require 'faraday'
require 'faraday_middleware'
require 'json'

# Debug: 
# require "pry"


country_code_src = "USD"
country_code_dst = "INR"
connection = Faraday.get("http://www.google.com/ig/calculator?hl=en&q=1#{country_code_src}=?#{country_code_dst}")

currency_comparison_hash = eval connection.body #Google's output is not JSON, it's a hash

dst_currency_value, *dst_currency_text = *currency_comparison_hash[:rhs].split(' ')
dst_currency_value = dst_currency_value.to_f
dst_currency_text = dst_currency_text.join(' ')

puts "#{country_code_dst} -> #{dst_currency_value} (#{dst_currency_text} to 1 #{country_code_src})"

这是一个简单的PHP脚本,它在GBP和USD之间获得汇率

<?php
$amount = urlencode("1");
$from_GBP0 = urlencode("GBP");
$to_usd= urlencode("USD");
$Dallor = "hl=en&q=$amount$from_GBP0%3D%3F$to_usd";
$US_Rate = file_get_contents("http://google.com/ig/calculator?".$Dallor);
$US_data = explode('"', $US_Rate);
$US_data = explode(' ', $US_data['3']);
$var_USD = $US_data['0'];
echo $to_usd;
echo $var_USD;
echo '<br/>'; 
?>

Google货币利率不是准确的Google本身说==> Google无法保证计算器使用的汇率的准确性。您应该在进行任何可能受汇率变化影响的交易之前确认当前费率。花旗银行NA提供的外币汇率按照许可显示。费率仅用于信息目的,并且可能会更改,恕不另行通知。实际交易的费率可能会有所不同,花旗银行不提供任何显示的交易。

对于所有搜索有关货币转换的暗示的新手家伙,请查看此链接。 datavoila

关于我自己在C#中的项目,它有很多帮助。以防万一网站消失,我将在下面添加代码。只需将以下步骤添加到您自己的项目中即可。抱歉,格式化。

const string fromCurrency = "USD";
const string toCurrency = "EUR";
const double amount = 49.95;
// For other currency symbols see http://finance.yahoo.com/currency-converter/
// Clear the output editor //optional use, AFAIK
Output.Clear();

// Construct URL to query the Yahoo! Finance API
const string urlPattern = "http://finance.yahoo.com/d/quotes.csv?s={0}{1}=X&f=l1";
string url = String.Format(urlPattern, fromCurrency, toCurrency);

// Get response as string
string response = new WebClient().DownloadString(url);

// Convert string to number
double exchangeRate =
    double.Parse(response, System.Globalization.CultureInfo.InvariantCulture);

// Output the result
Output.Text = String.Format("{0} {1} = {2} {3}",
                            amount, fromCurrency,
                            amount * exchangeRate, toCurrency);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top