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