-1

I am asking if there is any crypto api which can accept a fiat currency of any amount(USD) and can convert the equivalent value to a crypto currency value(BTC,ETH,BCH,LTC).a typical example of what am talking about is google crypto converter. "bitcoin to usd" <= making this GET request to google will tell better.

https://exampledomain.com/search?=usd+to+eth&amount=100

Just something similar to this, I looked for something similar to this in cryptocompare api, programmableweb and others, but they only offer the price.. Any one with better idea

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
Fillipo Sniper
  • 419
  • 2
  • 11
  • 28
  • Why can't you just do the calculation yourself using the [CryptoCompare API](https://min-api.cryptocompare.com)? In fact, your topic, asking for an API, is actually off-topic here, but on the other hand if you are using that API and have problems with the calculation, posting your code and asking for help is very much on-topic here. – Ken Y-N Aug 21 '18 at 05:17
  • @KenY-N thanks for replying, as i have said before i already used it,and i still use some of cryptoCompare API in my web app, but under price in their api documentation, they only offer the current price of the coin specified. is there any other way of getting the price. i would have loved it if they have option with javascript – Fillipo Sniper Aug 21 '18 at 06:15

1 Answers1

2

This is very simple with JQuery. I demonstrate using the API from BTC to USD and USD to BTC to convert a given amount of dollars to BTC. It is really as simple as that to interface with a REST API in JavaScript.

var dollar_amount = 42.99;
$.get("https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD",function(data){
  BTC_amount = dollar_amount / data["USD"];
  console.log("Using USD to BTC $" + dollar_amount + " is " + BTC_amount + " BTC");
});

$.get("https://min-api.cryptocompare.com/data/price?fsym=USD&tsyms=BTC",function(data){
  BTC_amount = dollar_amount * data["BTC"];
  console.log("Using BTC to USD $" + dollar_amount + " is " + BTC_amount + " BTC");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Ken Y-N
  • 14,644
  • 21
  • 71
  • 114