Programming Tutorials

How to make a simple Dogecoin price fetcher in Javascript.

After a few hours of screwing around with Cryptsy's API, I found it much easier to use the API from

Dogeapi.com

. So I thought Id share my simple script with everyone else.


Step 1 - Configuring the URL

This url -

https://www.dogeapi.com/wow/v2/?a=get_current_price&convert_to=usd&amount_doge=1

currently returns the price of one DOGE in USD. If you want it to return a different amount or in a different currency, edit the highlighted areas.


Step 2 - Writing the script

This script isnt long, so we dont need to go into much detail about it.

First, get the easy stuff out of the way, write -

$(document).ready(function () {

and

$.get("https://www.dogeapi.com/wow/v2/?a=get_current_price&convert_to=usd&amount_doge=1", function(data){

Second, we need to define our variables.

We can see from the link that the value we're looking for is called "amount", so we will define it as "dprice" with -

var dprice = (data.data.amount);

Lastly, we need to insert our newly defined price into our HTML, we do this with -

$('#result').text("1 Dogecoin = $" + dprice);

(You will need to write something with the ID "result" in your HTML to insert this)


Step 3 - We're done! Just add in the brackets, and the script will be complete and ready to run. Our full script will look exactly like this -

Finished Product

Back