Wednesday, 6 November 2013

FREE and REAL-TIME Currency conversion API

For some people that are looking for a FREE and REAL-TIME currency conversion API.
There are our contribution.

Call API Method:
devel.farebookings.com/api/curconversor/[currency from]/[currency to]/[amount]/[output type (optional)]

Page returns the TOTAL of amount in [currency to] currency.



Some examples of API use:


## We want convert one Euro to pounds.
devel.farebookings.com/api/curconversor/EUR/GBP/1/


## We want convert three Euro to pounds and output in json format.
devel.farebookings.com/api/curconversor/EUR/GBP/3/json


## We want a cross domain ajax API call.

$.ajax({
        url: "http://devel.farebookings.com/api/curconversor/EUR/GBP/1/",
        dataType: 'jsonp',
        success: function (data) {

            alert(data.GBP);

        }

});




Raul Torrico.
Web developer.
Farebookings.com

62 comments:

  1. Great Post. Thank you very much

    ReplyDelete
  2. Thanks to provide such real time conversation.
    One issue is australian dollar conversation not showing real value .
    I checked with google but its show some variance

    ReplyDelete
    Replies
    1. Hi, Jaywant,
      first, thanks for your review.
      You can see variance over the time of currency conversion here:
      http://www.x-rates.com/graph/?from=AUD&to=USD&amount=1.00
      The conversion can have littles changes in little time fractions.

      Delete
  3. Hi Raul,

    Thanks for your post.

    Is there any chance you will explain how to use it on JAVA

    ReplyDelete
    Replies
    1. Hi,
      You can choose many methods to obtain the returned data from the API...for example using curl. You need to include your curl java libraries in your project and send the url request to the API.

      Delete
  4. Hi Raul,
    Can you please share the complete list of the currencies supported?
    May be a link from where I can pull.
    Thanks in advance :)

    ReplyDelete
    Replies
    1. Hi Zaheer,
      http://en.wikipedia.org/wiki/ISO_4217
      Thanks

      Delete
  5. Dude I appreciate your help but The conversion rate is not that reliable I compared it with google,Yahoo, Oanda

    Onda has the best but I cant find any Api neither I could find any free xml file can you help me on this ?

    but I found a url which returns array to there website but If I use it return error

    http://www.oanda.com/lang/es/currency/converter/update?base_currency_0=CRC&quote_currency=USD&end_date=2014-01-10&view=details&id=9&action=C

    I would be thank full to you if you could help me out

    base_currency_0=CRC
    quote_currency=USD
    end_date=2014-01-10
    view=details
    action=C

    ReplyDelete
  6. Hi I am trying this and getting back an error using ajax.

    See anything wrong here?

    $.ajax({
    cache : false,
    type : "get",
    url : "http://devel.farebookings.com/api/curconversor/EUR/CAD/3/json",
    dataType : 'json',
    success : function(result){
    alert("in success")
    var items = $.parseJSON(result);
    alert(item.CAD);
    },
    error : function(xhr){
    alert(xhr.status + " " + xhr.statusText + " " + xhr.responseText)
    return;
    }
    });

    i always end up in the error with a status f 0 and te status text 0.
    Any and all help apprecited

    ReplyDelete
  7. All common Browsers do not allows Javasript Calls to access any Pages with another (sub)Domain because of the Same Origin Policy.
    The only way to work around that is to set up some kind of "proxy" on your own server (for example an php curl Script) that runs under the same Domain, gets the Information you want from a third source and prints them out.

    ReplyDelete
    Replies
    1. This comment has been removed by a blog administrator.

      Delete
    2. Now the API is ready to accept jsonp calls.
      Here an example of use.

      $.ajax({
      url: "http://devel.farebookings.com/api/curconversor/EUR/GBP/1/",
      dataType: 'jsonp',
      success: function (data) {

      alert(data.GBP);

      }

      });


      Enjoy!!

      Delete
    3. First of all thanks for the API. Now its showing a Slim Applicaiton Error and not working.

      Delete
    4. Hi Shiva,

      Thanks for the advice. I've fixed and now its working fine.

      Best Regards!

      Delete
    5. That was quick! Great job and once again thanks!

      Delete
  8. Hi Raul Torrico,

    can you please tell me how can i access this api's data into andoid..??

    ReplyDelete
    Replies
    1. You can use java.net or curl-java package.

      Delete
  9. Hi Raul,

    Which API you are using internally?

    ReplyDelete
  10. Hi,
    Can you tell me if there is any limitation on number of calls which can be made?
    Thanks

    ReplyDelete
  11. Hi Kate. There are any limitation, but, we will supervise any king of abuse, like too much calls that overtake normal use.

    ReplyDelete
    Replies
    1. Hi Raul,
      I am planning to embed this in one of my blog which is having a lot of hits. So expected usage is much high.
      I think you missed some word in last statement. Is it there are many restrictions or there are not any restrictions?
      Thanks

      Delete
  12. Hi Kate. Up to 20.000 hits/day....its ok for you??

    ReplyDelete
    Replies
    1. Hi,
      Yeah for now 20,000 hits per day is more than enough. Thanks for the info.

      Delete
  13. Hi, you can use this javascript snipet

    // include jquery

    var rate = 2; // put here your live rate
    var amount = 3;
    var curFrom = "EUR";
    var curTo = "GBP";
    var total = 0;

    $.ajax({
    url: "http://devel.farebookings.com/api/curconversor/"+curFrom+"/"+curTo+"/"+amount+"/",
    dataType: 'jsonp',
    success: function (data) {
    var conv = parseFloat(data[curTo]);
    total = conv + (conv * rate/100);

    alert(total);

    }

    });

    ReplyDelete
    Replies
    1. Do I have to define `rate` variable? Or is it optionally?

      Delete
  14. Thanks Raul!
    It really helps me
    I will use your api wisely

    ReplyDelete
  15. Is there a problem with the API? I get the error timeout 504

    ReplyDelete
    Replies
    1. I tested just now and work fine. Can you show me your code?. Thanks!

      Delete
  16. Until yesterday worked perfectly, I use the API in a Ruby on Rails application for months, thanks for your work. I will try and I will comment.

    Thanks

    ReplyDelete
    Replies
    1. Your comments will be appreciated! Thanks, again!

      Delete
    2. Today it works well again. I modified my code to catch the timeout error:

      class ExchangeRatesService

         def get_conversion (from, to, amount)
           begin
             result = client.get do | req |
               req.url "/api/curconversor/#{from}/#{to}/#{amount}/json"
               req.options.timeout = 25
             end
             JSON.parse(result.body)["#{to}"].to_f.round(5)
           rescue
             -1
           end
         end

         private

         def client
           client Faraday.new || = (
             "http://devel.farebookings.com/"
           )
         end

      end

      Thanks!

      Delete
  17. Server down? I get "404: File Not Found"

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. How do you use this in ionic with angularjs?
    Do i need to use $http?
    can you give me some example code please

    ReplyDelete
    Replies
    1. Hi Carl,
      better ask to angular developers, I can't help you in this kind of mobile/app/web technologies

      Delete
  20. i am not getting the alert in success or error block ? i dont know what error is in code ?
    $.ajax({
    cache : false,
    type : "get",
    url : "http://devel.farebookings.com/api/curconversor/EUR/GBP/1/",
    dataType : 'jsonp',
    success : function(result){
    alert("in success")
    var items = $.parseJSON(result);
    alert(item.CAD);
    },
    error : function(xhr){
    alert(xhr.status + " " + xhr.statusText + " " + xhr.responseText)
    return;
    }
    });

    ReplyDelete
    Replies
    1. Hi Sabarish,
      the response have not any error, but you are getting 'CAD' item that is undefined in ajax call url param. It must be 'GBP' in this case.
      The correct url param in this case is:
      http://devel.farebookings.com/api/curconversor/EUR/CAD/1/

      Cheers!

      Delete
  21. Hi Raul ,
    Thanks for you reply ....... you are right i coded wrongly.... if i used it as http://devel.farebookings.com/api/curconversor/EUR/CAD/1/ also not even getting an alert "in success"

    ReplyDelete
    Replies
    1. Hi again,

      You don't need parse result,
      just only get result item in this way:

      alert(result.CAD);

      Delete
    2. $.ajax({
      cache : false,
      type : "get",
      url : "http://devel.farebookings.com/api/curconversor/EUR/CAD/1/",
      dataType : 'jsonp',
      success : function(result){
      alert("in success")
      alert(result.CAD)
      },
      error : function(xhr){
      alert(xhr.status + " " + xhr.statusText + " " + xhr.responseText)
      return;
      }
      });

      Delete
  22. can i get response from https site to this api

    ReplyDelete
  23. we are you using this api last more then one year but yesterday we found it will not work and give 503 error message .
    so is it under maintenance or stop giving free support for exchange currency rates ?

    if you have any paid plan then also let me know as soon as possible.

    send me your paid plan details on puravshah6@gmail.com.

    we are ready to buy your paid service so please inform us as soon as possible.

    ReplyDelete
    Replies
    1. It was a technical issue, It's solved now. Sorry for the inconvenience.

      Delete
  24. Is it support cryptocurrencies like bitcoin and ether?

    ReplyDelete
    Replies
    1. Doesn't support bitcoin conversion. Sorry.

      Delete
  25. http://devel.farebookings.com/api/curconversor/INR/BTC/1000
    the above is not working, getting 404 Page Not Found error

    ReplyDelete
    Replies
    1. Hi, manda
      First, you forget slash at the end of sentence, and by the other side, api doesn't support bitcoin conversion.
      Thanks!!

      Delete
  26. How will I code using Volley api in Android

    ReplyDelete
    Replies
    1. Sorry but I haven't knowlegdment about Volley API for Android

      Delete
  27. Hi, getting Error 404 not found. Please assist, thanks.

    ReplyDelete
  28. This comment has been removed by the author.

    ReplyDelete
  29. This site will no longer be active?

    ReplyDelete