4

SO I am going to integrate the dogecoin in to the my busniess website. My Products are avilable to purchase in EURO currency and for avilable to provide it in doecoin I need to convert the EURO to Dogecoin.

What I have DID: I have found the DOGECOIN API (https://www.dogeapi.com) in php. i have found that we can convert the DOGECOIN in 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 the total USD from DOGE AMOUNT.output is : 1.13949000

My Question is : How Can i convert the EURO in DOGEAMOUNT ? I have search alot and not found any solution . please help. Thanks in Advance.

Donnie Rock
  • 552
  • 1
  • 14
  • 27
Jatin
  • 71
  • 6
  • You just need an exchange rate, don't you? Choose the exchange website that you want to relay on and you their API to get current exchange rate. – Jakub Matczak Feb 28 '14 at 08:01
  • I have found the currency converter website (http://coinmill.com/EUR_XDG.html) , I don't think it is reliable and they do not provide the API.Site Should convert the currency with live rate. – Jatin Feb 28 '14 at 08:03
  • What about cryptsy.com? They are trading DOGEs and are quite popular. They have API too. – Jakub Matczak Feb 28 '14 at 08:08
  • Maybe this post could help you to find the way to convert USD currency in Euro. http://stackoverflow.com/questions/19902952/currency-converter-api – Donnie Rock Feb 28 '14 at 08:16
  • @dragoste It seems that cryptsy.com also doesn't convert the EURO to DOGECOIN. – Jatin Feb 28 '14 at 08:50
  • You DO NOT need any converter, but only exchange rate. What's the problem in doing `DOGE = exRate*EUR` on your side? – Jakub Matczak Feb 28 '14 at 08:53
  • @DonnieRock he soultion in to the URL is also don't have the conversion from EURO to dogecoin. – Jatin Feb 28 '14 at 08:54
  • @Jatin, you've said the dogeapi converts Dogecoin to USD. If you have the USD currency you could convert it to Euro using another currency api. – Donnie Rock Feb 28 '14 at 09:01
  • @dragoste how can i get the exchange rate of euro to doge from cryptsy.com ? can you please provide any example ? – Jatin Feb 28 '14 at 09:12
  • Cryptsy was just an example. Or you can for example exchange USD to EUR as @Carsten suggested in his answer. – Jakub Matczak Feb 28 '14 at 09:24

2 Answers2

1

A bit messy but does the work (it uses another url to get exchanges 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);
  • Great..!!Many Thanks...Using this way i can get the DOGE COINS amount from euro amount. – Jatin Feb 28 '14 at 09:58
1

The dogeapi.com API can only give you the exchange rate in BTC or USD. To get the exchange rate from XDG (is that the inofficial three-letter-code for Dogecoin? Let's just assume that) to EUR, you'll have to take two steps:

  1. Get the exchange rate from XDG to USD.
  2. Get the exchange rate from USD to EUR.

For the first one, we have DogeAPI. For the second one, I'm going to use Yahoo's 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";

This prints:

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

Please note that this example doesn't cover details like bis/ask spread. Also, in a real system, you shouldn't query the web services with every request, but cache the result on your machine. And check if you got sane values back from the APIs.

Carsten
  • 17,991
  • 4
  • 48
  • 53
  • Great..I just want to make sure that yahoo apis gives the real time rate of currency ? – Jatin Feb 28 '14 at 09:25
  • 1
    If you inspect the the JSON structure returned by the query to the Yahoo API, you'll see quote's date and time. They seem to be based on New York's time zone (EST, GMT-5), though, so you have to convert that for your time zone. If I query the API, the quote only seems to be a minute old or so. – Carsten Feb 28 '14 at 09:33