Convert Euro to Dogecoin

So, I'm going to integrate the dog into my busniess website. My products are available for purchase in EUR currency and are available for its provision in doecoin. I need to convert EURO to Dogecoin.

What is my DID . I found the DOGECOIN API ( https://www.dogeapi.com ) in php. I found that we can convert DOGECOIN to BTC or USD. Using this:

https://www.dogeapi.com/wow/?a=get_current_price&convert_to=USD&amount_doge=1000

The above url gives me a total USD of DOGE AMOUNT.output: 1.13949000

My question is : How can I convert EURO to DOGEAMOUNT? I have a lot of search and no solution found. please help. Thanks in advance.

+4
source share
2 answers

A bit messy, but it works (it uses a different url to exchange for USD, EUR )

$doge2usd = file_get_contents("https://www.dogeapi.com/wow/?a=get_current_price&convert_to=USD&amount_doge=1");
echo sprintf("1 dogecoin => %f usd",$doge2usd);   // 1 DOGE => USD 0.00115078

$eur2usd = file_get_contents("http://rate-exchange.appspot.com/currency?from=EUR&to=USD");
$j = json_decode($eur2usd,TRUE);
$doge2eur = $doge2usd * (1 / $j["rate"]);        // 1 DOGE => 0.00083941557920536 EUR
echo sprintf("<br>1 dogecoins => %f euro, 5 dogecoins => %f euro",$doge2eur,$doge2eur*5);

$eur2doge = 1 / $doge2eur;  // 1 EUR => DOGE 1197.29
echo sprintf("<br>1 euro => %f dogecoins, 5 euro => %f dogecoins",$eur2doge,$eur2doge*5);
+1
source

dogeapi.com API can only give you the exchange rate in BTC or USD. To get the exchange rate from XDG (is this an unofficial three-letter code for Dogecoin? Suppose that) to EUR, you need to take two steps:

  • Get exchange rates from XDG to USD.
  • Get the exchange rate from USD to EUR.

For the first, we have DogeAPI. For the second, I will use the Yahoo API.

<?php

// how much is 1 dogecoin worth in USD?
$xdgusd = (double)file_get_contents("https://www.dogeapi.com/wow/?a=get_current_price&convert_to=USD&amount_doge=1");

// how much is 1 EUR worth in USD?
$yahoo_result = json_decode(file_get_contents("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20=%20%22EURUSD%22&format=json&env=store://datatables.org/alltableswithkeys&callback="));
$eurusd = (double)$yahoo_result->query->results->rate->Rate;

// how much is 1 dogecoin worth in EUR?
$xdgeur = $xdgusd / $eurusd;

echo "Doge in USD: " . $xdgusd . "\n";
echo "EUR in USD: " . $eurusd . "\n";
echo "Doge in EUR: " . $xdgeur . "\n";

Fingerprints:

Doge in USD: 0.00113941
EUR in USD: 1.3713
Doge in EUR: 0.00083089768832495

, , /. , - , . , API.

+1

Source: https://habr.com/ru/post/1529373/


All Articles