Jump to content

Ghost
 Share

Recommended Posts

How you can fetch cryptocurrency price data with Javascript/JQuery

<div id="dprice"></div>
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script>
    fetch('https://api.coingecko.com/api/v3/coins/denarius?tickers=true&market_data=true&community_data=true&developer_data=true&sparkline=false')
    .then((response) => {
      return response.text();
    })
    .then((myContent) => {
        var market = JSON.parse(myContent);
        var info = market["market_data"]["current_price"]["usd"];
        document.getElementById('dprice').innerHTML = info;
    });
</script>

Simply put this code into any HTML file, the script goes at the bottom of your HTML. This example fetches the Denarius (D) price from Coingecko's API

  • The D 1

Founder of BlockForums.org - PM me for any help - Join our Discord Server: https://discord.gg/UPpQy3n

100703395-b1ee6600-3360-11eb-82bc-96818c

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...