137

Now, I did find the Google Finance API and started looking through that but I found a lot of info about portfolios, transactions, positions & other stuff I know nothing about.

Am I looking at the wrong docs? What do I need to do to get a feed of exchange rates from GF? Is this even possible?

EDIT

To make things a little clearer. I'm not interested in technical stuff nor do I want any code.

George Stocker
  • 57,289
  • 29
  • 176
  • 237
Bogdan
  • 5,368
  • 9
  • 43
  • 62
  • see http://stackoverflow.com/a/21627583/592868 for a php-class using Yahoo! Finance – Felix Geenen Feb 07 '14 at 12:18
  • 3
    @George Stocker This question was originally very specific about some silly Google API which has been retired a while ago AFAIK. Somehow people started adding alternatives to that API and it transformed into some kind of index about currency exchange APIs. Obviously the community finds it useful since it got tons of votes and favourites... – Bogdan Mar 11 '14 at 19:11
  • @Bogdan What would you like me to do? – George Stocker Mar 11 '14 at 19:12
  • 4
    @GeorgeStocker Well, you can leave it closed if you feel it's against SO rules, but don't delete it; People seem to find this a good reference for this kind of stuff. My 2c. – Bogdan Mar 11 '14 at 19:26
  • @GeorgeStocker It is #1 in Google for currency javascript api's and incredibly useful. This item deserves to stay updated for it helps many many developers, which is the main reason stackoverflow was created. While you are right in the letter of the rule it is not in the spirit to close this topic, as there is no spam or opinionated answers to be found. I kindly request you open it again. – Jan Derk Aug 29 '14 at 18:20
  • @JanDerk I don't think it should be re-opened; but since we have a 'wiki answer' lock that allows you to edit the existing accepted answers to add more detail; that's a compromise I'm willing to make. if you want something more, you should bring this question up on meta. – George Stocker Aug 29 '14 at 18:23

9 Answers9

900

Thanks for all your answers.

Free currencyconverterapi:

  • Rates updated every 30 min
  • API key is now required for the free server.

A sample conversion URL is: http://free.currencyconverterapi.com/api/v5/convert?q=EUR_USD&compact=y


For posterity here they are along with other possible answers:

  1. Yahoo finance API Discontinued 2017-11-06###

Discontinued as of 2017-11-06 with message

It has come to our attention that this service is being used in violation of the Yahoo Terms of Service. As such, the service is being discontinued. For all future markets and equities data research, please refer to finance.yahoo.com.

Request: http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDINR=X
This CSV was being used by a jQuery plugin called Curry. Curry has since (2017-08-29) moved to use fixer.io instead due to stability issues. Might be useful if you need more than just a CSV.

  1. (thanks to Keyo) Yahoo Query Language lets you get a whole bunch of currencies at once in XML or JSON. The data updates by the second (whereas the European Central Bank has day old data), and stops in the weekend. Doesn't require any kind of sign up.

http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("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", "USDSGD", "USDTHB", "USDZAR", "USDISK")&env=store://datatables.org/alltableswithkeys

Here is the YQL query builder, where you can test a query and copy the url: (NO LONGER AVAILABLE)

http://developer.yahoo.com/yql/console/?q=show%20tables&env=store://datatables.org/alltableswithkeys#h=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22USDMXN%22%2C%20%22USDCHF%22%29

yql console no longer available

  1. Open Source Exchange Rates API

Free for personal use (1000 hits per month)
Changing "base" (from "USD") is not allowed in Free account
Requires registration.
Request: http://openexchangerates.org/latest.json
Response:

   <!-- 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 ...
      }
    }
  1. currencylayer API

Free Plan for 250 monthly hits
Changing "source" (from "USD") is not allowed in Free account
Requires registration.
Documentation: currencylayer.com/documentation

JSON Response:

   <!-- 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
          }
      }
  1. CurrencyFreaks API

Free Plan (1000 hits per month)
Changing 'Base' (From 'USD') is not allowed in free account
Requires registration
Data updated every 60 sec.
179 currencies worldwide including currencies, metals, and cryptocurrencies
Support (Even on the free plan) Shell,Node.js, Java, Python, PHP, Ruby, JS, C#, C, Go, Swift.
Documentation: https://currencyfreaks.com/documentation.html

Endpoint:

$ curl 'https://api.currencyfreaks.com/latest?apikey=YOUR_APIKEY'

JSON Response:

{
    "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]
    }
}
  1. Fixer.io API (European Central Bank data)

Free Plan for 1,000 monthly hits
Changing "source" (from "USD") is not allowed in Free account Requires registration.

This API endpoint is deprecated and will stop working on June 1st, 2018. For more information please visit: https://github.com/fixerAPI/fixer#readme)


Website : http://fixer.io/
Example request : [http://api.fixer.io/latest?base=USD][7]
Only collects one value per each day
  1. European Central Bank Feed

Docs: http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html#dev
Request: http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml

XML Response:

   <!-- 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>
  1. exchangeratesapi.io

According to the website:

Exchange rates API is a free service for current and historical foreign exchange rates published by the European Central Bank
This service is compatible with fixer.io and is really easy to use: no API key needed - UPDATE: API key is now needed, free tier is 250 requests/mo.
For example (this uses CURL, but you can use your favorite requesting tool):
    > curl https://api.exchangeratesapi.io/latest?base=GBP&symbols=USD&apikey=YOUR_KEY
    {"base":"GBP","rates":{"USD":1.264494191},"date":"2019-05-29"}
  1. CurrencyApi.net

Free Plan for 1250 monthly hits
150 Crypto and physical currencies - live updates
Base currency is set as USD on free account
Requires registration.
Documentation: currencyapi.net/documentation

JSON Response:

    {
      "valid": true,
      "updated": 1567957373,
      "base": "USD",
      "rates": {
              "AED": 3.673042,
              "AFN": 77.529504,
              "ALL": 109.410403,
              // 165 currencies + some cryptos
          }
      }
  1. Currency from LabStack

Website: https://labstack.com/currency
Documentation: https://labstack.com/docs/api/currency/convert
Pricing: https://labstack.com/pricing
Request: https://currency.labstack.com/api/v1/convert/1/USD/INR
Response:

```js
 {
   "time": "2019-10-09T21:15:00Z",
   "amount": 71.1488
 }
 ```

1: http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("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", "USDSGD", "USDTHB", "USDZAR", "USDISK")&env=store://datatables.org/alltableswithkeys

  1. currency-api

  • Free & Blazing Fast response using CDN
  • No Rate limits
  • 150+ Currencies, Including Common Cryptocurrencies
  • Daily Updated

Documentation: Link
Request: https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur/jpy.json
Request(Fallback): https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur/jpy.min.json
Response:

{
    "date": "2021-10-03",
    "jpy": 128.798673
}
Fawaz Ahmed
  • 1,082
  • 2
  • 14
  • 18
zeFree
  • 2,129
  • 2
  • 31
  • 39
  • 6
    Here is a [link](http://www.codereye.com/2009/03/java-currency-converter-using-yahoo.html) with more useful explanation of the Yahoo finance API. – Mzq Apr 24 '12 at 08:14
  • 4
    Please note the Open Exchange Rates project data has been moved away from GitHub (NO data available there now) and is now being served via http://openexchangerates.org - thanks! – William Joss Crowcroft Jun 24 '12 at 18:36
  • 2
    Is Yahoo finance API free for commercial use? Can not find any information that proves it. – sash Apr 14 '14 at 16:36
  • 1
    Note that many of the paid services (such as openchangerates.org) actually also use Yahoo as source. So as long as you only query every 15 minutes or so - you should be fine. The service can disappear any moment though adn that may be REALLY something to worry about. – user1914292 Nov 20 '14 at 09:52
  • 1
    open exchange rates website does not allow to get data with other base. they only allow a free user to get rates against USD only. – anu Dec 31 '14 at 00:49
  • Yahoo finance API doesn't work properly. Even querying once a day it just fails sometimes. – saganas Mar 02 '15 at 10:21
  • 2
    I'd like to also ask if Yahoo! data is free for commercial use. Say I have an e-commerce site, if I use the exchange rate in Y! to convert prices, is that legal? – Charlie Olson Apr 04 '15 at 05:38
  • 17
    rate-exchange.appspot doesn't work anymore.. – letitbefornow May 07 '15 at 14:54
  • Why I can only get XML when using second query statement of Yahoo API? How to get the JSON version? – Zen May 20 '15 at 04:04
  • 20
    http://rate-exchange.appspot.com/currency?from=USD&to=EUR is no longer available, please use http://rate-exchange-1.appspot.com/currency?from=USD&to=EUR instead. – Hippasus Jul 12 '15 at 11:06
  • 2
    For commercial use of Yahoo Query Language, one should get Yahoo approval, see https://developer.yahoo.com/yql/guide/usage_info_limits.html – roelleor Aug 04 '15 at 08:48
  • 1
    @zen for the yahoo api, to get it in json add '&format=json' in the url ;-) – Benoit Dec 05 '15 at 20:30
  • 1
    The rates and times in the YahooAPI are all over the place (refresh it). The YQL console has timeouts most of the time. I wouldn't recommend using any of these in any application. – EthernetCable Jun 07 '16 at 22:46
  • 3
    Sadly Yahoo terminated their service yesterday without warning, putting thousands of businesses in jeopardy. – FlorianB Nov 02 '17 at 23:17
  • 5
    UPDATE: Now Yahoo disabled the api with this message `It has come to our attention that this service is being used in violation of the Yahoo Terms of Service. As such, the service is being discontinued. For all future markets and equities data research, please refer to finance.yahoo.com.` – ZenithS Nov 06 '17 at 08:04
  • Fixer.io changed the base url to ```data.fixer.io/api``` and you now need an access key for a request. – mrks Mar 08 '18 at 11:13
  • Not one of those so called free or open currency exchange allow you to change the 'base' or 'source' currency, so they are effectively useless. You must pay for each and every one of them - not sure about the ECB though, that one looks free from a government funded organization. – Kraang Prime Mar 23 '18 at 20:51
  • 1
    1. Although many do not provide base currency for free, you can, from your client, with only the existing data API provides you, convert them to a different base currency by dividing each rate with the rate of the currency that you want to convert 2. Fixer provides all base currencies for free for a limited time by registering a legacy account: https://fixer.io/signup/legacy 3. Shameless plug: I created a python script that does point #1 and much much more by just registering a free Fixer account: https://github.com/asokratis/python-currency-fixer/ – softdevlife Apr 04 '18 at 17:25
  • Open Source Exchange Rates API is good but don't allow change the base currency at free account :(( – huykon225 Jun 25 '18 at 03:26
  • https://fincharts.info – Tino Costa 'El Nino' Jul 05 '18 at 17:52
  • 1
    Try this https://currencystack.io – Ben Scarberry Dec 11 '18 at 12:35
  • I've been using currencyconverterapi. However since yesterday the service is unavailable http://free.currencyconverterapi.com/api/v3/convert?q=USD_GBP&compact=ultra so effectively stooped working. No reply from the support email neither what's going on so far – nickornotto Jan 16 '19 at 23:03
  • free.currencyconverterapi.com is now required API key for free server. – PoundXI Jun 01 '19 at 08:32
  • The "http://free.currencyconverterapi.com/" doesn't work any more... Displaying "503 Service Unavailable No server is available to handle this request" – Biranchi Aug 01 '19 at 12:23
  • [free.currencyconverterapi.com/](https://free.currencyconverterapi.com/) is still working, it is now on v7 – Andang Rian Dimas Jan 17 '20 at 01:41
  • I wish all this "paid currencies exchange rate API" will dead soon and there is a reliable, open source script for all of us. – Drunken M Feb 22 '20 at 16:48
  • Here is another option: https://swop.cx/ Free plan allows 1000 requests per month. 180+ currencies. DEV friendly and easy to integrate GraphQL and REST endpoints. Disclaimer: I'm one of the SWOP developers :) – Luzian Oct 05 '20 at 15:37
  • 1
    I use CurrencyFreaks API it works for me perfectly. – Ihsan Ullah Khan Oct 08 '20 at 16:18
  • https://github.com/wmtbuddhika/currency-converter/tree/master – Thushara Buddhika May 06 '21 at 06:08
  • How about getting that XML for specific dates via the API in European Central Bank Feed? – Snow Jun 29 '21 at 14:39
  • 1
    This API is super simple and doesn't require App keys `https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur/usd.json` – Maksim Shamihulau Aug 13 '21 at 11:13
  • https://freecurrencyapi.net/ free plan support 50,000 hits – necip Oct 29 '21 at 09:22
  • Free currencyconverterapi needs api key and that will be expire in one month, every month you have to change api key which is bad – Manoj Sanjeewa Oct 14 '22 at 10:00
80

The European Central Bank (ECB) also has the most reliable free feed that I know of. It contains approx 28 currencies and is updated at least daily.

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

For more formats and tools see the ECB reference page: http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html

Ryan
  • 10,798
  • 11
  • 46
  • 60
  • 4
    too bad fixer.io comes with no warranty. Not for production. – pronebird Jul 27 '15 at 08:10
  • 3
    Unfortunately, it does not update on weekends. – Denis Dec 05 '15 at 21:22
  • 1
    Many forex trading markets are closed from 4pm EST on Friday to 5pm EST Sunday. If you really need more accurate weekend rates, then yes, I'd check a different stream. – Ryan Dec 07 '15 at 06:41
  • fixer.io updates only once at 4PM CET time. – Kishan Mehta May 02 '17 at 08:22
  • 1
    @Ryan But why it not showing all currencies? – Sunil Targe Jun 25 '17 at 12:50
  • 5
    Fixer.io service is sadly deprecated. There is an alternative compatible replacement Exchange rates API located at [exchangeratesapi.io](https://exchangeratesapi.io/) – madisvain Apr 11 '18 at 10:07
  • We switched from Fixer.io to https://www.completeapi.com. Works like a charm! And it's free. – rockstardev Sep 07 '18 at 08:46
  • 1
    Creator of Fixer here; I moved the app to https://frankfurter.app – Hakan Ensari Oct 19 '18 at 13:22
  • exchangeratesapi.io looked promising but `https://api.exchangeratesapi.io/latest?base=EUR&symbols=USD` will return: `{"rates":{"USD":1.1825},"base":"EUR","date":"2021-03-24"}` which is yesterdays date so I'm not sure on the accuracy of it. – Ste Mar 25 '21 at 15:20
52

This api is decommissioned

Yahoo has a YQL feature to get a whole bunch of currencies at once in XML or JSON. I've noticed the data is up to date by the minute where the ECB has day old data, and stops in the weekend.

http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("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", "USDSGD", "USDTHB", "USDZAR", "USDISK")&env=store://datatables.org/alltableswithkeys

Here is their query builder, where you can test a query and copy the url:

http://developer.yahoo.com/yql/console/?q=show%20tables&env=store://datatables.org/alltableswithkeys#h=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22USDMXN%22%2C%20%22USDCHF%22%29

Benbob
  • 13,876
  • 18
  • 79
  • 114
  • Hi @Keyo, when i try the YQL sample u have provided within my java code which tries to read as a URL i get an IO Exception (Server returned HTTP response code: 400 for URL: http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("USDEUR")&env=store://datatables.org/alltableswithkeys) which works if i just copy past this URL to the browser – Malik Firose Apr 29 '15 at 11:39
  • 'public static void main(String[] args) { String currencyPair = "USDEUR"; String address = "http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in (\"" + currencyPair + "\")&env=store://datatables.org/alltableswithkeys"; try { // String response = URLReader.read(address); // System.out.println(response); URL url = new URL(address); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }' – Malik Firose Apr 29 '15 at 11:39
  • Hi @Keyo, is there a way of obtaining the high/low rate for a specific time frame in YQL? – awawjerh Jan 18 '16 at 18:31
  • 4
    Sadly Yahoo terminated their service yesterday without warning, putting thousands of businesses in jeopardy. – FlorianB Nov 02 '17 at 23:17
  • This API seems to be permanently disabled. – reducing activity Nov 30 '18 at 08:46
51

If you need a free and simple API for converting one currency to another, try free.currencyconverterapi.com.

Disclaimer, I'm the author of the website and I use it for one of my other websites.

The service is free to use even for commercial applications but offers no warranty. For performance reasons, the values are only updated every hour.

A sample conversion URL is: http://free.currencyconverterapi.com/api/v6/convert?q=EUR_PHP&compact=ultra&apiKey=sample-api-key which will return a json-formatted value, e.g. {"EUR_PHP":60.849184}

Manny
  • 6,277
  • 3
  • 31
  • 45
  • 1
    Thanks. What is the source of conversion rates? This gives us possibility to measure reliability of your service. – s3m3n Apr 12 '15 at 00:19
  • There are various sources of conversion rates, and fallback measure if one of the sources failed. Y! is one of them. – Manny Jun 05 '15 at 09:31
  • 1
    Works Nov 2017. Thanks for providing it. But please keep providing it as sites depend on it. Was using Yahoo Finance which just died. – Tuntable Nov 18 '17 at 08:38
  • Can't get a list exchange with free.currencyconverterapi.com. so sad :( – huykon225 Jun 25 '18 at 03:27
  • If you are the author then see my comment to previous answer @Manny – nickornotto Jan 16 '19 at 23:05
  • 1
    Powerful. Thanks author – james Oduro Jul 15 '19 at 19:24
  • 1
    I will upgrade to premium soon. – james Oduro Jul 15 '19 at 19:25
  • Doesn't work any more... Displaying "503 Service Unavailable No server is available to handle this request" – Biranchi Aug 01 '19 at 12:22
  • 4
    It is NOT free anymore. Free is only for testing/demo use. If you request more then it will return 400 and give you error: "The system has detected this request as an abuse of the free service. If you need more requests, please consider using the paid service. Please check currencyconverterapi.com/pricing for more information. Thank you." and block your ip and api-key. – Swifty Mar 17 '20 at 08:12
  • Also fetch requests to this server in Firefox seems to get blocked by built-in Ad-blocker for whatever reason – emvaized Feb 17 '21 at 09:31
  • 1
    This is pretty old now however as of time of writing this comment, I found it quite difficult to find a free conversion API for learning & demo. This site is still rolling free for demo. Thanks dude! – RobbB Jun 01 '21 at 02:16
16

Here are some exchange APIs with PHP example.

[ Open Exchange Rates API ]

Provides 1,000 requests per month free. You must register and grab the App ID. The base currency USD for free account. Check the supported currencies and documentation.

// 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

[ Currency Layer API ]

Provides 1,000 requests per month free. You must register and grab the Access KEY. Custom base currency is not supported in free account. Check the documentation.

$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

hd1
  • 33,938
  • 5
  • 80
  • 91
Madan Sapkota
  • 25,047
  • 11
  • 113
  • 117
  • 15
    Hits quota very easily..not recommended. – Ayush Goyal Jan 25 '14 at 07:52
  • 7
    @AyushGoyal If you're hitting the API for every conversion then you're doing it wrong anyway. Setup a cronjob to query the API every hour and store current exchange rates in a database table and when you need to do exchange calculations pull the data from the table as often as you like. You will never hit the monthly limit that way. – tpartee Jun 06 '17 at 19:56
1

You can try geoplugin

Beside the geolocation done by IP (but the IP is the provider IP, so not so accurate), they return currencies also and have a currency converter: see examples.

They have 111 currencies updated.

Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
0

If you're looking for a ruby based solution for this problem, I recommend using the Google Calculator method a solution similar to the following: 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})"
Linus Caldwell
  • 10,908
  • 12
  • 46
  • 58
ylluminate
  • 12,102
  • 17
  • 78
  • 152
0

Here is one simple PHP Script which gets exchange rate between GBP and 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 currency rates are not accurate google itself says ==> Google cannot guarantee the accuracy of the exchange rates used by the calculator. You should confirm current rates before making any transactions that could be affected by changes in the exchange rates. Foreign currency rates provided by Citibank N.A. are displayed under licence. Rates are for information purposes only and are subject to change without notice. Rates for actual transactions may vary and Citibank is not offering to enter into any transaction at any rate displayed.

Linus Caldwell
  • 10,908
  • 12
  • 46
  • 58
mohamed nur
  • 331
  • 1
  • 15
-1

For all newbie guys searching for some hint about currency conversion, take a look at this link. Datavoila

It helped med a lot regarding my own project in C#. Just in case the site disappears, I'll add the code below. Just add the below steps to your own project. Sorry about the formatting.

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);
Linus Caldwell
  • 10,908
  • 12
  • 46
  • 58
Emperor 2052
  • 517
  • 1
  • 5
  • 14